Coverage Report - org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotToolbarButton
83%
15/18
N/A
1
SWTBotToolbarButton$1
100%
3/3
N/A
1
 
 1  0
 /*******************************************************************************
 2  
  * Copyright (c) 2008, 2009 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.widgets;
 12  
 
 13  
 import org.eclipse.swt.SWT;
 14  
 import org.eclipse.swt.widgets.ToolItem;
 15  
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 16  
 import org.eclipse.swtbot.swt.finder.results.BoolResult;
 17  
 import org.hamcrest.SelfDescribing;
 18  
 
 19  
 /**
 20  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 21  
  * @version $Id$
 22  
  */
 23  
 public abstract class SWTBotToolbarButton extends AbstractSWTBot<ToolItem> {
 24  
 
 25  
         /**
 26  
          * Constructs an new instance of this item.
 27  
          *
 28  
          * @param w the tool item.
 29  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 30  
          */
 31  
         public SWTBotToolbarButton(ToolItem w) throws WidgetNotFoundException {
 32  0
                 this(w, null);
 33  0
         }
 34  
 
 35  
         /**
 36  
          * Constructs an new instance of this item.
 37  
          *
 38  
          * @param w the tool item.
 39  
          * @param description the description of the widget, this will be reported by {@link #toString()}
 40  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 41  
          */
 42  
         public SWTBotToolbarButton(ToolItem w, SelfDescribing description) throws WidgetNotFoundException {
 43  42
                 super(w, description);
 44  42
         }
 45  
 
 46  
         /**
 47  
          * Click on the tool item.
 48  
          *
 49  
          * @since 1.0
 50  
          */
 51  
         public abstract SWTBotToolbarButton click();
 52  
 
 53  
         protected void sendNotifications() {
 54  15
                 notify(SWT.MouseEnter);
 55  15
                 notify(SWT.MouseMove);
 56  15
                 notify(SWT.Activate);
 57  15
                 notify(SWT.MouseDown);
 58  15
                 notify(SWT.MouseUp);
 59  15
                 notify(SWT.Selection);
 60  15
                 notify(SWT.MouseHover);
 61  15
                 notify(SWT.MouseMove);
 62  15
                 notify(SWT.MouseExit);
 63  15
                 notify(SWT.Deactivate);
 64  15
                 notify(SWT.FocusOut);
 65  15
         }
 66  
         
 67  
         @Override
 68  
         public boolean isEnabled() {
 69  17
                 return syncExec(new BoolResult() {
 70  
                         public Boolean run() {
 71  17
                                 return widget.isEnabled();
 72  
                         }
 73  
                 });
 74  
         }
 75  
 }