public void updateKeyCustomProperty(SWTBotGefEditPart part, String key, String newkey) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(key, "PROPERTY"); if (row == -1) return true; table.click(row, 0); bot.sleep(1000); bot.text(key, 0).setText(newkey); bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0); return false; } @Override public String getFailureMessage() { return "key not set"; } },2 * 60 * 1000); }
public void updateValueCustomProperty(SWTBotGefEditPart part, String key, String oldvalue, String newValue) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(oldvalue, "VALUE"); if (row == -1) return true; table.click(row, 1); bot.sleep(1000); bot.text(oldvalue, 0).setText(newValue); bot.text(KeyStroke.getInstance(SWT.TAB)+"" , 0); return false; } @Override public String getFailureMessage() { return "value not set"; } },2 * 60 * 1000); }
public void deleteCustomProperty(SWTBotGefEditPart part, String key) { GraphElement element = selectPart(part); selectTab(part, CUSTOM); SWTBotTable table = botView.bot().tableWithId(CustomProperties.PROJECT_PROPERTY_PAGE_WIDGET_ID, CustomProperties.CUSTOM_PROPERTY_LIST_WITH_BUTTON); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { int row = table.indexOf(key, "PROPERTY"); table.click(row, 0); table.contextMenu("Remove entry").click(); return table.indexOf(key, 0) == -1; } @Override public String getFailureMessage() { return "row not deleted"; } },2 * 60 * 1000); }
@Test public void testOfflineAppendMode() throws Exception { GW4EProject project = new GW4EProject(bot, gwproject); FileParameters fp = project.createSimpleProject (); fp.setTargetFilename("SimpleOffLineImpl"); OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); page.selectAppendMode("com.company.SimpleImpl.java - gwproject/src/main/java"); page.selectGenerators(new String [] {"random(edge_coverage(100))"}); page.finish(); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { IFile resource = (IFile) ResourceManager.getResource("gwproject/src/main/java/com/company/SimpleImpl.java"); boolean methodAppended = IOHelper.findInFile(resource, "Generated with : random(edge_coverage(100))"); return methodAppended; } @Override public String getFailureMessage() { return "method not generated "; } }; bot.waitUntil(condition, 3 * 6 * SWTBotPreferences.TIMEOUT); //3mn closeWizard (); }
@Test public void testOfflineStandAloneMode() throws Exception { GW4EProject project = new GW4EProject(bot, gwproject); FileParameters fp = project.createSimpleProject (); fp.setTargetFilename("SimpleOffLineImpl"); OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); page.selectStandAloneMode("MyClazz"); page.selectGenerators(new String [] {"random(edge_coverage(100))"}); page.finish(); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { IFile resource = (IFile) ResourceManager.getResource("gwproject/src/main/java/com/company/MyClazz.java"); boolean methodAppended = IOHelper.findInFile(resource, "Generated with : random(edge_coverage(100))"); return methodAppended; } @Override public String getFailureMessage() { return "method not generated "; } }; bot.waitUntil(condition, 3 * 6 * SWTBotPreferences.TIMEOUT); //3mn closeWizard (); }
private OfflineTestUIPageTest walkToToOfflinePage(String gwproject,FileParameters fp) throws CoreException, FileNotFoundException, BuildPolicyConfigurationException { String targetFormat="offline"; String checkTestBox="Java Offline Test Based"; GW4EProject project = new GW4EProject(bot, gwproject); ICondition convertPageReachedCondition = new DefaultCondition () { @Override public boolean test() throws Exception { boolean b = project.walkToToOfflinePage(fp.getProject(),fp.getPackageFragmentRoot(),fp.getPackage(), fp.getTargetFilename(), targetFormat,checkTestBox,fp.getGraphmlFilePath()); return b; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageReachedCondition, 3 * SWTBotPreferences.TIMEOUT); SWTBotShell shell = bot.shell("GW4E Conversion File"); return new OfflineTestUIPageTest(shell); }
public void createProjectWithoutError(String testResourceFolder, String pkgname, String graphMLFilename) throws CoreException, InterruptedException, IOException { createProject(); IFile file = createGraphMLFile(testResourceFolder, pkgname, graphMLFilename); IFile buildPolicyFile = BuildPolicyManager.createBuildPoliciesFile(file, new NullProgressMonitor ()); setPathGenerator(buildPolicyFile, file.getFullPath().lastSegment(), NoBuildRequiredException.NO_CHECK); DefaultCondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { ProblemView pv = ProblemView.open(GW4EProject.this.bot); cleanBuild(); boolean b = pv.getDisplayedErrorCount() == 0; return b; } @Override public String getFailureMessage() { return "Failed to create a project withour error"; } }; bot.waitUntil(condition, 3 * 60 * 1000); }
public void removeNature() { SWTBotTree tree = setupTreeForMenu(this.projectName); SWTBotMenu menu = new SWTBotMenu( ContextMenuHelper.contextMenu(tree, new String[] { "GW4E", "Remove GW4E Nature" })); menu.click(); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { boolean b = ClasspathManager .hasGW4EClassPathContainer(ResourceManager.getProject(projectName)); return !b; } @Override public String getFailureMessage() { return "GW4E ClassPath Container not removed"; } }); }
public void convertExistingProject() throws CoreException { SWTBotTree tree = getProjectTree(); SWTBotTreeItem item = tree.expandNode(this.projectName); item.setFocus(); item.select(); SWTBotMenu menu = item.contextMenu("Configure").contextMenu("Convert to GW4E"); menu.click(); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { boolean b = GW4ENature .hasGW4ENature(ResourceManager.getProject(projectName)); return b; } @Override public String getFailureMessage() { return "GraphWalker has not GraphWalker Nature "; } }); cleanBuild(); }
public void convertToExisting(String project, String packageRootFragment, String pkg, String targetFilename, String targetFormat, String checkTestBox, String... nodes) { ICondition condition = new DefaultCondition() { @Override public boolean test() throws Exception { ConvertDialog cd = prepareConvertTo(project, packageRootFragment, pkg, targetFilename, targetFormat, nodes); boolean b = cd.createExisting(project, packageRootFragment, pkg, targetFilename, targetFormat, checkTestBox); return b; } @Override public String getFailureMessage() { return "Unable to complete the convert to wizard"; } }; bot.waitUntil(condition, 3 * SWTBotPreferences.TIMEOUT); }
private void init() { ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { SWTBotMenu menu = bot.menu("Window"); menu = menu.menu("Show View"); menu = menu.menu("Console"); menu.click(); try { bot.waitUntil(new ViewOpened(ConsoleView.this.bot, "Console"), 3 * 1000); } catch (Exception e) { return false; } return true; } @Override public String getFailureMessage() { return "Cannot open Console view"; } }; bot.waitUntil(condition, TIMEOUT); botView = getBotView(); }
private SWTBotShell showPreferenceDialogWindowPreference() { ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { try { bot.menu("Window").menu("Preferences").click(); bot.waitUntil(new ShellActiveCondition("Preferences"), 5 * 1000); return true; } catch (Throwable e) { } return false; } @Override public String getFailureMessage() { return "Cannot open the Preference page"; } }; bot.waitUntil(condition, 30 * 1000); SWTBotShell shell = bot.shell("Preferences"); shell.activate(); return shell; }
private void setPathGenerator (String pathGenerator) { ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { try { SWTBotCombo combo = bot.comboBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID, GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_COMBO_PATH_GENERATOR); combo.setSelection(pathGenerator); } catch (Exception e) { return false; } return true; } @Override public String getFailureMessage() { return "Unable to set " + pathGenerator+ " in the combo"; } }; bot.waitUntil(condition); }
private void selectComboPathGenerator (SWTBotTableItem tableItem,String path) { DefaultCondition condition = new DefaultCondition() { @Override public boolean test() throws Exception { try { tableItem.click(1); SWTBotCCombo combo = bot.ccomboBoxWithId(ModelPathGenerator.GW4E_LAUNCH_CONFIGURATION_PATH_GENERATOR_ID,ModelPathGenerator.GW4E_LAUNCH_CONFIGURATION_PATH_GENERATOR_COMBO_EDITOR); combo.setSelection(path); return true; } catch (Exception e) { return false; } } @Override public String getFailureMessage() { return "Unable to open the path generator combo"; } }; bot.waitUntil(condition); }
private void selectComboPathGenerator (String path) { DefaultCondition condition = new DefaultCondition() { @Override public boolean test() throws Exception { try { SWTBotCombo combo = bot.comboBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_COMBO_PATH_GENERATOR_ID_MODEL); combo.setSelection(path); return true; } catch (Exception e) { e.printStackTrace(); return false; } } @Override public String getFailureMessage() { return "Unable to open the path generator combo"; } }; bot.waitUntil(condition); }
private void waitUntilResolvedProject(final MiniSelector selector) { bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { if (Display.getCurrent() != null) { // seems surprising that waitUtil() doesn't spin the event loop while (Display.getCurrent().readAndDispatch()); } return selector.getProject() != null; } @Override public String getFailureMessage() { return "MiniSelector project was never resolved"; } }); }
private static boolean waitUntilTreeHasItemImpl(SWTBot bot, final TreeItem tree, final String nodeText) { try { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find node with text " + nodeText; } @Override public boolean test() throws Exception { return getTreeItem(tree, nodeText) != null; } }); } catch (TimeoutException ex) { return false; } return true; }
private static boolean waitUntilTreeHasTextImpl(SWTBot bot, final TreeItem tree) { try { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Not all of the nodes in the tree have text."; } @Override public boolean test() throws Exception { return treeItemHasText(tree); } }); } catch (TimeoutException ex) { return false; } return true; }
/** * Wait until a tree item contains a child with the given text. * * @throws TimeoutException if the child does not appear within the default timeout */ public static void waitUntilTreeItemHasChild(SWTWorkbenchBot bot, final SWTBotTreeItem treeItem, final String childText) { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { System.err.println(treeItem + ": expanded? " + treeItem.isExpanded()); for (SWTBotTreeItem childNode : treeItem.getItems()) { System.err.println(" " + childNode); } return "Tree item never appeared"; } @Override public boolean test() throws Exception { return treeItem.getNodes().contains(childText); } }); }
/** * Wait until the tree item contains the given text with the timeout specified. */ public static void waitUntilTreeContainsText(SWTWorkbenchBot bot, final SWTBotTreeItem treeItem, final String text, long timeout) { bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { return treeItem.getText().contains(text); } @Override public String getFailureMessage() { return "Text never appeared"; } }, timeout); }
private void assertStagingLocationCombo(final String... buckets) { bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { spinEvents(); return new SWTBotCombo(stagingLocations).itemCount() == buckets.length; } @Override public String getFailureMessage() { return "missing staging buckets"; } }); Assert.assertArrayEquals(buckets, stagingLocations.getItems()); }
/** * Wait until the contents of the given {@link SWTBotView} are loaded. * * @param view * the view to be loaded */ public static void waitUntilViewIsLoaded(final SWTBotView view) { view.bot().waitUntil(new DefaultCondition() { @Override public boolean test() { SWTBotTreeItem[] allItems = view.bot().tree().getAllItems(); return allItems.length == 0 || !allItems[0].getText().equals(LOADING_VIEW_MESSAGE); } @Override public String getFailureMessage() { return "View must be loaded: " + view.getTitle(); } }, TIMEOUT_FOR_VIEW_TO_LOAD); }
/** * Waits until the node collapses. * * @param bot * bot to work with, must not be {@code null} * @param node * node to wait for, must not be {@code null} */ public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) { Assert.isNotNull(bot, ARGUMENT_BOT); Assert.isNotNull(node, ARGUMENT_NODE); if (node.isExpanded()) { node.collapse(); try { bot.waitUntil(new DefaultCondition() { @Override @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") public boolean test() { return !node.isExpanded(); } @Override public String getFailureMessage() { return "Timeout for node to collapse"; } }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND); } catch (TimeoutException e) { // Try one last time and do not wait anymore node.collapse(); } } }
private static boolean waitUntilTreeHasItemImpl(SWTBot bot, final TreeItem tree, final String nodeText) { try { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Could not find node with text " + nodeText; } @Override public boolean test() throws Exception { return getTreeItem(tree, nodeText) != null; } }); } catch (TimeoutException e) { return false; } return true; }
private static boolean waitUntilTreeHasTextImpl(SWTBot bot, final TreeItem tree) { try { bot.waitUntil(new DefaultCondition() { @Override public String getFailureMessage() { return "Not all of the nodes in the tree have text."; } @Override public boolean test() throws Exception { return doesTreeItemHaveText(tree); } }); } catch (TimeoutException e) { return false; } return true; }
private void addServer() { final int howManyServers = ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size(); UIThreadRunnable.asyncExec(new VoidResult() { public void run() { final UIAddServerController addServerController = new UIAddServerController( bot.getDisplay().getActiveShell()); addServerController.execute(); } }); bot.button("Finish").click(); bot.waitUntil(new DefaultCondition() { // BEGIN SUPRESS CATCH EXCEPTION public boolean test() throws Exception { return howManyServers + 1 == ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size(); } public String getFailureMessage() { return "Add server did not succeed."; } // END SUPRESS CATCH EXCEPTION }); assertEquals(howManyServers + 1, ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size()); }
@Test public void testOfflineExpandedMode() throws CoreException, BuildPolicyConfigurationException, IOException, InterruptedException { GW4EProject project = new GW4EProject(bot, gwproject); FileParameters fp = project.createSimpleProject (); fp.setTargetFilename("SimpleOffLineImpl"); OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); page.selectExtendedMode("com.company.SimpleImpl.java - gwproject/src/main/java","MyClazz"); page.selectGenerators(new String [] {"random(edge_coverage(100))"}); page.finish(); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { IFile resource = (IFile) ResourceManager.getResource("gwproject/src/main/java/com/company/MyClazz.java"); boolean methodAppended = IOHelper.findInFile(resource, "Generated with : random(edge_coverage(100))"); return methodAppended; } @Override public String getFailureMessage() { return "method not generated "; } }; bot.waitUntil(condition, 3 * 6 * SWTBotPreferences.TIMEOUT); //3mn closeWizard (); }
private void testConvertTo(String targetFormat,String checkTestBox) throws CoreException, FileNotFoundException, BuildPolicyConfigurationException { GW4EProject project = new GW4EProject(bot, gwproject); project.createInitialProjectWithoutError(TEST_RESOURCE_FOLDER, PACKAGE_NAME, graphMLFilename); FileParameters fp = FileParameters.create(targetFormat); IFolder folder = ResourceManager.createFolder(fp.getMainSourceFolder(), PACKAGE_NAME); ICondition folderExistsCondition = new FolderExists (folder); bot.waitUntil(folderExistsCondition, SWTBotPreferences.TIMEOUT); ICondition convertPageCompletedCondition = new DefaultCondition () { @Override public boolean test() throws Exception { boolean b = project.convertTo(fp.getProject(),fp.getPackageFragmentRoot(),fp.getPackage(), fp.getTargetFilename(), targetFormat,checkTestBox,fp.getGraphmlFilePath()); return b; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageCompletedCondition, 3 * SWTBotPreferences.TIMEOUT); IProject pj = ResourceManager.getProject(fp.getProject()); bot.waitUntil(new PathFoundCondition(pj,fp.getPath()),30 * 1000); }
@Test public void testGenerateApiBasedTest () throws CoreException, IOException, InterruptedException { GW4EProject project = new GW4EProject(bot, gwproject); FileParameters fp = project.createSimpleProject (); fp.setTargetFilename("SimpleStatic"); List<String> ids = buildIds ("Start","e_StartApp","v_VerifyAppRunning"); IPath p = new Path("/"+ gwproject+ "/src/main/resources/com/company/Simple.json"); IFile file = (IFile) ResourceManager.getResource(p.toString()); StaticGeneratorWizard.open(file, ids); StaticGeneratorWizard ges = new StaticGeneratorWizard(bot); ges.assertTargetElements("Start","e_StartApp","v_VerifyAppRunning"); ges.assertSourceElements("v_VerifyPreferencePage","e_ClosePreferencePage","e_OpenPreferencesPage"); ges.next(); ges.assertExtensionValue(0,"com.company.SimpleImpl.java - gwproject/src/main/java"); ges.next(); ges.enterDestination("SimpleStatic", "/gwproject/src/main/java/com/company/SimpleStatic.java", "src/main/java", "com", "company"); ges.finish(); DefaultCondition condition = new EditorOpenedCondition(bot,"SimpleStatic.java"); bot.waitUntil(condition,RUN_TIMEOUT); String[] nodes = new String[4]; nodes[0] = gwproject; nodes[1] = "src/main/java"; nodes[2] = "com.company"; nodes[3] = "SimpleStatic.java"; GW4ETestRunner gwtr = new GW4ETestRunner(bot); String[] expected = new String[] { "Executing:v_VerifyAppRunning" }; gwtr.runAsJavaApplication(expected,RUN_TIMEOUT,nodes); System.out.println("ended"); }
public void createProjectWithSimpleScriptedTemplate() throws CoreException { GW4EProject project = new GW4EProject(bot, gwproject); project.createtWithSimpleScriptedTemplate(gwproject); String mainSourceFolder = gwproject + "/src/main/java"; String pkgFragmentRoot = "src/main/java"; String pkg = "com.company"; String targetFilename = "SimplewithscriptImpl"; String targetFormat = "test"; String[] graphFilePath = new String[] { gwproject, "src/main/resources", pkg, "Simplewithscript.json" }; String checkTestBox = "Java Test Based"; String[] contexts = new String[0]; FileParameters fp = new FileParameters(mainSourceFolder, gwproject, pkgFragmentRoot, pkg, targetFilename, targetFormat, graphFilePath); ICondition convertPageCompletedCondition = new DefaultCondition() { @Override public boolean test() throws Exception { boolean b = project.prepareconvertTo(fp.getProject(), fp.getPackageFragmentRoot(), fp.getPackage(), fp.getTargetFilename(), targetFormat, checkTestBox, "e_init", "v_Browse", "e_init", contexts, fp.getGraphmlFilePath()); return b; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageCompletedCondition, 3 * 60 * 1000); }
@Test public void testCreateProjectWithSharedTemplate() throws CoreException { GW4EProject project = new GW4EProject(bot, gwproject); project.createWithSharedTemplate(gwproject); String mainSourceFolder = gwproject + "/src/main/java"; String pkgFragmentRoot = "src/main/java"; String pkg = "com.company"; String targetFilename = "Model_AImpl"; String targetFormat = "test"; String[] graphFilePath = new String[] { gwproject, "src/main/resources", pkg, "Model_A.json" }; String checkTestBox = "Java Test Based"; String[] contexts = new String[] { "/gwproject/src/main/resources/com/company/Model_B.json" }; FileParameters fp = new FileParameters(mainSourceFolder, gwproject, pkgFragmentRoot, pkg, targetFilename, targetFormat, graphFilePath); ICondition convertPageCompletedCondition = new DefaultCondition() { @Override public boolean test() throws Exception { boolean b = project.prepareconvertTo(fp.getProject(), fp.getPackageFragmentRoot(), fp.getPackage(), fp.getTargetFilename(), targetFormat, checkTestBox, "e_to_V_A", "v_B", "e_to_V_A", contexts, fp.getGraphmlFilePath()); return b; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageCompletedCondition, 3 * 60 * 1000); }
public FileParameters generateForSimpleProject () throws CoreException { GW4EProject project = new GW4EProject(bot, getProjectName()); String mainSourceFolder = getProjectName() + "/src/main/java"; String pkgFragmentRoot = "src/main/java"; String pkg = "com.company"; String targetFilename = "SimpleImpl"; String targetFormat = "test"; String[] graphFilePath = new String [] { getProjectName(), "src/main/resources", pkg, "Simple.json" }; String checkTestBox = "Java Test Based"; String [] contexts = new String [0]; FileParameters fp = new FileParameters(mainSourceFolder, getProjectName(), pkgFragmentRoot, pkg, targetFilename, targetFormat, graphFilePath); ICondition convertPageCompletedCondition = new DefaultCondition () { @Override public boolean test() throws Exception { boolean b = project.prepareconvertTo( fp.getProject(), fp.getPackageFragmentRoot(), fp.getPackage(), fp.getTargetFilename(), targetFormat, checkTestBox, "e_StartApp","v_VerifyPreferencePage", "e_StartApp",contexts, fp.getGraphmlFilePath()); return b; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageCompletedCondition, 3 * 60 * 1000); return fp; }
public void resetToJavPerspective() { final SWTBotPerspective javaPerspective = bot.perspectiveById(JavaUI.ID_PERSPECTIVE); javaPerspective.activate(); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { return javaPerspective.isActive(); } @Override public String getFailureMessage() { return JavaUI.ID_PERSPECTIVE + " has not become active in time"; } }); }
public boolean walkToToOfflinePage(String project, String packageRootFragment, String pkg, String targetFilename, String targetFormat, String checkTestBox, String... nodes) { ConvertDialog cd = prepareConvertTo(project, packageRootFragment, pkg, targetFilename, targetFormat, nodes); ICondition convertPageCompletedCondition = new DefaultCondition () { @Override public boolean test() throws Exception { boolean ret = cd.create(project, packageRootFragment, pkg, targetFilename, targetFormat, checkTestBox,false); if (!ret) { SWTBotShell shell = bot.shell("GW4E Conversion File"); shell.bot().button("Cancel").click(); bot.waitUntil(Conditions.shellCloses(shell)); return false; } return true; } @Override public String getFailureMessage() { return "Unable to complete the wizard page."; } }; bot.waitUntil(convertPageCompletedCondition); bot.button("Next >").click(); return true; }
public static void importProjectFromZip(SWTWorkbenchBot bot, String path) { int timeout = 10000; bot.menu("File").menu("Import...").click(); bot.waitUntil(Conditions.shellIsActive("Import")); SWTBotShell shell = bot.shell("Import").activate(); shell.bot().tree().expandNode("General").select("Existing Projects into Workspace"); shell.bot().button("Next >").click(); shell.bot().radio("Select archive file:").click(); shell.bot().comboBox(1).setText(path); shell.bot().comboBox(1).pressShortcut(SWT.CR, SWT.LF); SWTBotButton finishButton = shell.bot().button("Finish"); ICondition buttonEnabled = new DefaultCondition() { @Override public boolean test() throws Exception { return finishButton.isEnabled(); } @Override public String getFailureMessage() { return "Finish button not enabled"; } }; shell.bot().waitUntil(buttonEnabled, timeout); finishButton.click(); bot.waitUntil(Conditions.shellCloses(shell), timeout); }
public GW4EProjectProperties openPropertiesPage ( ) { SWTBotTree tree = getProjectTree(); SWTBotTreeItem item = tree.expandNode(this.projectName); item.setFocus(); item.select(); ICondition condition = new DefaultCondition () { @Override public boolean test() throws Exception { SWTBotTreeItem treeItem = tree.getTreeItem(projectName); return treeItem.isSelected(); } @Override public String getFailureMessage() { return "Project " + projectName + " not selected "; } }; bot.waitUntil(condition); bot.menu( "File").menu("Properties").click(); bot.waitUntil(Conditions.shellIsActive("Properties for " + projectName)); SWTBotShell shell = bot.shell("Properties for " + projectName).activate(); shell.bot().tree().select("GW4E"); bot.waitUntil(Conditions.waitForWidget(WidgetMatcherFactory.withId( ProjectPropertyPage.PROJECT_PROPERTY_PAGE_WIDGET_ID, ProjectPropertyPage.PROJECT_PROPERTY_PAGE_WIDGET_SECURITY_LEVEL_FOR_ABSTRACT_CONTEXT))); return new GW4EProjectProperties(bot,shell); }
private ICondition waitForTable() { return new DefaultCondition() { public boolean test() throws Exception { SWTBotTable table = getTable(); return table != null; } public String getFailureMessage() { return "Table : Authorized Folder For Graph Definition has not been found"; } }; }
private void waitForRowAdded(final SWTBotTable table, final int expectedCount) { ICondition condition = new DefaultCondition() { public boolean test() throws Exception { return table.rowCount() == expectedCount; } public String getFailureMessage() { return "Table " + id + " has not " + expectedCount + " row(s). It has " + expectedCount + " row(s)"; } }; bot.waitUntil(condition); }
private void waitForExpectedValueAtRowCol(final SWTBotTable table, final String expectedValue) { ICondition condition = new DefaultCondition() { public boolean test() throws Exception { return table.containsItem(expectedValue); } public String getFailureMessage() { return "Table '"+ id + " does not contains " + expectedValue; } }; bot.waitUntil(condition); }