Coverage Report - org.eclipse.swtbot.swt.finder.waits.ShellIsActive
 
Classes in this File Line Coverage Branch Coverage Complexity
ShellIsActive
70%
7/10
50%
1/2
1.75
ShellIsActive$1
100%
3/3
25%
1/4
1.75
 
 1  2
 /*******************************************************************************
 2  
  * Copyright (c) 2008 http://www.inria.fr/ 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  
  *     http://www.inria.fr/ - initial API and implementation
 10  
  *******************************************************************************/
 11  
 
 12  
 package org.eclipse.swtbot.swt.finder.waits;
 13  
 
 14  
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 15  
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
 16  
 import org.eclipse.swtbot.swt.finder.results.BoolResult;
 17  
 import org.eclipse.swtbot.swt.finder.utils.StringUtils;
 18  
 import org.eclipse.swtbot.swt.finder.utils.internal.Assert;
 19  
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 20  
 
 21  
 /**
 22  
  * A condition that waits until the specified shell is the active shell.
 23  
  *
 24  
  * @see Conditions
 25  
  * @since 1.3
 26  
  * @author Vincent MAHE <vmahe [at] free[dot]fr>
 27  
  * @version $Id$
 28  
  */
 29  
 class ShellIsActive extends DefaultCondition {
 30  
 
 31  
         private String        text;
 32  
 
 33  1
         ShellIsActive(String text) {
 34  1
                 Assert.isNotNull(text, "The shell text was null"); //$NON-NLS-1$
 35  1
                 Assert.isLegal(!StringUtils.isEmpty(text), "The shell text was empty"); //$NON-NLS-1$
 36  1
                 this.text = text;
 37  1
         }
 38  
 
 39  
         public String getFailureMessage() {
 40  0
                 return "The shell '" + text + "' did not activate"; //$NON-NLS-1$ //$NON-NLS-2$
 41  
         }
 42  
 
 43  
         public boolean test() throws Exception {
 44  
                 try {
 45  1
                         final SWTBotShell shell = bot.shell(text);
 46  1
                         return UIThreadRunnable.syncExec(new BoolResult() {
 47  
                                 public Boolean run() {
 48  1
                                         return shell.widget.isVisible() || shell.widget.isFocusControl();
 49  
                                 }
 50  
                         });
 51  0
                 } catch (WidgetNotFoundException e) {
 52  
                 }
 53  0
                 return false;
 54  
         }
 55  
 
 56  
 }