Coverage Report - org.eclipse.swtbot.swt.finder.waits.ShellCloses
 
Classes in this File Line Coverage Branch Coverage Complexity
ShellCloses
85%
6/7
N/A
1.25
ShellCloses$1
100%
3/3
75%
3/4
1.25
 
 1  4
 /*******************************************************************************
 2  
  * Copyright (c) 2008 Ketan Padegaonkar and others.
 3  
  * All rights reserved. This program and the accompanying materials
 4  
  * are made available under the terms of the Eclipse Public License v1.0
 5  
  * which accompanies this distribution, and is available at
 6  
  * http://www.eclipse.org/legal/epl-v10.html
 7  
  *
 8  
  * Contributors:
 9  
  *     Ketan Padegaonkar - initial API and implementation
 10  
  *******************************************************************************/
 11  
 package org.eclipse.swtbot.swt.finder.waits;
 12  
 
 13  
 
 14  
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 15  
 import org.eclipse.swtbot.swt.finder.results.BoolResult;
 16  
 import org.eclipse.swtbot.swt.finder.utils.internal.Assert;
 17  
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 18  
 
 19  
 /**
 20  
  * A condition that waits until the specified shell is disposed/visible.
 21  
  *
 22  
  * @see Conditions
 23  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 24  
  * @version $Id$
 25  
  * @since 1.2
 26  
  */
 27  
 class ShellCloses extends DefaultCondition {
 28  
 
 29  3
         private final SWTBotShell        shell;
 30  
 
 31  
         /**
 32  
          * Creates a condition that evaluates to false until the shell is disposed or visible.
 33  
          * 
 34  
          * @param shell the shell to be monitored.
 35  
          */
 36  1
         ShellCloses(SWTBotShell shell) {
 37  1
                 Assert.isNotNull(shell, "The shell was null"); //$NON-NLS-1$
 38  1
                 this.shell = shell;
 39  1
         }
 40  
 
 41  
         public String getFailureMessage() {
 42  0
                 return "The shell " + shell + " did not close."; //$NON-NLS-1$ //$NON-NLS-2$
 43  
         }
 44  
 
 45  
         public boolean test() throws Exception {
 46  2
                 return UIThreadRunnable.syncExec(new BoolResult() {
 47  
                         public Boolean run() {
 48  2
                                 return shell.widget.isDisposed() || !shell.widget.isVisible();
 49  
                         }
 50  
                 });
 51  
         }
 52  
 
 53  
 }