To show other views, the same mechanism is done in the UI tests as a user would do, by navigating the Window | Show View | Other… menu.
testTimeZoneView
, with an @Test
annotation.Show View
and activate it.Timekeeping
node and select the Time Zone View
node (the view created in Chapter 2, Creating Views with SWT).bot.viewByTitle()
method to acquire a reference to the view.null
.@Test public void testTimeZoneView() { bot.menu("Window").menu("Show View").menu("Other...").click(); SWTBotShell shell = bot.shell("Show View"); shell.activate(); bot.tree().expandNode("Timekeeping").select("Time Zone View"); bot.button("OK").click(); SWTBotView timeZoneView = bot.viewByTitle("Time Zone View"); assertNotNull(timeZoneView); }
Using the built-in Eclipse mechanism to switch views, the bot navigated the Window | Show View | Other… | Timekeeping | Time Zone View menu hierarchy to bring the view to the screen.
Once shown, the viewByTitle
method of the bot
can be used to get a reference to the widget, and verify that it is not null
.
Being able to select a view programmatically is such a common occurrence that it can help to have a utility method be able to open a view on demand.
18.225.98.111