Java 类org.eclipse.swtbot.swt.finder.results.VoidResult 实例源码

项目:eclemma    文件:CoverageViewTest.java   
@Test
public void testImportSession() {
  // given
  UIThreadRunnable.syncExec(new VoidResult() {
    public void run() {
      try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.eclemma.ui.CoverageView");
      } catch (PartInitException e) {
        e.printStackTrace();
      }
    }
  });

  // when
  SWTBotView view = bot.viewByTitle("Coverage");
  view.bot().tree().contextMenu("Import Session...").click();

  // then
  bot.shell("Import").activate();
  bot.text(" Please select an existing execution data file.");
}
项目:dsl-devkit    文件:TestRunRecording.java   
/** {@inheritDoc} */
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public void testStarted(final Description description) {
  if (!screenshotsCleared) {
    deleteDirectoryContents(new File(screenshotFolder));
    screenshotsCleared = true;
  }
  testFailed = false;
  testStepStarted = false;
  if (description.getTestClass() != null) {
    testClassName = description.getTestClass().getName();
  } else {
    testClassName = testClass.getSimpleName();
  }
  testMethodName = description.getMethodName();
  AbstractTestStep.registerTestStepListener(this);
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().addMouseListener(TestRunRecording.this);
    }
  });
  start();
}
项目:dsl-devkit    文件:TestRunRecording.java   
/** {@inheritDoc} */
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public void testFinished(final Description description) {
  stop();
  AbstractTestStep.removeTestStepListener(this);
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().removeMouseListener(TestRunRecording.this);
    }
  });
  if (!testFailed) {
    deleteScreenshots();
  }
}
项目:dsl-devkit    文件:ContextActionUiTestUtil.java   
/**
 * Clicks on the {@link MenuItem}.
 *
 * @param menuItem
 *          the {@link MenuItem} to click on
 */
private static void click(final MenuItem menuItem) {
  final Event event = new Event();
  event.time = (int) System.currentTimeMillis();
  event.widget = menuItem;
  event.display = menuItem.getDisplay();
  event.type = SWT.Selection;

  UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
    @Override
    public void run() {
      if (SWTUtils.hasStyle(menuItem, SWT.CHECK) || SWTUtils.hasStyle(menuItem, SWT.RADIO)) {
        menuItem.setSelection(!menuItem.getSelection());
      }
      menuItem.notifyListeners(SWT.Selection, event);
    }
  });
}
项目:dsl-devkit    文件:AbstractUiTest.java   
/**
 * Opens the editor asynchronously.
 *
 * @param file
 *          the file
 * @param editorId
 *          the editor id
 * @param activate
 *          true to activate, false otherwise
 */
protected void openEditorAsync(final IFile file, final String editorId, final boolean activate) {
  asyncExec(new VoidResult() {
    @Override
    public void run() {
      try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
        final int matchFlags = IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT;
        final IEditorInput input = new FileEditorInput(file);
        IEditorPart editor = activePage.openEditor(input, editorId, activate, matchFlags);
        editor.setFocus();
        waitForEditorJobs(editor);
      } catch (PartInitException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e.getMessage(), e);
        }
      }
    }
  });
}
项目:tlaplus    文件:RCPTestSetupHelper.java   
public static void beforeClass() {
    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            resetWorkbench();
            resetToolbox();

            // close browser-based welcome screen (if open)
            SWTWorkbenchBot bot = new SWTWorkbenchBot();
            try {
                SWTBotView welcomeView = bot.viewByTitle("Welcome");
                welcomeView.close();
            } catch (WidgetNotFoundException e) {
                return;
            }
        }
    });
}
项目:emfstore-rest    文件:UIShowHistoryControllerForElementTest.java   
@Override
@Test
public void testController() throws ESException {

    final Player player = createPlayerAndCommit();

    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIShowHistoryController showHistoryController =
                new UIShowHistoryController(bot.getDisplay().getActiveShell(), player);
            showHistoryController.execute();
        }
    });

    final SWTBotView historyView = bot.viewById(
        "org.eclipse.emf.emfstore.client.ui.views.historybrowserview.HistoryBrowserView");

    assertNotNull(historyView);
}
项目:emfstore-rest    文件:UIShowHistoryControllerTest.java   
@Override
@Test
public void testController() throws ESException {

    createPlayerAndCommit();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIShowHistoryController showHistoryController =
                new UIShowHistoryController(bot.getDisplay().getActiveShell(), localProject);
            showHistoryController.execute();
        }
    });

    final SWTBotView historyView = bot.viewById(
        "org.eclipse.emf.emfstore.client.ui.views.historybrowserview.HistoryBrowserView");

    assertNotNull(historyView);
}
项目:emfstore-rest    文件:UIAddTagControllerTest.java   
private ESPathQuery createTag() throws ESException {
    ESPrimaryVersionSpec baseVersion = localProject.getBaseVersion();
    createPlayerAndCommit();
    ESPathQuery pathQuery = ESHistoryQuery.FACTORY
        .pathQuery(baseVersion, localProject.getBaseVersion(), true, true);
    List<ESHistoryInfo> historyInfos = localProject.getHistoryInfos(pathQuery, new NullProgressMonitor());
    assertEquals(2, historyInfos.size());
    final ESHistoryInfo historyInfo = historyInfos.get(1);
    assertEquals(2, historyInfo.getTagSpecs().size());
    UIThreadRunnable.asyncExec(
        new VoidResult() {
            public void run() {
                UIAddTagController addTagController = new UIAddTagController(bot.getDisplay().getActiveShell(),
                    localProject, historyInfo);
                addTagController.execute();
            }
        });

    bot.table(0).select(0);
    SWTBotButton button = bot.button("OK");
    button.click();
    return pathQuery;
}
项目:emfstore-rest    文件:UIServerControllerTest.java   
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());
}
项目:eclipse-plugin    文件:SWTBotBaseTest.java   
@Before
public void baseBeforeTest() {
    // Sets codenvy fake API
    CodenvyAPI.setClient(new FakeCodenvyClient());

    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            final Shell eclipseShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            eclipseShell.forceFocus();
        }
    });

    try {

        final SWTBotView welcomeView = bot.viewByTitle("Welcome");
        welcomeView.close();

    } catch (WidgetNotFoundException e) {
        // ignore the exception
    }
}
项目:gw4e.project    文件:GraphElementProperties.java   
protected void selectTab(SWTBotGefEditPart part, String label) {
    selectPart(part);
    Matcher<TabbedPropertyList> matcher = new BaseMatcher<TabbedPropertyList>() {
        @Override
        public boolean matches(Object item) {
            if (item instanceof TabbedPropertyList) {
                return true;
            }
            return false;
        }
        @Override
        public void describeTo(Description description) {
        }
    };
    List<TabbedPropertyList> allWidgets = widget(matcher);
    UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
        @Override
        public void run() {
            for (final TabbedPropertyList tabbedProperty : allWidgets) {
                final ListElement tabItem = getTabItem(label, tabbedProperty);
                if (tabItem != null) {
                    final Event mouseEvent = createEvent(tabItem);
                    tabItem.notifyListeners(SWT.MouseUp, mouseEvent);
                    tabItem.setFocus();
                    return;
                }
            }
            throw new IllegalStateException("Unable to select the tab " + label);
        }
    });
}
项目:gw4e.project    文件:VertexProperties.java   
public void setInit(SWTBotGefEditPart part, String script) {
    selectPart(part);
    selectTab(part, INIT);
    SWTBotStyledText st = bot.styledTextWithId( WIDGET_ID,  WIDGET_SCRIPT);
    st.setText(script);
    UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
        @Override
        public void run() {
            st.widget.notifyListeners(SWT.FocusOut, null);
            editor.setFocus();
        }
    });
}
项目:gw4e.project    文件:GraphHelper.java   
protected void syncWithUIThread() {
    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) {
            }
        }
    });
}
项目:gw4e.project    文件:EdgeProperties.java   
public void setGuard(SWTBotGefEditPart part, String script) {
    selectPart(part);
    selectTab(part, GUARD);
    SWTBotStyledText st = bot.styledTextWithId(WIDGET_ID, WIDGET_GUARD_SCRIPT);
    st.setText(script);
    UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
        @Override
        public void run() {
            st.widget.notifyListeners(SWT.FocusOut, null);
            editor.setFocus();
        }
    });
}
项目:gw4e.project    文件:EdgeProperties.java   
public void setAction(SWTBotGefEditPart part, String script) {
    selectPart(part);
    selectTab(part, ACTION);
    SWTBotStyledText st = bot.styledTextWithId(WIDGET_ID, WIDGET_ACTION_SCRIPT);
    st.setText(script);
    UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
        @Override
        public void run() {
            st.widget.notifyListeners(SWT.FocusOut, null);
            editor.setFocus();
        }
    });
}
项目:gw4e.project    文件:GW4EProject.java   
public   void asyncPrint(final List<MenuItem> list) {
    UIThreadRunnable.asyncExec(bot.getDisplay(), new VoidResult() {
        public void run() {
            for (MenuItem menuItem : list) {
                System.out.println(menuItem.getText());
            }
        }
    });

}
项目:eclemma    文件:DumpExecutionDataTest.java   
private static void openCoverageView() {
    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            try {
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                        .showView("org.eclipse.eclemma.ui.CoverageView");
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
    });
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
private static void printTree(final TreeItem tree) {
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      System.err.println(String.format("%s has %d items:", tree.getText(), tree.getItemCount()));
      for (TreeItem item : tree.getItems()) {
        System.err.println(String.format("  - %s", item.getText()));
      }
    }
  });
}
项目:dsl-devkit    文件:SwtBotRadio.java   
/**
 * {@inheritDoc} A customized version to fix bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484.
 */
@Override
public SwtBotRadio click() {
  if (isSelected()) {
    log.debug(MessageFormat.format("Widget {0} is already selected, not clicking again.", this)); //$NON-NLS-1$
    return this;
  }
  waitForEnabled();

  log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$

  final SwtBotRadio otherSelectedButton = otherSelectedButton();
  if (otherSelectedButton != null) {
    otherSelectedButton.notify(SWT.Deactivate);
    asyncExec(new VoidResult() {
      public void run() {
        otherSelectedButton.widget.setSelection(false);
      }
    });
  }

  notify(SWT.Activate);
  notify(SWT.MouseDown, createMouseEvent(0, 0, 1, 0, 1));
  notify(SWT.MouseUp, createMouseEvent(0, 0, 1, SWT.BUTTON1, 1));
  asyncExec(new VoidResult() {
    public void run() {
      widget.setSelection(true);
    }
  });
  notify(SWT.Selection);

  log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$
  return this;
}
项目:dsl-devkit    文件:FixedDefaultWorkbench.java   
/**
 * Reset active perspective.
 *
 * @return the fixed default workbench
 */
FixedDefaultWorkbench resetActivePerspective() {
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      activePage().resetPerspective();
    }
  });
  return this;
}
项目:dsl-devkit    文件:AbstractUiTest.java   
/**
 * Closes the given editor-part.
 *
 * @param editor
 *          the editor to close
 * @param save
 *          true if should save before close, false otherwise
 */
protected void closeEditor(final IEditorPart editor, final boolean save) {
  UiAssert.isNotUiThread();
  Object editorJobs = getTestUtil().getEditorJobFamily(editor);
  UIThreadRunnable.syncExec(getBot().getDisplay(), new VoidResult() {
    @Override
    public void run() {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, save);
    }
  });
  if (editorJobs != null) {
    waitForJobsOfFamily(editorJobs);
  }
}
项目:tlaplus    文件:RCPTestSetupHelper.java   
public static void afterClass() {
    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            resetWorkbench();
        }
    });
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
private static void printTree(final TreeItem tree) {
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      System.err.println(String.format("%s has %d items:", tree.getText(), tree.getItemCount()));
      for (TreeItem item : tree.getItems()) {
        System.err.println(String.format("  - %s", item.getText()));
      }
    }
  });
}
项目:emfstore-rest    文件:UIShareProjectControllerTest.java   
private void shareProject() {
    final ESShareObserver observer = createShareObserver();
    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().register(observer);

    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIShareProjectController shareProjectController = new UIShareProjectController(
                bot.getDisplay().getActiveShell(),
                localProject);
            shareProjectController.execute();
        }
    });

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return didShare;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Share did not succeed.";
        }
    }, timeout());
    final SWTBotButton confirmButton = bot.button("OK");
    confirmButton.click();
    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().unregister(observer);
}
项目:emfstore-rest    文件:UIShareProjectControllerTest.java   
private void createLocalProject() {
    final int localProjectsSize = ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UICreateLocalProjectController localProjectController = new UICreateLocalProjectController(
                bot.getDisplay().getActiveShell());
            localProject = localProjectController.execute();
        }
    });
    final SWTBotText text = bot.text(0);
    text.setText("quux");
    final SWTBotButton button = bot.button("OK");
    button.click();
    bot.waitUntil(new DefaultCondition() {

        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return localProjectsSize + 1 == ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size();
        }

        // END SURPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Create local project did not succeed.";
        }
    });
}
项目:emfstore-rest    文件:UICreateRemoteProjectControllerTest.java   
@Override
@Test
public void testController() throws ESException {
    final int remoteProjectsSize = server.getRemoteProjects(usersession).size();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            createRemoteProjectController = new UICreateRemoteProjectController(
                bot.getDisplay().getActiveShell(),
                usersession);
            createRemoteProjectController.execute();
        }
    });
    final SWTBotText text = bot.text(0);
    text.setText("foo");
    final SWTBotButton okButton = bot.button("OK");
    okButton.click();
    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return server.getRemoteProjects(usersession).size() == remoteProjectsSize + 1;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Create remote project did not succeed.";
        }
    }, timeout());
    assertEquals(remoteProjectsSize + 1, server.getRemoteProjects(usersession).size());
}
项目:emfstore-rest    文件:AbstractUIControllerTestWithCommit.java   
protected void commit(final ESLocalProject localProject) {
    final ESPrimaryVersionSpec baseVersion = localProject.getBaseVersion();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            ESUIControllerFactory.INSTANCE.commitProject(
                bot.getDisplay().getActiveShell(),
                localProject);
        }
    });

    final SWTBotButton buttonWithLabel = bot.button("OK");
    buttonWithLabel.click();

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return baseVersion.getIdentifier() + 1 == localProject.getBaseVersion()
                .getIdentifier();
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Commit did not succeed.";
        }
    }, AllUITests.TIMEOUT);

    assertEquals(baseVersion.getIdentifier() + 1,
        localProject.getBaseVersion().getIdentifier());
}
项目:emfstore-rest    文件:AbstractUIControllerTestWithCommit.java   
protected void checkout() {
    UIThreadRunnable.asyncExec(new VoidResult() {

        public void run() {
            UICheckoutController checkoutController;
            try {
                checkoutController = new UICheckoutController(
                    bot.getDisplay().getActiveShell(),
                    localProject.getRemoteProject());
                checkedoutCopy = checkoutController.execute();
            } catch (final ESException e) {
                fail(e.getMessage());
            }
        }
    });

    bot.text().setText("checkout");
    bot.button("OK").click();

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return checkedoutCopy != null;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Checkout did not succeed";
        }
    }, timeout());
}
项目:emfstore-rest    文件:AbstractUIControllerTestWithCommit.java   
protected ESLocalProject checkout(final ESPrimaryVersionSpec versionSpec, String checkoutName) {

        final ESLocalProject[] localProjectArr = new ESLocalProject[1];

        UIThreadRunnable.asyncExec(new VoidResult() {

            public void run() {
                UICheckoutController checkoutController;
                try {
                    checkoutController = new UICheckoutController(
                        bot.getDisplay().getActiveShell(),
                        versionSpec,
                        localProject.getRemoteProject());
                    localProjectArr[0] = checkoutController.execute();
                } catch (final ESException e) {
                    fail(e.getMessage());
                }
            }
        });

        bot.text().setText(checkoutName);
        bot.button("OK").click();

        bot.waitUntil(new DefaultCondition() {

            // BEGIN SUPRESS CATCH EXCEPTION
            public boolean test() throws Exception {
                return localProjectArr[0] != null;
            }

            // END SUPRESS CATCH EXCEPTION

            public String getFailureMessage() {
                return "Checkout did not succeed";
            }
        }, timeout());

        return localProjectArr[0];
    }
项目:emfstore-rest    文件:AbstractUIControllerTestWithCommit.java   
protected ESPrimaryVersionSpec updateCopy() {
    SWTBotPreferences.PLAYBACK_DELAY = 100;
    didUpdate = false;

    final ESUpdateObserver updateObserver = createUpdateObserver();
    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().register(updateObserver);

    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIUpdateProjectController updateProjectController = new UIUpdateProjectController(
                bot.getDisplay().getActiveShell(),
                getCopy());
            updateProjectController.execute();
        }
    });

    final Matcher<Shell> matcher = withText("Update");
    bot.waitUntil(waitForShell(matcher));
    bot.button("OK").click();

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return didUpdate;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Update did not succeed.";
        }
    }, timeout());

    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().unregister(updateObserver);

    return getCopy().getBaseVersion();
}
项目:emfstore-rest    文件:UIAddTagControllerTest.java   
private void removeTag(final ESHistoryInfo historyInfo, ESPathQuery pathQuery) throws ESException {
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            UIRemoveTagController removeTagController = new UIRemoveTagController(
                bot.getDisplay().getActiveShell(), historyInfo);
            removeTagController.execute();
        }
    });
    List<ESHistoryInfo> historyInfos = localProject.getHistoryInfos(pathQuery, new NullProgressMonitor());
    assertEquals(2, historyInfos.size());
}
项目:emfstore-rest    文件:UIDeleteRemoteProjectControllerTest.java   
@Override
@Test
public void testController() throws ESException {
    final int remoteProjectsSize = server.getRemoteProjects().size();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            UIDeleteRemoteProjectController deleteRemoteProjectController;
            try {
                deleteRemoteProjectController = new UIDeleteRemoteProjectController(bot.getDisplay()
                    .getActiveShell(),
                    usersession, localProject.getRemoteProject());
                deleteRemoteProjectController.execute();
            } catch (final ESException e) {
                fail();
            }
        }
    });
    bot.button("Yes").click();
    bot.waitUntil(new DefaultCondition() {

        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return server.getRemoteProjects().size() == remoteProjectsSize - 1;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Delete remote project did not succeed.";
        }
    });
    assertEquals(remoteProjectsSize - 1, server.getRemoteProjects().size());
}
项目:emfstore-rest    文件:UIRevertCommitControllerTest.java   
@Override
@Test
public void testController() throws ESException {
    assertEquals(0, localProject.getModelElements().size());
    final int localProjectsSize = ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size();
    final ESPrimaryVersionSpec baseVersion = localProject.getBaseVersion();
    createPlayerAndCommit();
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIRevertCommitController revertCommitController = new UIRevertCommitController(
                bot.getDisplay().getActiveShell(),
                baseVersion,
                localProject);
            revertCommitController.execute();
        }
    });

    final SWTBotShell shell = bot.shell("Confirmation");
    shell.bot().button("OK").click();

    final ESLocalProject clonedProject = ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects()
        .get(localProjectsSize);

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return localProjectsSize + 1 == ESWorkspaceProvider.INSTANCE.getWorkspace().getLocalProjects().size()
                && clonedProject.getModelElements().size() == 0;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Revert did not succeed.";
        }
    }, timeout());

    assertEquals(0, clonedProject.getModelElements().size());
}
项目:emfstore-rest    文件:NoLocalChangesCommitControllerTest.java   
@Override
@Test
public void testController() throws ESException {
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            ESUIControllerFactory.INSTANCE.commitProject(
                bot.getDisplay().getActiveShell(),
                localProject);
        }
    });

    bot.shell("No local changes");
    bot.button("OK").click();
}
项目:emfstore-rest    文件:UISessionControllerTest.java   
private void login() {
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            loginSessionController = new UILoginSessionController(
                bot.getDisplay().getActiveShell(),
                server);
            loginSessionController.execute();
        }
    });
    final SWTBotButton okButton = bot.button("OK");
    okButton.click();
    assertNotNull(server.getLastUsersession());
    usersession = server.getLastUsersession();
}
项目:emfstore-rest    文件:UISessionControllerTest.java   
private void logout() {
    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            logoutSessionController =
                new UILogoutSessionController(bot.getDisplay().getActiveShell(), usersession);
            logoutSessionController.execute();
        }
    });
    assertNotNull(server.getLastUsersession());
}
项目:emfstore-rest    文件:UIServerControllerTest.java   
private void removeServer() {
    final int howManyServers = ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size();
    final ESServer serverToBeRemoved = ESWorkspaceProvider.INSTANCE.getWorkspace().getServers()
        .get(howManyServers - 1);
    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIRemoveServerController removeServerController = new UIRemoveServerController(
                bot.getDisplay().getActiveShell(),
                serverToBeRemoved);
            removeServerController.execute();
        }
    });
    bot.button("Yes").click();
    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return howManyServers - 1 == ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size();
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Remove server did not succeed.";
        }
    }, timeout());
    assertEquals(howManyServers - 1, ESWorkspaceProvider.INSTANCE.getWorkspace().getServers().size());
}
项目:dsl-devkit    文件:DragAndDropUtil.java   
/**
 * Performs the drag and drop from source {@link Point} to destination {@link Point}.
 *
 * @param source
 *          the source {@link Point} to start dragging
 * @param dest
 *          the destination {@link Point} for dropping
 */
private void doDragAndDrop(final Point source, final Point dest) {
  // log.debug(MessageFormat.format("Drag-and-dropping from ({0},{1}) to ({2},{3})",
  // source.x, source.y, dest.x, dest.y));
  try {
    final Robot awtRobot = new Robot();
    // the x+10 motion is needed to let native functions register a drag
    // detect. It did not work under Windows
    // otherwise and has been reported to be required for linux, too.
    // But I could not test that.
    syncExec(new VoidResult() {
      @Override
      public void run() {
        awtRobot.mouseMove(source.x, source.y);
        awtRobot.mousePress(InputEvent.BUTTON1_MASK);
        awtRobot.mouseMove(source.x + DRAG_THRESHOLD, source.y);
      }
    });

    /* drag delay */
    SWTUtils.sleep(DRAG_DELAY);

    syncExec(new VoidResult() {
      @Override
      public void run() {
        awtRobot.mouseMove(dest.x + DRAG_THRESHOLD, dest.y);
        awtRobot.mouseMove(dest.x, dest.y);
      }
    });

    /* drop delay */
    SWTUtils.sleep(DRAG_DELAY);

    syncExec(new VoidResult() {
      @Override
      public void run() {
        awtRobot.mouseRelease(InputEvent.BUTTON1_MASK);
      }
    });
  } catch (final AWTException e) {
    // log.error(e.getMessage(), e);
    throw new IllegalStateException(e);
  }
}
项目:emfstore-rest    文件:AbstractUIControllerTestWithCommit.java   
protected ESPrimaryVersionSpec updateToVersion() {
    SWTBotPreferences.PLAYBACK_DELAY = 100;
    didUpdate = false;

    final ESUpdateObserver updateObserver = createUpdateObserver();
    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().register(updateObserver);

    UIThreadRunnable.asyncExec(new VoidResult() {
        public void run() {
            final UIUpdateProjectToVersionController updateProjectController = new UIUpdateProjectToVersionController(
                bot.getDisplay().getActiveShell(),
                getCopy());
            updateProjectController.execute();
        }
    });

    Matcher<Shell> matcher = withText("Select a Version to update to");
    bot.waitUntil(waitForShell(matcher));
    bot.button("OK").click();

    matcher = withText("Update");
    bot.waitUntil(waitForShell(matcher));
    bot.button("OK").click();

    bot.waitUntil(new DefaultCondition() {
        // BEGIN SUPRESS CATCH EXCEPTION
        public boolean test() throws Exception {
            return didUpdate;
        }

        // END SUPRESS CATCH EXCEPTION

        public String getFailureMessage() {
            return "Update to version did not succeed.";
        }
    }, 600000);

    ESWorkspaceProviderImpl.getInstance();
    ESWorkspaceProviderImpl.getObserverBus().unregister(updateObserver);

    return getCopy().getBaseVersion();
}