org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot Java Examples

The following examples show how to use org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Close all non-main shells that are visible.
 *
 * @param bot
 *            the workbench bot
 */
public static void closeSecondaryShells(SWTWorkbenchBot bot) {
    SWTBotShell[] shells = bot.shells();
    SWTBotShell mainShell = getMainShell(shells);
    if (mainShell == null) {
        return;
    }

    // Close all non-main shell but make sure we don't close an invisible
    // shell such the special "limbo shell" that Eclipse needs to work
    Arrays.stream(shells)
            .filter(shell -> shell != mainShell)
            .filter(s -> !s.widget.isDisposed())
            .filter(SWTBotShell::isVisible)
            .peek(shell -> log.debug(MessageFormat.format("Closing lingering shell with title {0}", shell.getText())))
            .forEach(SWTBotShell::close);
}
 
Example #2
Source File: ProjectExplorerRefreshTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test Class setup
 *
 * @throws Exception
 *             on error
 */
@BeforeClass
public static void init() throws Exception {
    TestDirectoryStructureUtil.generateTraceStructure(TEST_TRACES_PATH);

    SWTBotUtils.initialize();

    /* Set up for SWTBot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
    fBot = new SWTWorkbenchBot();

    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();

    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME);
    fTracesFolder = new File(Objects.requireNonNull(TmfProjectRegistry.getProject(project, true).getTracesFolder()).getResource().getLocation().toOSString());

    createCProject(C_PROJECT_NAME);
    setTracingNature(C_PROJECT_NAME);
    IProject cProject = ResourcesPlugin.getWorkspace().getRoot().getProject(C_PROJECT_NAME);
    fCProjectFolder = cProject.getLocation().toFile();
}
 
Example #3
Source File: ViewsResponseTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Things to setup
 */
@Before
public void beforeClass() {

    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBotTest");
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 60000; /* 60 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotUtils.closeView("welcome", bot);
    /* Prepare the workspace */
    prepareWorkspace();
    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();

    /* Create project */
    SWTBotUtils.createProject(PROJECT_NAME);
}
 
Example #4
Source File: TestInvalidCtfTrace.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Initialization
 */
@BeforeClass
public static void beforeClass() {
    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBot Thread"); // for the debugger
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    SWTBotUtils.createProject(PROJET_NAME);

}
 
Example #5
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test Class setup
 *
 * @throws IOException
 */
@BeforeClass
public static void init() throws IOException {
    TestDirectoryStructureUtil.generateTraceStructure(TEST_TRACES_PATH);

    SWTBotUtils.initialize();

    /* Set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
    fBot = new SWTWorkbenchBot();

    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    importCustomParsers();
}
 
Example #6
Source File: AbstractNewWizardTest.java    From aCute with Eclipse Public License 2.0 6 votes vote down vote up
protected SWTBotShell openWizard() {
	bot = new SWTWorkbenchBot();
	bot.menu("File").menu("New").menu("Other...").click();
	bot.waitUntil(Conditions.shellIsActive("New"));
	SWTBotShell shell = bot.shell("New");
	shell.activate();
	bot.tree().expandNode(".NET Core").select(".NET Core Project");
	bot.button("Next >").click();

	while (!bot.list(0).itemAt(0).equals("No available templates") && !bot.list(0).isEnabled()) {
		try {
			Thread.sleep(500);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	return shell;
}
 
Example #7
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static void createUiBinder(final SWTWorkbenchBot bot, String projectName,
    String packageName, String name, boolean generateSampleContent, boolean generateComments) {
  // Open the list of new project wizards
  bot.menu("File").menu("New").menu("Other...").click();

  // Select the Web App project wizard
  SWTBotTree projectSelectionTree = bot.tree();
  SWTBotTreeItem projectSelectionGoogleTreeItem = SwtBotTreeActions
      .getUniqueTreeItem(bot, projectSelectionTree, "GWT Classes", "UiBinder").expand();
  SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "UiBinder");
  bot.button("Next >").click();

  // Configure the UiBinder and then create it
  String sourceFolder = projectName + "/" + SOURCE_FOLDER;
  bot.textWithLabel("Source folder:").setText(sourceFolder);
  bot.textWithLabel("Package:").setText(packageName);
  bot.textWithLabel("Name:").setText(name);

  SwtBotUtils.setCheckBox(bot.checkBox("Generate sample content"),
      generateSampleContent);
  SwtBotUtils.setCheckBox(bot.checkBox("Generate comments"), generateComments);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
 
Example #8
Source File: MarkerSetSwtBotTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set up the test context and environment
 */
@BeforeClass
public static void setUp() {
    SWTBotUtils.initialize();

    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 10000; /* 10 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fBot = new SWTWorkbenchBot();

    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    WaitUtils.waitForJobs();

    final CtfTestTrace cygProfile = CtfTestTrace.CYG_PROFILE;
    LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(cygProfile);
    fStart = ((CtfTmfTrace) trace).getStartTime().toNanos();
    fFullRange = new TmfTimeRange(TmfTimestamp.fromNanos(fStart), TmfTimestamp.fromNanos(fStart + 100l));
    final File file = new File(trace.getPath());
    LttngUstTestTraceUtils.dispose(cygProfile);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, file.getAbsolutePath(), UST_ID);
    SWTBotUtils.openView(FlameChartView.ID);
    fViewBot = fBot.viewByTitle("Flame Chart");
    WaitUtils.waitForJobs();
}
 
Example #9
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Waits until the node collapses.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (node.isExpanded()) {
    node.collapse();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return !node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to collapse";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);
    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.collapse();
    }
  }
}
 
Example #10
Source File: PluginTest.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Import cpp project into workspace, and setup SWTBot.
 */
@BeforeClass
public static void setup() {

    bot = new SWTWorkbenchBot();

    Path file = null;
    try {
        file = Utils.loadFileFromBundle("org.codechecker.eclipse.rcp.it.tests", Utils.RES + CPP_PROJ);
    } catch (URISyntaxException | IOException e) {
        e.printStackTrace();
    }

    Utils.copyFolder(file,
            Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator));

    File project = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator
            + CPP_PROJ + File.separator + ".project");
    try {
        ProjectImporter.importProject(project.toPath(), CPP_PROJ);
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
}
 
Example #11
Source File: TestImportExportPackageWizard.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTBotUtils.initialize();
    Thread.currentThread().setName(SWT_BOT_THREAD_NAME); // for the debugger
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();

}
 
Example #12
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates an experiment
 *
 * @param bot
 *            a given workbench bot
 * @param projectName
 *            the name of the project, creates the project if needed
 * @param expName
 *            the experiment name
 */
public static void createExperiment(SWTWorkbenchBot bot, String projectName, final @NonNull String expName) {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true);
    TmfExperimentFolder expFolder = tmfProject.getExperimentsFolder();
    assertNotNull(expFolder);
    NewExperimentOperation operation = new NewExperimentOperation(expFolder, expName);
    operation.run(new NullProgressMonitor());

    bot.waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            TmfExperimentElement experiment = expFolder.getExperiment(expName);
            return experiment != null;
        }

        @Override
        public String getFailureMessage() {
            return "Experiment (" + expName + ") couldn't be created";
        }
    });
}
 
Example #13
Source File: SwtBotUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create a java project with the specified project name. This function opens up the Java
 * Perspective.
 *
 * @param bot The current SWTWorkbenchBot object
 * @param projectName Name of java project to be created
 */
public static void createJavaProject(SWTWorkbenchBot bot, String projectName) {
  // Open Java Perspective
  bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();

  // Open the list of new project wizards
  bot.menu("File").menu("New").menu("Project...").click();

  // Select the Java project
  SWTBotTree projectSelectionTree = bot.tree();
  SWTBotTreeItem projectSelectionTreeItem =
      SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project");
  SwtBotTreeActions.selectTreeItem(bot, projectSelectionTreeItem, "Java Project");

  bot.button("Next >").click();

  // Configure the project and then create it
  bot.textWithLabel("Project name:").setText(projectName);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
 
Example #14
Source File: SwtBotProjectCreation.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create a GWT project from Maven Archetype.
 *
 * Archetype: https://github.com/branflake2267/Archetypes/tree/master/archetypes/gwt-basic
 */
public static void createMavenGwtProjectIsCreated2(SWTWorkbenchBot bot, String projectName, String packageName) {
  // And create a maven project using an archetype
  String groupId = packageName;
  String artifactId = projectName;
  String archetypeGroupId = "com.github.branflake2267.archetypes";
  String archetypeArtifactId = "gwt-basic-archetype";
  String archetypeVersion = "2.0-SNAPSHOT";
  String archetypeUrl = "https://oss.sonatype.org/content/repositories/snapshots";

  SwtBotProjectActions.createMavenProjectFromArchetype(bot, groupId, artifactId, packageName,
      archetypeGroupId, archetypeArtifactId, archetypeVersion, archetypeUrl);

  // And wait for the project to finish setting up
  SwtBotWorkbenchActions.waitForIdle(bot);
}
 
Example #15
Source File: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected static void fileNew(final SWTWorkbenchBot it, final String newWhat) {
  int retries = 3;
  ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, retries, true);
  for (final Integer i : _doubleDotLessThan) {
    try {
      it.menu("File").menu("New").menu(newWhat).click();
      return;
    } catch (final Throwable _t) {
      if (_t instanceof WidgetNotFoundException) {
        final WidgetNotFoundException e = (WidgetNotFoundException)_t;
        if (((i).intValue() == (retries - 1))) {
          throw e;
        }
        String _message = e.getMessage();
        String _plus = ("failed: " + _message);
        InputOutput.<String>println(_plus);
        InputOutput.<String>println("retrying...");
        it.sleep(1000);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
}
 
Example #16
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the specified project. Throws a WidgetNotFoundException if the 'Package Explorer' or
 * 'Project Explorer' view cannot be found or if the specified project cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to select.
 * @return the tree
 */
public static SWTBotTreeItem selectProject(final SWTWorkbenchBot bot, String projectName) {
  /*
   * Choose either the Package Explorer View or the Project Explorer view. Eclipse 3.3 and 3.4
   * start with the Java Perspective, which has the Package Explorer View open by default, whereas
   * Eclipse 3.5 starts with the Resource Perspective, which has the Project Explorer View open.
   */
  SWTBotView explorer = getPackageExplorer(bot);
  for (SWTBotView view : bot.views()) {
    if (view.getTitle().equals("Package Explorer")
        || view.getTitle().equals("Project Explorer")) {
      explorer = view;
      break;
    }
  }

  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  return new SWTBotTree(explorerTree).getTreeItem(projectName).select();
}
 
Example #17
Source File: SystemCallLatencyStatisticsTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Opens a latency table
 */
@Before
public void createTree() {
    /*
     * Open latency view
     */
    SWTBotUtils.openView(PRIMARY_VIEW_ID, SECONDARY_VIEW_ID);
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotView viewBot = bot.viewById(PRIMARY_VIEW_ID);
    final IViewReference viewReference = viewBot.getViewReference();
    IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
        @Override
        public IViewPart run() {
            return viewReference.getView(true);
        }
    });
    assertTrue("Could not instanciate view", viewPart instanceof SegmentStoreStatisticsView);
    fTreeBot = viewBot.bot().tree();
    assertNotNull(fTreeBot);
}
 
Example #18
Source File: RCPTestSetupHelper.java    From tlaplus with MIT License 6 votes vote down vote up
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;
			}
		}
	});
}
 
Example #19
Source File: CallGraphDensityViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Setup for the test
 */
@Before
public void before() {
    fBot = new SWTWorkbenchBot();
    SWTBotUtils.openView(CALLGRAPHDENSITY_ID);
    SWTBotView view = fBot.viewById(CALLGRAPHDENSITY_ID);
    assertNotNull(view);
    fView = view;
    CallGraphDensityView funcDensityView = UIThreadRunnable.syncExec((Result<CallGraphDensityView>) () -> {
        IViewPart viewRef = fView.getViewReference().getView(true);
        return (viewRef instanceof CallGraphDensityView) ? (CallGraphDensityView) viewRef : null;
    });
    assertNotNull(funcDensityView);
    fTableBot = fView.bot().table();
    assertNotNull(fTableBot);
    fDensityViewer = funcDensityView.getDensityViewer();
    assertNotNull(fDensityViewer);
    fLatch = new CountDownLatch(1);
    fDensityViewer.removeDataListener(fSyncListener);
    fDensityViewer.addDataListener(fSyncListener);
    fTableViewer = funcDensityView.getTableViewer();
    assertNotNull(fTableViewer);
    SWTBotUtils.maximize(funcDensityView);
    fFuncDensityView = funcDensityView;
    fDensityViewer.setNbPoints(100);
}
 
Example #20
Source File: SystemCallLatencyStatisticsTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test with an actual trace, this is more of an integration test than a
 * unit test. This test is a slow one too. If some analysis are not well
 * configured, this test will also generates null pointer exceptions. These
 * are will be logged.
 *
 * @throws IOException
 *             trace not found?
 * @throws SecurityException
 *             Reflection error
 * @throws NoSuchMethodException
 *             Reflection error
 * @throws IllegalArgumentException
 *             Reflection error
 */
@Test
public void testWithTrace() throws IOException, NoSuchMethodException, SecurityException, IllegalArgumentException {
    String tracePath = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL())).getAbsolutePath();
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotView view = bot.viewById(PRIMARY_VIEW_ID);
    SWTBotUtils.closeViewById(PRIMARY_VIEW_ID, fBot);

    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
    WaitUtils.waitForJobs();
    createTree();
    WaitUtils.waitForJobs();
    SWTBotTreeItem totalEntry = fTreeBot.getTreeItem("bug446190").getNode("Total");
    validate(totalEntry, "Total", "1 µs", "5.904 s", "15.628 ms", "175.875 ms", "1801");
    assertEquals(55, totalEntry.getNodes().size());
    validate(totalEntry.getNode(2), "select", "13.6 µs", "1.509 s", "192.251 ms", "386.369 ms", "58");
    validate(totalEntry.getNode(3), "poll", "6.3 µs", "6.8 µs", "6.55 µs", "---", "2");
    validate(totalEntry.getNode(5), "set_tid_address", "2.3 µs", "2.3 µs", "2.3 µs", "---", "1");
    validate(totalEntry.getNode(7), "pipe", "27.9 µs", "29.7 µs", "28.8 µs", "---", "2");
    testToTsv(view);
    SWTBotMenu menuBot = view.viewMenu().menu("Export to TSV...");
    assertTrue(menuBot.isEnabled());
    assertTrue(menuBot.isVisible());

    fBot.closeAllEditors();
    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
}
 
Example #21
Source File: XYChartViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Put things back the way they were
 */
@AfterClass
public static void afterClass() {
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    bot.closeAllEditors();
    fLogger.removeAllAppenders();
}
 
Example #22
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens the Properties dialog for a given project.
 *
 * This method assumes that either the Package Explorer or Project Explorer view is visible.
 */
public static void openProjectProperties(final SWTWorkbenchBot bot, String projectName) {
  selectProject(bot, projectName);

  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      // Open the Project Properties menu via the File menu
      SWTBotMenu fileMenu = bot.menu("File");
      fileMenu.menu("Properties").click();
    }
  });
}
 
Example #23
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Switching to a new Perspective.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param perspective
 *          the new perspective to open, must not be {@code null}
 */
public static void switchPerspective(final SWTWorkbenchBot bot, final String perspective) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(perspective, "perspective");
  // Change the perspective via the Open Perspective dialog
  bot.menu("Window").menu("Open Perspective").menu("Other...").click();
  final SWTBotShell shell = bot.shell("Open Perspective");
  shell.activate();

  // select the dialog
  bot.table().select(perspective);
  bot.button("OK").click();
}
 
Example #24
Source File: RawTextEditorTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTBotUtils.initialize();
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}
 
Example #25
Source File: Views.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IPackageExplorerView packageExplorerView() throws RemoteException {

  SWTWorkbenchBot bot = new SWTWorkbenchBot();
  RemoteWorkbenchBot.getInstance().openViewById(VIEW_PACKAGE_EXPLORER_ID);
  bot.viewByTitle(VIEW_PACKAGE_EXPLORER).show();
  return PackageExplorerView.getInstance().setView(bot.viewByTitle(VIEW_PACKAGE_EXPLORER));
}
 
Example #26
Source File: AllTests.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Import cpp project into workspace, and setup SWTBot.
 *
 */
@BeforeClass
public static void setup() {
    //clearWs();
    bot = new SWTWorkbenchBot();
    GuiUtils.closeWelcomeIfPresent(bot);
    GuiUtils.changePerspectiveTo(GuiUtils.C_CPP_PESPECTIVE, bot);
}
 
Example #27
Source File: RenameJavaClassSwtBotTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void renameJavaClass() {
  SWTWorkbenchBot _bot = this.getBot();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package test");
  _builder.newLine();
  _builder.append("class XtendClass extends JavaClass {");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final SWTBotEclipseEditor xtendEditor = SwtBotProjectHelper.newXtendEditor(_bot, "XtendClass", "test", _builder);
  SWTWorkbenchBot _bot_1 = this.getBot();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("package test;");
  _builder_1.newLine();
  _builder_1.append("public class ?JavaClass? {}");
  _builder_1.newLine();
  final SWTBotEclipseEditor javaEditor = SwtBotProjectHelper.newJavaEditor(_bot_1, "JavaClass", "test", _builder_1);
  this.renameInJavaEditor(javaEditor, "NewJavaClass", "Rename Type");
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("package test");
  _builder_2.newLine();
  _builder_2.append("class XtendClass extends NewJavaClass {");
  _builder_2.newLine();
  _builder_2.append("}");
  _builder_2.newLine();
  this.assertEquals(_builder_2, xtendEditor.getText());
  Assert.assertFalse(xtendEditor.isDirty());
  StringConcatenation _builder_3 = new StringConcatenation();
  _builder_3.append("package test;");
  _builder_3.newLine();
  _builder_3.append("public class NewJavaClass {}");
  _builder_3.newLine();
  this.assertEquals(_builder_3, javaEditor.getText());
  Assert.assertFalse(javaEditor.isDirty());
  this.assertEquals("NewJavaClass.java", javaEditor.getTitle());
}
 
Example #28
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns {@code true} if the SWTBot finds the specified window.
 *
 * @param bot
 *          the {@link SWTWorkbenchBot}, must not be {@code null}
 * @param windowName
 *          the name of the window to search for, must not be {@code null}
 * @return {@code true} if a window was found, {@code false} otherwise
 */
public static boolean checkOpenWindow(final SWTWorkbenchBot bot, final String windowName) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(windowName, "windowName");
  Boolean windowFound = false;
  try {
    final SWTBotShell shell = bot.shell(windowName);
    shell.isActive();
    windowFound = true;
  } catch (WidgetNotFoundException exception) {
    throw new WrappedException("Error during searching for window", exception);
  }
  return windowFound;
}
 
Example #29
Source File: SwtBotSdkActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private static void setupSdk(final SWTWorkbenchBot bot, String treeItemText,
    String sdkDirEnvVariableName, String sdkDisplayName) {
  SwtBotWorkbenchActions.openPreferencesDialog(bot);

  SWTBotTreeItem prefGwtTreeItem =
      SwtBotTreeActions.getUniqueTreeItem(bot, bot.tree(),
          SwtBotProjectActions.GWT_MENU_LABELS, "GWT Settings").expand();
  SwtBotTreeActions.selectTreeItem(bot, prefGwtTreeItem, treeItemText);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Add..."));

  // Remove, use the included sdks
  bot.textWithLabel("Installation directory:").setText(System.getenv(sdkDirEnvVariableName));
  bot.textWithLabel("Display name:").setText(sdkDisplayName);

  SWTBotButton okButton = bot.button("OK");
  if (okButton.isEnabled()) {
    // Close add SDK dialog
    SwtBotUtils.clickButtonAndWaitForWindowChange(bot, okButton);
  } else {
    // Already setup, in the case of running multiple tests together
    SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Cancel"));
  }

  // Close Preferences dialog
  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("OK"));
}
 
Example #30
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Before class, call by all subclassed
 */
@BeforeClass
public static void beforeClass() {

    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBotTest");
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
    fBot = new SWTWorkbenchBot();
    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}