Coverage Report - org.eclipse.swtbot.swt.finder.widgets.SWTBotArrowButton
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotArrowButton
86%
19/22
N/A
1
 
 1  0
 /*******************************************************************************
 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.widgets;
 12  
 
 13  
 import org.eclipse.swt.SWT;
 14  
 import org.eclipse.swt.widgets.Button;
 15  
 import org.eclipse.swtbot.swt.finder.ReferenceBy;
 16  
 import org.eclipse.swtbot.swt.finder.SWTBotWidget;
 17  
 import org.eclipse.swtbot.swt.finder.Style;
 18  
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 19  
 import org.eclipse.swtbot.swt.finder.utils.MessageFormat;
 20  
 import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
 21  
 import org.eclipse.swtbot.swt.finder.utils.internal.Assert;
 22  
 import org.hamcrest.SelfDescribing;
 23  
 
 24  
 /**
 25  
  * This represents a {@link Button} widget of type {@link SWT#ARROW}.
 26  
  *
 27  
  * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
 28  
  * @version $Id$
 29  
  * @see SWTBotCheckBox
 30  
  * @see SWTBotRadio
 31  
  * @see SWTBotToggleButton
 32  
  */
 33  
 @SWTBotWidget(clasz = Button.class, style = @Style(name = "SWT.ARROW", value = SWT.ARROW), preferredName = "arrowButton", referenceBy = { ReferenceBy.LABEL, ReferenceBy.TOOLTIP })  //$NON-NLS-1$
 34  
 public class SWTBotArrowButton extends AbstractSWTBotControl<Button> {
 35  
 
 36  
         /**
 37  
          * Constructs an instance of this object with the given button
 38  
          *
 39  
          * @param button the widget.
 40  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 41  
          * @since 2.0
 42  
          */
 43  
         public SWTBotArrowButton(Button button) {
 44  0
                 this(button, null);
 45  0
         }
 46  
 
 47  
         /**
 48  
          * Constructs an instance of this object with the given button
 49  
          *
 50  
          * @param button the widget.
 51  
          * @param description the description of the widget, this will be reported by {@link #toString()}
 52  
          * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 53  
          * @since 2.0
 54  
          */
 55  
         public SWTBotArrowButton(Button button, SelfDescribing description) {
 56  3
                 super(button, description);
 57  3
                 Assert.isTrue(SWTUtils.hasStyle(button, SWT.ARROW), "Expecting an arrow button."); //$NON-NLS-1$
 58  3
         }
 59  
 
 60  
         /**
 61  
          * Click on the button.
 62  
          */
 63  
         public SWTBotArrowButton click() {
 64  1
                 log.debug(MessageFormat.format("Clicking on {0}", SWTUtils.getText(widget))); //$NON-NLS-1$
 65  1
                 waitForEnabled();
 66  1
                 notify(SWT.MouseEnter);
 67  1
                 notify(SWT.MouseMove);
 68  1
                 notify(SWT.Activate);
 69  1
                 notify(SWT.FocusIn);
 70  1
                 notify(SWT.MouseDown);
 71  1
                 notify(SWT.MouseUp);
 72  1
                 notify(SWT.Selection);
 73  1
                 notify(SWT.MouseHover);
 74  1
                 notify(SWT.MouseMove);
 75  1
                 notify(SWT.MouseExit);
 76  1
                 notify(SWT.Deactivate);
 77  1
                 notify(SWT.FocusOut);
 78  1
                 log.debug(MessageFormat.format("Clicked on {0}", SWTUtils.getText(widget))); //$NON-NLS-1$
 79  1
                 return this;
 80  
         }
 81  
 
 82  
 }