Java Code Examples for org.eclipse.swtbot.swt.finder.SWTBot#widget()

The following examples show how to use org.eclipse.swtbot.swt.finder.SWTBot#widget() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoMapTest.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	SWTBotPreferences.PLAYBACK_DELAY = 1000; // slow down tests...Otherwise we won't see anything
	display = Display.getCurrent();
	parent = createUI(display);

	bot = new SWTBot(parent);
	geoMapPositioned = geoMap = bot.widget(Is.isA(GeoMap.class));
	geoMapBot = new SWTBotGeoMap(geoMap);
}
 
Example 2
Source File: GeoMapViewerTest.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	SWTBotPreferences.PLAYBACK_DELAY = 1000; // slow down tests...Otherwise we won't see anything
	display = Display.getCurrent();
	parent = createUI(display);

	bot = new SWTBot(parent);
	GeoMap geoMap = bot.widget(Is.isA(GeoMap.class));
	geoMapBot = new SWTBotGeoMap(geoMap);
}
 
Example 3
Source File: TableComboTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the items in the {@link TableCombo} are correctly displayed in
 * the table widget.
 */
@Test
public void testDisplayOfItems() {

	/*
	 * GIVEN a TableCombo with one column and a number of TableItems assigned to the
	 * TableCombo.
	 */
	createTableCombo(shell, 1, 5);

	/*
	 * WHEN the TableCombo gets displayed
	 */
	shell.open();

	/*
	 * THEN the number of rows displayed in the table widget of the TableCombo must
	 * match the number of TableItems.
	 */
	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	final SWTBotTable tableBot = new SWTBotTable(tableComboWidget.getTable());

	assertEquals(
			"Expected the number of items in the table widget of the TableCombo to be the same as the number of TableItems added to the TableCombo",
			5, tableBot.rowCount());

}
 
Example 4
Source File: TableComboTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the columns defined for a {@link TableCombo} are correctly
 * displayed in the table widget.
 */
@Test
public void testDisplayOfColumns() {

	/*
	 * GIVEN a TableCombo with a number of columns and a number of TableItems
	 * assigned to the TableCombo.
	 */
	createTableCombo(shell, 3, 5);

	/*
	 * WHEN the TableCombo gets displayed
	 */
	shell.open();

	/*
	 * THEN the number of columns displayed in the table widget of the TableCombo
	 * must match the configured number
	 */
	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	final SWTBotTable tableBot = new SWTBotTable(tableComboWidget.getTable());

	assertEquals(
			"Expected the number of columns in the table widget of the TableCombo to be the same as the number of columns configured in the TableCombo",
			3, tableBot.columnCount());

}
 
Example 5
Source File: TableComboTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the text displayed in tableCombo text widget corresponds to the
 * item selected in the tableCombo.
 */
@Test
public void testSelectionOfSingleItem() {

	/*
	 * GIVEN a TableCombo with one column and a number of TableItems assigned to the
	 * TableCombo.
	 */
	createTableCombo(shell, 1, 5);

	/*
	 * WHEN the TableCombo gets displayed and a single item is selected in the table
	 * combo
	 */
	shell.open();

	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	tableComboWidget.select(0);

	/*
	 * THEN the text displayed in tableCombo text widget must correspond to the item
	 * selected in the tableCombo.
	 */
	assertEquals(
			"Expected the text displayed in the tableCombo text widget to correspond to the item selected in the tableCombo",
			"Item 0", tableComboWidget.getText());

}
 
Example 6
Source File: TableComboViewerTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the items set as input to the {@link TableComboViewer} are
 * correctly displayed in the table widget.
 */
@Test
public void testDisplayOfItems() {

	/*
	 * GIVEN a TableComboViewer with two columns and a number of items set as input
	 * of the TableComboViewer.
	 */
	createTableComboViewer(shell, 5);

	/*
	 * WHEN the TableComboViewer gets displayed
	 */
	shell.open();

	/*
	 * THEN the number of rows displayed in the table widget of the TableComboViewer
	 * must match the number of items.
	 */
	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	final SWTBotTable tableBot = new SWTBotTable(tableComboWidget.getTable());

	assertEquals(
			"Expected the number of items in the table widget of the TableCombo to be the same as the number of items added to the TableComboViewer",
			5, tableBot.rowCount());

}
 
Example 7
Source File: TableComboViewerTests.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensures that the properties of the items for the {@link TableComboViewer} are
 * correctly displayed in the cells of the table widget.
 */
@Test
public void testDisplayOfCellValues() {

	/*
	 * GIVEN a TableComboViewer with two columns and a number of items set as input
	 * of the TableComboViewer.
	 */
	createTableComboViewer(shell, 5);

	/*
	 * WHEN the TableComboViewer gets displayed
	 */
	shell.open();

	/*
	 * THEN the number of columns displayed in the table widget of the
	 * TableComboViewer must match the number of columns defined for the
	 * TableComboViewer and the cell values must reflect the according property
	 * values of the item in the row at hand.
	 */
	final SWTBot shellBot = new SWTBot(shell);
	final TableCombo tableComboWidget = shellBot.widget(WidgetMatcherFactory.widgetOfType(TableCombo.class));
	final SWTBotTable tableBot = new SWTBotTable(tableComboWidget.getTable());

	assertEquals(
			"Expected the number of columns in the table widget of the TableComboViewer to be the one as defined for the TableComboViewer",
			2, tableBot.columnCount());
	assertEquals(
			"Expected the value in the cell [0,1] in the table widget of the TableComboViewer to correspond to the description of first item set as input for the TableComboViewer",
			"Description 0", tableBot.cell(0, 1));
	assertEquals(
			"Expected the value in the cell [1,0] in the table widget of the TableComboViewer to correspond to the name of second item set as input for the TableComboViewer",
			"Item 1", tableBot.cell(1, 0));

}
 
Example 8
Source File: SWTBotEclipseSwtChart.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Constructor
 *
 * @param bot
 *            a SWTBot instance with which to find a SwtChart
 * @throws WidgetNotFoundException
 *             if the widget is <code>null</code> or widget has been
 *             disposed.
 */
public SWTBotEclipseSwtChart(SWTBot bot) throws WidgetNotFoundException {
    super(bot.widget(WidgetOfType.widgetOfType(Chart.class)));
}
 
Example 9
Source File: SWTBotTimeGraph.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Constructor
 *
 * @param bot
 *            a SWTBot instance with which to find a time graph
 * @throws WidgetNotFoundException
 *             if the widget is <code>null</code> or widget has been
 *             disposed.
 */
public SWTBotTimeGraph(SWTBot bot) throws WidgetNotFoundException {
    super(bot.widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
}
 
Example 10
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the first push button that has any one of the specified mnemonic texts.
 * Useful when buttons change mnemonic text between releases.
 *
 * @param bot
 *            a given bot
 * @param texts
 *            the possible button mnemonic texts
 * @return a SWTBotButton
 * @throws WidgetNotFoundException
 *             if the widget is not found or is disposed.
 */
public static SWTBotButton anyButtonOf(SWTBot bot, String... texts) {
    Matcher<Widget> anyOf = anyOf(Lists.transform(Arrays.asList(texts), text -> withMnemonic(text)));
    Iterable<Matcher<? extends Widget>> matchers = Arrays.asList(widgetOfType(Button.class), anyOf, withStyle(SWT.PUSH, "SWT.PUSH"));
    return new SWTBotButton((Button) bot.widget(allOf(matchers), 0), allOf(matchers));
}
 
Example 11
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the first shell that has any one of the specified texts. Useful when
 * shells change text between releases, or when one of many shells could appear.
 *
 * @param bot
 *            a given bot
 * @param texts
 *            the possible shell texts
 * @return a SWTBotShell
 * @throws WidgetNotFoundException
 *             if the widget is not found or is disposed.
 */
public static SWTBotShell anyShellOf(SWTBot bot, String... texts) {
    Matcher<Widget> anyOf = anyOf(Lists.transform(Arrays.asList(texts), text -> withText(text)));
    Iterable<Matcher<? extends Widget>> matchers = Arrays.asList(widgetOfType(Shell.class), anyOf);
    return new SWTBotShell((Shell) bot.widget(allOf(matchers), 0), allOf(matchers));
}
 
Example 12
Source File: SWTBotSwtChart.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Constructor
 *
 * @param bot
 *            a SWTBot instance with which to find a SwtChart
 * @throws WidgetNotFoundException
 *             if the widget is <code>null</code> or widget has been
 *             disposed.
 */
public SWTBotSwtChart(SWTBot bot) throws WidgetNotFoundException {
    super(bot.widget(WidgetOfType.widgetOfType(Chart.class)));
}