Coverage Report - org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotLabel
66%
4/6
N/A
1
SWTBotLabel$1
100%
3/3
N/A
1
SWTBotLabel$2
100%
3/3
N/A
1
 
 1  2
 /*******************************************************************************
 2  
  * Copyright (c) 2008 Stephen Paulin 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  
  *     Stephen Paulin - initial API and implementation
 10  
  *******************************************************************************/
 11  
 package org.eclipse.swtbot.swt.finder.widgets;
 12  
 
 13  
 import org.eclipse.swt.graphics.Image;
 14  
 import org.eclipse.swt.widgets.Label;
 15  
 import org.eclipse.swtbot.swt.finder.ReferenceBy;
 16  
 import org.eclipse.swtbot.swt.finder.SWTBotWidget;
 17  
 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
 18  
 import org.eclipse.swtbot.swt.finder.results.IntResult;
 19  
 import org.eclipse.swtbot.swt.finder.results.Result;
 20  
 import org.hamcrest.SelfDescribing;
 21  
 
 22  
 /**
 23  
  * This represents a {@link Label} widget.
 24  
  * 
 25  
  * @author Stephen Paulin <paulin [at] developerskingdom [dot] com>
 26  
  * @version $Id$
 27  
  * @since 1.2
 28  
  */
 29  
 @SWTBotWidget(clasz = Label.class, preferredName = "label", referenceBy = { ReferenceBy.MNEMONIC })
 30  
 public class SWTBotLabel extends AbstractSWTBotControl<Label> {
 31  
 
 32  
         /**
 33  
          * Constructs an instance of this using the given finder and text to search for.
 34  
          * 
 35  
          * @param widget the widget
 36  
          * @throws WidgetNotFoundException if the widget is null or disposed.
 37  
          */
 38  
         public SWTBotLabel(Label widget) throws WidgetNotFoundException {
 39  0
                 this(widget, null);
 40  0
         }
 41  
 
 42  
         /**
 43  
          * Constructs an instance of this using the given finder and text to search for.
 44  
          * 
 45  
          * @param widget the widget
 46  
          * @param description the description of the widget, this will be reported by {@link #toString()}
 47  
          * @throws WidgetNotFoundException if the widget is null or disposed.
 48  
          */
 49  
         public SWTBotLabel(Label widget, SelfDescribing description) throws WidgetNotFoundException {
 50  5
                 super(widget, description);
 51  5
         }
 52  
 
 53  
         /**
 54  
          * Return the Label's image or <code>null</code>.
 55  
          * 
 56  
          * @return the image of the label or <code>null</code>.
 57  
          */
 58  
         public Image image() {
 59  1
                 return syncExec(new Result<Image>() {
 60  
                         public Image run() {
 61  1
                                 return widget.getImage();
 62  
                         }
 63  
                 });
 64  
         }
 65  
 
 66  
         /**
 67  
          * Returns the alignment. The alignment style (LEFT, CENTER or RIGHT) is returned.
 68  
          * 
 69  
          * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER
 70  
          */
 71  
         public int alignment() {
 72  3
                 return syncExec(new IntResult() {
 73  
                         public Integer run() {
 74  3
                                 return widget.getAlignment();
 75  
                         }
 76  
                 });
 77  
         }
 78  
 
 79  
 }