Java 类org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 实例源码

项目:gw4e.project    文件:GW4EProjectTestCase.java   
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);

}
项目:gw4e.project    文件:GW4EProject.java   
private ConvertDialog prepareConvertTo(String project, String packageRootFragment, String pkg,
        String targetFilename, String targetFormat, String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Convert to...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("GW4E Conversion File"));
    SWTBotShell shell = bot.shell("GW4E Conversion File");

    ConvertDialog cd = new ConvertDialog(shell);
    return cd;
}
项目:gw4e.project    文件:GW4EPerspective.java   
public static void openNewGraphWalkerModel(SWTWorkbenchBot bot) {

    SWTBotMenu all = bot.menu("File").menu("New");

    /*
    Function<String, String>   f =  new Function<String, String> () {

        @Override
        public String apply(String t) {
            return t;
        }

    };
    all.menuItems().stream().map(f);
    */

    bot.menu("File").menu("New").menu("GW4E Model").click();
    bot.waitUntil(new ShellActiveCondition("GW4E"));
    SWTBotShell shell = bot.shell("GW4E");
    assertTrue(shell.isOpen());
    shell.bot().button("Cancel").click();
    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
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;   
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private SWTBotShell showPreferenceDialogMAC() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window != null) {
                Menu appMenu = workbench.getDisplay().getSystemMenu();
                for (MenuItem item : appMenu.getItems()) {
                    if (item.getText().startsWith("Preferences")) {
                        Event event = new Event();
                        event.time = (int) System.currentTimeMillis();
                        event.widget = item;
                        event.display = workbench.getDisplay();
                        item.setSelection(true);
                        item.notifyListeners(SWT.Selection, event);
                        break;
                    }
                }
            }
        }
    });
    return  getPreferenceDialog() ;
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
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;   
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private SWTBotShell showPreferenceDialogMAC() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window != null) {
                Menu appMenu = workbench.getDisplay().getSystemMenu();
                for (MenuItem item : appMenu.getItems()) {
                    if (item.getText().startsWith("Preferences")) {
                        Event event = new Event();
                        event.time = (int) System.currentTimeMillis();
                        event.widget = item;
                        event.display = workbench.getDisplay();
                        item.setSelection(true);
                        item.notifyListeners(SWT.Selection, event);
                        break;
                    }
                }
            }
        }
    });
    return  getPreferenceDialog() ;
}
项目:gw4e.project    文件:GW4EOfflineRunner.java   
public void validateRun (String configurationName,String projectName,String filepath,boolean printUnvisited,boolean verbose,String startElement,String generator) {
    SWTBotShell shell = openExistingRun (configurationName);

    SWTBotText projectText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_PROJECT);
    assertEquals("Wrong project name",projectName,projectText.getText());

    SWTBotText modelText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_MODEL);
    assertEquals("Wrong model name",filepath,modelText.getText());

    SWTBotCheckBox verboseButton  = shell.bot().checkBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_VERBOSE);
    assertEquals("Wrong verbose value",verbose,verboseButton.isChecked());

    SWTBotCheckBox unvisitedButton  = shell.bot().checkBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_PRINT_UNVISITED);
    assertEquals("Wrong verbose value",verbose,unvisitedButton.isChecked());

    SWTBotText startElementText = shell.bot().textWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_TEXT_ID_START_ELEMENT);
    assertEquals("Wrong start element",startElement,startElementText.getText());

    SWTBotCombo generatorCombo = shell.bot().comboBoxWithId(GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_COMBO_PATH_GENERATOR_ID_MODEL);
    assertEquals("Wrong generator value",generator,generatorCombo.getText());

    SWTBotButton closeButton = bot.button("Close");
    closeButton.click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:google-cloud-eclipse    文件:SwtBotAppEngineActions.java   
private static void openImportProjectsWizard(SWTWorkbenchBot bot,
    String wizardCategory, String importWizardName) {
  for (int tries = 1; true; tries++) {
    SWTBotShell shell = null;
    try {
      bot.menu("File").menu("Import...").click();
      shell = bot.shell("Import");
      shell.activate();

      SwtBotTreeUtilities.waitUntilTreeHasItems(bot, bot.tree());
      SWTBotTreeItem treeItem = bot.tree().expandNode(wizardCategory);
      SwtBotTreeUtilities.waitUntilTreeItemHasChild(bot, treeItem, importWizardName);
      treeItem.select(importWizardName);
      break;
    } catch (TimeoutException e) {
      if (tries == 2) {
        throw e;
      } else if (shell != null) {
        shell.close();
      }
    }
  }
}
项目:gwt-eclipse-plugin    文件:SwtBotMenuActions.java   
public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) {
  SwtBotUtils.print("Opening Perspective: " + perspectiveLabel);

  SWTBotShell shell = null;
  try {
    menu(bot, "Window").menu("Open Perspective").menu("Other...").click();

    shell = bot.shell("Open Perspective");

    bot.waitUntil(ActiveWidgetCondition.widgetMakeActive(shell));
    shell.bot().table().select(perspectiveLabel);

    shell.bot().button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
  } catch (Exception e) {
    if (shell != null && shell.isOpen()) shell.close();
    SwtBotUtils.printError("Couldn't open perspective '" + perspectiveLabel + "'\n"
        + "trying to activate already open perspective instead");
    // maybe somehow the perspective is already opened (by another test before us)
    SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel);
    perspective.activate();
  }

  SwtBotUtils.print("Opened Perspective: " + perspectiveLabel);
}
项目:translationstudio8    文件:CreateProjectDemo.java   
@Test
public void createProject() throws Exception {
    String projectName = "prjBot-001";

    bot.menu("File").menu("New").click();
    SWTBotShell shell = bot.shell("New");
    shell.activate();
    // From menu open File > New dialog, verify whether the dialog has been opened.

    bot.tree().select("Project");
    SWTBotAssert.assertEnabled(bot.button("Next >"));
    // After selecting Project, the Next button should be enabled.

    bot.button("Next >").click();
    bot.textWithLabel("Project name:").setText(projectName);
    SWTBotAssert.assertEnabled(bot.button("Finish"));
    // Enter the Project Name, then Finish button should be enabled.

    bot.button("Finish").click();
    SWTBotAssert.assertVisible(bot.tree().select(projectName));
    // Click Finish button and verify whether the project's been successfully created.
}
项目:DevStudioUITestAutomation    文件:EndPointCreation.java   
/**
 * @param bot
 */
public static void handleCreationWizard(SWTWorkbenchBot bot) {

    bot.activeShell().bot().button(Properties.BUTTON_NEXT).click();

    bot.textWithLabel(TEXT_WITH_LABEL_ENDPOINT_NAME).setText(ENDPOINT_NAME);
    bot.activeShell().bot().link()
            .click(IMAGE_HYPER_LINK_CREATE_NEW_PROJECT);

    SWTBotShell shell = bot.shell(Properties.SHELL_EMPTY_STRING);
    shell.activate();
    bot.button(Properties.BUTTON_NEXT).click();
    bot.textWithLabel(Properties.TEXT_WITH_LABEL_PROJECT_NAME).setText(
            PropertiesESB.ARTIFACT_MY_ESB_CONFIG_PROJECT_FOR_ENDPOINT_TEST);
    bot.button(Properties.BUTTON_FINISH).click();
    bot.textWithLabel(Properties.TEXT_WITH_LABEL_Address).setText(
            PropertiesESB.ARTIFACT_ENDPOINT_URL);
    bot.button(Properties.BUTTON_FINISH).click();

}
项目:DevStudioUITestAutomation    文件:EndPointTestCase.java   
@Test
public void testESBConfigProjectCreation() throws Exception {

    assertTrue(Properties.ERROR_OPEN_DASHBOARD,
            DashBoardCreation.openDashBoard(bot));

    @SuppressWarnings({ "rawtypes", "unchecked" })
    Matcher matcherImageHyperLink = allOf(
            widgetOfType(ImageHyperlink.class),
            withText(EndPointCreation.IMAGE_HYPER_LINK));

    assertTrue(Properties.ERROR_OPEN_CREATION_WIZARD,
            DashBoardCreation.openWizard(matcherImageHyperLink, bot));

    SWTBotShell shell = bot
            .shell(EndPointCreation.SHELL_CREATE_NEW_ENDPOINT);
    shell.activate();

    EndPointCreation.handleCreationWizard(bot);

    assertTrue(EndPointCreation.checkCreatedProject(bot));

}
项目:syncope    文件:SyncopeViewTest.java   
@Test
public void canLoginAdmin() throws Exception {
    SWTBotShell loginShell = BOT.activeShell();
    loginShell.activate();
    BOT.textWithLabel("Deployment Url").setText(ADDRESS);
    BOT.textWithLabel("Username").setText(ADMIN_UNAME);
    BOT.textWithLabel("Password").setText(ADMIN_PWD);
    BOT.button("Login").click();
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
}
项目:FRaMED    文件:FramedComponentsAbstractTests.java   
protected SWTBotShell createNewOrmModelFileWizard(String category, String parentProjectName,
    String fileType, String fileName) {
  bot.menu("File").menu("New").menu("Other...").click();

  SWTBotShell shell = bot.shell("New");
  shell.activate();

  bot.text().setText(fileType);
  bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), category, fileType));

  bot.tree().expandNode(category).select(fileType);
  bot.button("Next >").click();

  bot.textWithLabel("Enter or select the parent folder:").setText(parentProjectName);
  bot.textWithLabel("File name:").setText(fileName);
  bot.button("Next >").click();

  bot.comboBox(0).setSelection("Compartment Diagram");
  // bot.comboBox("Model Object").setSelection("Compartment Diagram");
  bot.button("Finish").click();
  return shell;
}
项目:tmxeditor8    文件:CreateProjectDemo.java   
@Test
public void createProject() throws Exception {
    String projectName = "prjBot-001";

    bot.menu("File").menu("New").click();
    SWTBotShell shell = bot.shell("New");
    shell.activate();
    // From menu open File > New dialog, verify whether the dialog has been opened.

    bot.tree().select("Project");
    SWTBotAssert.assertEnabled(bot.button("Next >"));
    // After selecting Project, the Next button should be enabled.

    bot.button("Next >").click();
    bot.textWithLabel("Project name:").setText(projectName);
    SWTBotAssert.assertEnabled(bot.button("Finish"));
    // Enter the Project Name, then Finish button should be enabled.

    bot.button("Finish").click();
    SWTBotAssert.assertVisible(bot.tree().select(projectName));
    // Click Finish button and verify whether the project's been successfully created.
}
项目:xsemantics    文件:XsemanticsSwtbotTestBase.java   
protected void createProjectAndAssertNoErrorMarker(String projectType) throws CoreException {
    SWTBotMenu fileMenu = bot.menu("File");
    SWTBotMenu newMenu = fileMenu.menu("New");
    SWTBotMenu projectMenu = newMenu.menu("Project...");
    projectMenu.click();

    SWTBotShell shell = bot.shell("New Project");
    shell.activate();
    SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
    waitForTreeItems(xsemanticsNode);
    xsemanticsNode.expandNode(projectType).select();
    bot.button("Next >").click();

    bot.textWithLabel("Project name:").setText(TEST_PROJECT);

    bot.button("Finish").click();

    // creation of a project might require some time
    bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
    assertTrue("Project doesn't exist", isProjectCreated(TEST_PROJECT));

    waitForBuild();
    assertNoErrorsInProject();
}
项目:xsemantics    文件:XsemanticsImportExamplesProjectWizardTests.java   
protected void createExampleProjects(String projectType,
        String mainProjectId) {
    SWTBotMenu fileMenu = bot.menu("File");
    SWTBotMenu newMenu = fileMenu.menu("New");
    SWTBotMenu otherMenu = newMenu.menu("Other...");
    otherMenu.click();

    SWTBotShell shell = bot.shell("New");
    shell.activate();
    SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
    waitForTreeItems(xsemanticsNode);
    SWTBotTreeItem examplesNode = xsemanticsNode.expandNode("Examples");
    waitForTreeItems(examplesNode);
    examplesNode.expandNode(projectType).select();
    bot.button("Next >").click();

    bot.button("Finish").click();

    // creation of a project might require some time
    bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
    assertTrue("Project doesn't exist", isProjectCreated(mainProjectId));
    assertTrue("Project doesn't exist", isProjectCreated(mainProjectId
            + ".tests"));
    assertTrue("Project doesn't exist", isProjectCreated(mainProjectId
            + ".ui"));
}
项目:packtpub-xtext-book-examples    文件:SmallJavaProjectWizardTests.java   
@BeforeClass
public static void beforeClass() throws Exception {
    bot = new SWTWorkbenchBot();
    try {
        bot.viewByTitle("Welcome").close();
    } catch (WidgetNotFoundException e) {
        // OK, no Welcome view, that's fine :)
    }

    // Change the perspective via the Open Perspective dialog
    bot.menu("Window").menu("Open Perspective").menu("Other...").click();
    SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
    openPerspectiveShell.activate();

    // select the dialog
    bot.table().select("Plug-in Development");
    bot.button("OK").click();

    // in Luna the Error Log is not shown by default in the Plug-in Development perspective
    // bot.viewByPartName("Error Log").close();

    // in SwtBot 2.2.0 we must use viewByPartName instead of viewByTitle
    bot.viewByPartName("Problems").show();
}
项目:packtpub-xtext-book-examples    文件:SmallJavaProjectWizardTests.java   
private void createProject(String projectType, String projectName) {
    bot.menu("File").menu("New").menu("Project...").click();

    SWTBotShell shell = bot.shell("New Project");
    shell.activate();
    bot.tree().expandNode("Xtext").select(projectType);
    bot.button("Next >").click();

    bot.textWithLabel("Project name:").setText(projectName);

    bot.button("Finish").click();

    // creation of a project might require some time
    bot.waitUntil(shellCloses(shell), 50000);
    assertTrue("Project doesn't exist", isProjectCreated(projectName));
}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
private void closeWizard () {
    try {
        SWTBotShell shell = bot.shell("Generate a GraphWalker Offline Test");
        Conditions.shellCloses(shell);
    } catch (Exception e) {
    }       
}
项目:gw4e.project    文件:GW4EProject.java   
public GraphModelProperties getGraphmlProperties(String folder, String pkg, String filename) {
    SWTBotTreeItem pti = getProjectTreeItem(this.projectName);
    pti.expand();

    SWTBotTreeItem fileItem = null;
    if (pkg == null) {
        fileItem = pti.expandNode(folder, filename);
    } else {
        fileItem = pti.expandNode(folder, pkg, filename);
    }

    bot.waitUntil(new isItemExpandedInTree(pti.getNode(folder)));

    fileItem.setFocus();
    fileItem.select();
    bot.waitUntil(new isItemSelectedInTree(fileItem));

    fileItem.click();

    bot.waitUntil(new isItemSelected(fileItem));

    SWTBotMenu fileMenu = bot.menu("File");
    fileMenu.menu("Properties").click();

    bot.waitUntil(Conditions.shellIsActive("Properties for " + filename));
    SWTBotShell shell = bot.shell("Properties for " + filename);
    GraphModelProperties gp = new GraphModelProperties(shell.bot(), this.projectName, folder, pkg, filename);

    return gp;
}
项目:gw4e.project    文件:GW4EProject.java   
public boolean convertTo(String project, String packageRootFragment, String pkg, String targetFilename,
        String targetFormat, String checkTestBox, String... nodes) {
    ConvertDialog cd = prepareConvertTo(project, packageRootFragment, pkg, targetFilename, targetFormat, nodes);
    boolean ret = cd.create(project, packageRootFragment, pkg, targetFilename, targetFormat, checkTestBox);
    if (!ret) {
        SWTBotShell shell = bot.shell("GW4E Conversion File");
        shell.bot().button("Cancel").click();
        bot.waitUntil(Conditions.shellCloses(shell));
        return false;
    }
    return true;
}
项目:gw4e.project    文件:GW4EProject.java   
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;
}
项目:gw4e.project    文件:GW4EProject.java   
public boolean prepareconvertTo(String project, String packageRootFragment, String pkg, String targetFilename,
        String targetFormat, String checkTestBox,String annotationStartElement,
        String targetvertex,String startElement,String [] contexts, String... nodes) {
    ConvertDialog cd = prepareConvertTo(project, packageRootFragment, pkg, targetFilename, targetFormat, nodes);
    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;
    }

    SWTBotButton fbutton = bot.button("Next >");
    fbutton.click();

    GraphWalkerTestUIPageTest gwid = new GraphWalkerTestUIPageTest(cd.getShell());
    gwid.completeFullPage("random(edge_coverage(100))", "GROUP1;GROUP2", annotationStartElement);
    gwid.nextPage();

    JUnitGraphWalkerTestUIPageTest jugw = new JUnitGraphWalkerTestUIPageTest(cd.getShell());
    jugw.completeFullPage(targetvertex, startElement, contexts);
    jugw.nextPage();

    GraphWalkerTestHookPageTest gwth = new GraphWalkerTestHookPageTest(cd.getShell());
    gwth.completeFullPage();
    gwth.finish();

    bot.waitUntil(Conditions.shellCloses(cd.getShell()), 6 * SWTBotPreferences.TIMEOUT);

    return true;
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public void assertNextStepPage(SWTBotShell page, String description, String result) {
    SWTBotButton nextButton = bot.button("&Next >");
    nextButton.click();
    String defaultResult = MessageUtil.getString("enter_a_result_if_verification_failed");
    if (result != null && result.trim().length() > 0 && !result.equals(defaultResult)) {
        new StepPage().setResult(page, result).setFailed(page);
    }
    new StepPage().assertActionAndResult(page, description, result);
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public void assertTexts(SWTBotShell page, String[] texts) {
    SWTBotStyledText styledText = page.bot().styledText();
    for (String text : texts) {
        if (styledText.getText().indexOf(text) == -1) {
            org.junit.Assert.fail("Text does not contain " + text);
        }
    }
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public void assertActionAndResult(SWTBotShell page, String description, String result) {
    SWTBotStyledText styledTextDescription = page.bot().styledTextWithId(
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_STEP_PAGE_DESCRIPTION_ID);
    SWTBotStyledText styledTextResult = page.bot().styledTextWithId(
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_STEP_PAGE_RESULT_ID);

    org.junit.Assert.assertEquals("Invalid Result", result, styledTextResult.getText());
    org.junit.Assert.assertEquals("Invalid Description", description, styledTextDescription.getText());
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public StepPage setResult(SWTBotShell page, String result) {
    SWTBotStyledText styledTextResult = page.bot().styledTextWithId(
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_STEP_PAGE_RESULT_ID);
    styledTextResult.setText(result);
    return this;
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public void setFailed(SWTBotShell page) {
    SWTBotCheckBox button = page.bot().checkBoxWithId(
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
            org.gw4e.eclipse.wizard.runasmanual.StepPage.GW4E_STEP_PAGE_BUTTON_FAILED_ID);
    if (!button.isChecked())
        button.click();
}
项目:gw4e.project    文件:RunAsManualWizard.java   
public void assertContext(SWTBotShell page, SummaryExecutionRow[] rows) {
    SWTBotTable table = bot.tableWithId(
            org.gw4e.eclipse.wizard.runasmanual.SummaryExecutionPage.GW4E_MANUAL_ELEMENT_ID,
            org.gw4e.eclipse.wizard.runasmanual.SummaryExecutionPage.GW4E_MANUAL_TABLE_VIEWER_SUMMARY_ID);
    int max = table.rowCount();
    for (int i = 0; i < max; i++) {
        SWTBotTableItem item = table.getTableItem(i);

        String status = getStatus(item);
        String step = item.getText(1);
        String result = item.getText(2);
        String description = item.getText(4);

        String statusExpected = rows[i].getStatus() + "";
        String stepExpected = rows[i].getStepname();
        String resultExpected = rows[i].getResult();

        String defaultResult = MessageUtil.getString("enter_a_result_if_verification_failed");
        if (defaultResult.equalsIgnoreCase(resultExpected)) {
            resultExpected = "";
        }

        String descriptionExpected = rows[i].getDescription();
        org.junit.Assert.assertEquals("Invalid status", statusExpected, status);
        org.junit.Assert.assertEquals("Invalid step", stepExpected, step);
        org.junit.Assert.assertEquals("Invalid result", resultExpected, result);
        org.junit.Assert.assertEquals("Invalid description", descriptionExpected, description);
    }

}
项目:gw4e.project    文件:ShellActiveCondition.java   
@Override
public boolean test() throws Exception {
    Matcher<Shell> matcher = WidgetMatcherFactory.withText(title);
    bot.waitUntil(Conditions.waitForShell(matcher));
    SWTBotShell shell = bot.shell(title);
    return shell!=null;
}
项目:gw4e.project    文件:ImportHelper.java   
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);
}
项目:gw4e.project    文件:GW4EProjectPreference.java   
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);
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private void showConsolePreference(SWTBotShell shell) {
    SWTBotTree tree = bot.tree().select("Run/Debug");
    SWTBotTreeItem item = tree.getTreeItem("Console");
    item.click();
    SWTBotCheckBox button = bot.checkBoxWithLabel("Limit console output");
    if (button.isChecked()) button.click();
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private SWTBotShell getPreferenceDialog() {
    Matcher<Shell> matcher = WidgetMatcherFactory.withText("Preferences");
    bot.waitUntil(Conditions.waitForShell(matcher));
    SWTBotShell shell = bot.shell("Preferences");
    shell.activate();
    return shell;
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private SWTBotShell showPreferenceDialog() {
    if (OSUtils.isWindows() || OSUtils.isLinux()) {
        return showPreferenceDialogWindowPreference();
    } else {
        return showPreferenceDialogMAC() ;
    }
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private void showConsolePreference(SWTBotShell shell) {
    SWTBotTree tree = bot.tree().select("Run/Debug");
    tree.expandNode("Run/Debug", true);

    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem swtBotTreeItem : items) {
        if (swtBotTreeItem.getText().equalsIgnoreCase("Run/Debug")) {
            swtBotTreeItem.getNode("Console").select();
        }
    }

    try {
        int max = 10;
        for (int i = 0; i < max; i++) {
            SWTBotCheckBox button = bot.checkBox(i);
            if (button.getText().equalsIgnoreCase("&Limit console output")) {
                if (button.isChecked()) {
                    button.click();
                    break;
                }
            }
        } 
    } catch (Exception e) {
    }

    String name = "OK";
    if (GW4EPlatform.isEclipse47()) name = "Apply and Close";
    bot.button(name).click();
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private SWTBotShell showPreferenceDialog() {
    if (OSUtils.isWindows() || OSUtils.isLinux()) {
        return showPreferenceDialogWindowPreference();
    } else {
        return showPreferenceDialogMAC() ;
    }
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private SWTBotShell getPreferenceDialog() {
    Matcher<Shell> matcher = WidgetMatcherFactory.withText("Preferences");
    bot.waitUntil(Conditions.waitForShell(matcher));
    SWTBotShell shell = bot.shell("Preferences");
    shell.activate();
    return shell;
}