Java 类org.eclipse.swtbot.swt.finder.waits.ICondition 实例源码

项目:gw4e.project    文件:OutLineView.java   
public ICondition createTreeRowCountCondition (final int count) {
    return new ICondition () {
        @Override
        public boolean test() throws Exception {
            return  geVisibleRowCount () == count;
        }

        @Override
        public void init(SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Expected row coutn not found ";
        }

    };
}
项目:gw4e.project    文件:ToolBarEditor.java   
public void copy(ICondition condition) {
    CopyAction button = new CopyAction();
    button.click();
    editor.click(50, 50);
    if (condition == null) {
        condition = new org.eclipse.swtbot.swt.finder.waits.ICondition() {
            @Override
            public boolean test() throws Exception {
                PasteAction button = new PasteAction();
                return button.isEnabled();
            }

            @Override
            public void init(SWTBot bot) {
            }

            @Override
            public String getFailureMessage() {
                return "Paste button not enabled";
            }

        };
    }
    bot.waitUntil(condition);
}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
@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 ();
}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
@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 ();
}
项目: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    文件:GW4EFixesTestCase.java   
@Test
public void testFixUnExistingEntry () throws CoreException, IOException, InterruptedException {
    System.out.println("XXXXXXXXXXXXXXXXXXXX testFixUnExistingEntry");
    GW4EProject project = new GW4EProject(bot, gwproject);
    project.resetToJavPerspective();
    project.createProjectWithoutError(TEST_RESOURCE_FOLDER, PACKAGE_NAME, graphMLFilename);

    addUnExistingEntry (project);
    project.cleanBuild(); 


    ProblemView pv = ProblemView.open(bot);

    pv.executeQuickFixForErrorMessage(
            "Unexisting Graph Model : dummy.graphml",
            MessageUtil.getString("removethisentryfromthebuildpoliciesfile"), 
            new ICondition [] {new NoErrorInProblemView(pv)}
    );
    pv.close();//Mandatory

}
项目:gw4e.project    文件:GW4EProject.java   
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);
}
项目:gw4e.project    文件:ConsoleView.java   
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();
}
项目: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    文件: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    文件:GW4EManualRunner.java   
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);
}
项目: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";
        }
    });
}
项目:gw4e.project    文件:ToolBarView.java   
@Override
public void delete(ICondition condition) {
     List<SWTBotToolbarButton> swtBotToolbarButtons = view.getToolbarButtons();
     for (SWTBotToolbarButton swtBotToolbarButton : swtBotToolbarButtons) {
        if ("Delete".equals(swtBotToolbarButton.getToolTipText())) {
            swtBotToolbarButton.click();
        }
    }
    if (condition!=null)
        view.bot().waitUntil(condition);
}
项目:gw4e.project    文件:ToolBarView.java   
@Override
public void undoDelete(ICondition condition) {
     List<SWTBotToolbarButton> swtBotToolbarButtons = view.getToolbarButtons();
     for (SWTBotToolbarButton swtBotToolbarButton : swtBotToolbarButtons) {
        if ("Undo Delete".equals(swtBotToolbarButton.getToolTipText())) {
            swtBotToolbarButton.click();
        }
    }
    if (condition!=null)
        view.bot().waitUntil(condition);
}
项目:gw4e.project    文件:ToolBarView.java   
@Override
public void redoDelete(ICondition condition) {
     List<SWTBotToolbarButton> swtBotToolbarButtons = view.getToolbarButtons();
     for (SWTBotToolbarButton swtBotToolbarButton : swtBotToolbarButtons) {
        if ("Redo Delete".equals(swtBotToolbarButton.getToolTipText())) {
            swtBotToolbarButton.click();
        }
    }
    if (condition!=null)
        view.bot().waitUntil(condition);
}
项目:gw4e.project    文件:ToolBarEditor.java   
public void paste(ICondition condition) {
    PasteAction action = new PasteAction();
    action.click();
    editor.click(10, 10) ; // Give the editor the focus
    if (condition!=null)
        bot.waitUntil(condition);
}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
@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 ();

}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
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);
}
项目:gw4e.project    文件:GW4EFixesTestCase.java   
@Test
public void testQuickFixesSetNoCheckMode()
        throws CoreException, BuildPolicyConfigurationException, IOException {
    System.out.println("XXXXXXXXXXXXXXXXXXXX testQuickFixesSetNoCheckMode");
    GW4EProject project = new GW4EProject(bot, gwproject);
    project.createInitialProject(gwproject,TEST_RESOURCE_FOLDER,PACKAGE_NAME,graphMLFilename);

    ProblemView pv = ProblemView.open(bot);

    ICondition [] conditions =  new ICondition [] {
        new ErrorIsInProblemView(pv, GW4EProject.NO_POLICIES_FOUND_IN_BUILD_POLICIES_FILE_ERROR_MSG),
        new EditorOpenedCondition(bot,PreferenceManager.getBuildPoliciesFileName(gwproject)),
    };

    pv.executeQuickFixForErrorMessage(
            project.getMissingErroMessage (gwproject,TEST_RESOURCE_FOLDER,PACKAGE_NAME,graphMLFilename),
            GW4EProject.QUICK_FIX_MSG_MISSING_BULD_POLICIES_FILE,
            conditions);
    pv.close(); // Mandatory

    pv = ProblemView.open(bot);
    pv.executeQuickFixForErrorMessage(
            GW4EProject.NO_POLICIES_FOUND_IN_BUILD_POLICIES_FILE_ERROR_MSG,
            GW4EProject.ADD_NOCHECK_POLICIES,
            new ICondition [] {new NoErrorInProblemView(pv)}
    );

    String buildPoliciPath = gwproject + "/" + TEST_RESOURCE_FOLDER + "/"+ PACKAGE_NAME + "/" + PreferenceManager.getBuildPoliciesFileName(gwproject) ;
    IFile buildPolicyModel =  (IFile)  ResourceManager.getResource(buildPoliciPath);
    IPath pathModel = buildPolicyModel.getFullPath().removeLastSegments(1).append(graphMLFilename);
    IFile iFileModel = (IFile)  ResourceManager.getResource(pathModel.toString());

    String policies = project.getPathGenerator (buildPolicyModel , graphMLFilename);
    String expectedPolicies =   NoBuildRequiredException.NO_CHECK  ;

    assertEquals("Wrong policies found in the build policies file", expectedPolicies, policies);

}
项目:gw4e.project    文件:GW4EFixesTestCase.java   
@Test
public void testInvalidGenerator  () throws CoreException, IOException, InterruptedException {
    System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidGenerator");
    String wrongPathGenerator = "xxx";
    GW4EProject project = new GW4EProject(bot, gwproject);
    project.createProjectWithoutError( TEST_RESOURCE_FOLDER,  PACKAGE_NAME,  graphMLFilename);

    String policiesFileName = PreferenceManager.getBuildPoliciesFileName(gwproject);
    IPath path = new Path (gwproject).append(TEST_RESOURCE_FOLDER).append(PACKAGE_NAME).append(policiesFileName);
    IFile buildPolicyFile = (IFile) ResourceManager.getResource(path.toString());

    project.setPathGenerator (buildPolicyFile , graphMLFilename, wrongPathGenerator);

    project.cleanBuild(); 

    String expectedErrorMessageInProblemView = "Missing severity flag for '" + wrongPathGenerator + "'";
    ProblemView pv = ProblemView.open(bot);
    IMarkerResolution [] markers = InvalidSeverityMarkerResolution.getResolvers();
    String error1 = MessageUtil.getString("invalidpathgeneratoroudinbuildpolicies") + wrongPathGenerator;
    pv.executeQuickFixForErrorMessage(
            expectedErrorMessageInProblemView,
            markers[0].getLabel(),
            new ICondition [] {new ErrorIsInProblemView(pv,error1)}
    );
    pv.close();//Mandatory


    pv.open(bot);
    ResolutionMarkerDescription description = PathGeneratorDescription.getDescriptions().get(9);

    pv.executeQuickFixForErrorMessage(
            error1,
            description.toString(),
            new ICondition [] {new NoErrorInProblemView(pv)}
    );

    String  updatedValue  = project.getPathGenerator (buildPolicyFile , graphMLFilename);
    String expectedValue = description.getGenerator() + ";" + PreferenceManager.getDefaultSeverity(gwproject);
    assertEquals("Wrong policies found in the build policies file", expectedValue, updatedValue);
}
项目:gw4e.project    文件:GW4EFixesTestCase.java   
@Test
public void testInvalidSeverity () throws CoreException, IOException, InterruptedException {
    System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidSeverity");
    String wrongSeverity = "Z";
    String pathGeneratorPrefix = "random(vertex_coverage(100));E;random(edge_coverage(100));";
    GW4EProject project = new GW4EProject(bot, gwproject);
    project.createProjectWithoutError( TEST_RESOURCE_FOLDER,  PACKAGE_NAME,  graphMLFilename);

    String policiesFileName = PreferenceManager.getBuildPoliciesFileName(gwproject);
    IPath path = new Path (gwproject).append(TEST_RESOURCE_FOLDER).append(PACKAGE_NAME).append(policiesFileName);
    IFile buildPolicyFile = (IFile) ResourceManager.getResource(path.toString());

    project.setPathGenerator (buildPolicyFile , graphMLFilename, pathGeneratorPrefix + wrongSeverity);

    project.cleanBuild(); 

    String expectedErrorMessageInProblemView = "Invalid severity flag found  '" + wrongSeverity + "'  (Choose one of E,W,I)" ;

    ProblemView pv = ProblemView.open(bot);
    IMarkerResolution [] resolutions = InvalidSeverityMarkerResolution.getResolvers();

    pv.executeQuickFixForErrorMessage(
            expectedErrorMessageInProblemView,
            resolutions [0].getLabel(),
            new ICondition [] {new NoErrorInProblemView(pv)}
    );
    pv.close();//Mandatory

    String  updatedValue  = project.getPathGenerator (buildPolicyFile , graphMLFilename);
    String expectedValue = pathGeneratorPrefix  + ((InvalidSeverityMarkerResolution)resolutions [0]).getSeverity();
    assertEquals("Wrong severity found in the build policies file", expectedValue, updatedValue);
}
项目:gw4e.project    文件:GW4EFixesTestCase.java   
@Test
public void testInvalidGeneratorInSourceFile () throws CoreException, FileNotFoundException {
    System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidGeneratorInSourceFile");
    String expectedNewGenerator = "xxx";

        PetClinicProject.create (bot,gwproject); // At this step the generator is "random(edge_coverage(100))"

        IFile veterinarien = PetClinicProject.getVeterinariensSharedStateImplFile(gwproject);
    ICompilationUnit cu = JavaCore.createCompilationUnitFrom(veterinarien);
    String oldGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
        SourceHelper.updatePathGenerator(veterinarien, oldGenerator, expectedNewGenerator);
        cu = JavaCore.createCompilationUnitFrom(veterinarien);
        String newGenerator = JDTManager.findPathGeneratorInGraphWalkerAnnotation(cu);
        assertEquals(newGenerator,expectedNewGenerator);

        GW4EProject project = new GW4EProject(bot, gwproject);
        project.cleanBuild(); 

        String expectedErrorMessageInProblemView = "Invalid path generator : '"+ expectedNewGenerator + "'";
    ProblemView pv = ProblemView.open(bot);
    List<ResolutionMarkerDescription> markers = PathGeneratorDescription.getDescriptions();

    pv.executeQuickFixForErrorMessage(
            expectedErrorMessageInProblemView,
            markers.get(0).toString(), 
            new ICondition [] {new NoErrorInProblemView(pv)}
    );
    pv.close();//Mandatory

        String graphmlSourcePath = JDTManager.getGW4EGeneratedAnnotationValue(cu,"value");
        IPath path = new Path (gwproject).append(graphmlSourcePath);
        IFile graphModel =  (IFile)ResourceManager.getResource(path.toString());
        IPath buildPolicyPath = ResourceManager.getBuildPoliciesPathForGraphModel(graphModel);
        IFile buildPolicyFile =  (IFile)ResourceManager.getResource(buildPolicyPath.toString());

    PropertyValueCondition condition = new PropertyValueCondition(buildPolicyFile,graphModel.getName(),"random(vertex_coverage(100));I;random(edge_coverage(100));I;");
    bot.waitUntil(condition);

    }
项目:gw4e.project    文件:GW4ETemplateTestCase.java   
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);
}
项目:gw4e.project    文件:GW4ETemplateTestCase.java   
@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);
}
项目:gw4e.project    文件:GW4EProject.java   
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;
}
项目:gw4e.project    文件:GW4EProject.java   
public void createInitialProjectWithoutError(String resourceFolder, String pkg, String graphMLFilename)
        throws FileNotFoundException, CoreException, BuildPolicyConfigurationException {
    createInitialProject(projectName, resourceFolder, pkg, graphMLFilename);

    ProblemView pv = ProblemView.open(bot);

    ICondition[] conditions = new ICondition[] {
            new ErrorIsInProblemView(pv, GW4EProject.NO_POLICIES_FOUND_IN_BUILD_POLICIES_FILE_ERROR_MSG),
            new EditorOpenedCondition(bot, PreferenceManager.getBuildPoliciesFileName(projectName)), };

    GW4EProject project = new GW4EProject(bot, projectName);

    pv.executeQuickFixForErrorMessage(
            project.getMissingErroMessage(projectName, resourceFolder, pkg, graphMLFilename),
            GW4EProject.QUICK_FIX_MSG_MISSING_BULD_POLICIES_FILE, conditions);
    pv.close(); // Mandatory

    pv = ProblemView.open(bot);
    pv.executeQuickFixForErrorMessage(GW4EProject.NO_POLICIES_FOUND_IN_BUILD_POLICIES_FILE_ERROR_MSG,
            GW4EProject.ADD_DEFAULT_POLICIES, new ICondition[] { new NoErrorInProblemView(pv) });

    String buildPoliciPath = projectName + "/" + resourceFolder + "/" + pkg + "/"
            + PreferenceManager.getBuildPoliciesFileName(projectName);
    IFile buildPolicyModel = (IFile) ResourceManager.getResource(buildPoliciPath);
    IPath pathModel = buildPolicyModel.getFullPath().removeLastSegments(1).append(graphMLFilename);
    IFile iFileModel = (IFile) ResourceManager.getResource(pathModel.toString());
    String[] policies = BuildPolicyManager.valuesToArray(projectName, buildPolicyModel, iFileModel,
            graphMLFilename);
    String[] expectedPolicies = PreferenceManager.getBasicPolicies(projectName);

    assertArrayEquals("Wrong policies found in the build policies file", expectedPolicies, policies);

}
项目: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    文件: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  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";
        }
    };

}
项目:gw4e.project    文件:GW4EPreferencePage.java   
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);
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
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);
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private void waitForNotExpectedValueAtRowCol(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);
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorModelName (String newName,String [] nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Resource"));
    SWTBotShell shell = bot.shell("Rename Resource");

    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(newName);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorRenameFolder (String [] nodes, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Package"));
    SWTBotShell shell = bot.shell("Rename Package");


    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(name);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell), 30 * 1000);
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorMoveModel (String [] nodes,String [] destination, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Move...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Move"));
    SWTBotShell shell = bot.shell("Move");

    SWTBotTree packageTree = shell.bot().treeWithLabel("Choose destination for '"+ name + "':");
    SWTBotTreeItem target = packageTree.expandNode(destination);
    target.select();
    target.setFocus();

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:AbstractRunner.java   
protected SWTBotShell openRun () {
    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            try {
                bot.menu("Run").menu("Run Configurations...").click();
                return true;
            } catch (Exception e) {
                return false;
            }
        }

        @Override
        public String getFailureMessage() {

            return "Unable to find the 'Run -> Run Configurations...' menu";
        }

    };

    bot.waitUntil(condition, RUN_TIMEOUT);

    bot.waitUntil(Conditions.shellIsActive("Run Configurations"));
    SWTBotShell shell = bot.shell("Run Configurations");
    SWTBotTreeItem item = shell.bot().tree().getTreeItem(getLauncherName()).select();
    item.select();
    return shell;
}
项目:gw4e.project    文件:GW4EManualRunner.java   
@Override
protected ICondition getWaitConditionWhenOpeningConfiguration() {
    ICondition condition = Conditions.waitForWidget(
            WidgetMatcherFactory.withId(
                    GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
                    GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_OMIT_EMPTY_EDGE));
    return condition;
}
项目:gw4e.project    文件:GW4EManualRunner.java   
public IFile importJSONModel (String sourceFile,String targetFolder) throws IOException, CoreException {
    URL url = this.getClass().getClassLoader().getResource(sourceFile);
    File f = new File(FileLocator.toFileURL(url).getPath());
    IContainer container  = (IContainer) ResourceManager.getResource(targetFolder);
    ImportHelper.copyFile(f, container);
    IPath p = new Path(targetFolder).append(sourceFile);
    ICondition condition = new ResourceExists (p);
    bot.waitUntil(condition);
    return (IFile) ResourceManager.getResource(p.toString());
}
项目:gw4e.project    文件:GW4ETestRunner.java   
@Override
protected ICondition getWaitConditionWhenOpeningConfiguration() {
    ICondition condition = Conditions.waitForWidget(
            WidgetMatcherFactory.withId(
                    GW4ELaunchConfigurationTab.GW4E_LAUNCH_CONFIGURATION_CONTROL_ID,
                    GW4ELaunchConfigurationTab.GW4E_LAUNCH_TEST_CONFIGURATION_PROJECT));
    return condition;
}