To show other views, the same mechanism is followed in the UI tests, as a user would do; by going to Window | Show View | Other.
Create a new method,
testTimeZoneView()
, with a@Test
annotation.From the bot, open the Other dialog by going to Window | Show View.
Get the shell with the title Show View and activate it.
Expand the Timekeeping node and select the Time Zone View node (the view created in Chapter 2, Creating Views with SWT).
Click on the OK button to have the view shown.
Use the
bot.viewByTitle()
method to acquire a reference to the view.Assert that the view is not
null
.The code looks like this:
@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); }
Run the...