예제 #1
0
 /** Before Test */
 @Override
 @Before
 public void before() {
   super.before();
   fViewBot = fBot.viewByTitle("Control Flow");
   fViewBot.show();
   fViewBot.setFocus();
 }
  /** Import a gzip trace */
  @Test
  public void testGzipImport() {
    final String traceType = "Test trace : TMF Tests";
    final String tracesNode = "Traces [1]";

    /*
     * Actual importing
     */
    openImportWizard();
    selectImportFromArchive(fGzipTrace.getAbsolutePath());
    selectFolder(ROOT_FOLDER);
    SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
    assertFalse(checkBox.isEnabled());
    SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
    comboBox.setSelection(traceType);
    importFinish();
    /*
     * Remove .gz extension
     */
    assertNotNull(fGzipTrace);
    String name = fGzipTrace.getName();
    assertNotNull(name);
    assertTrue(name.length() > 3);
    String traceName = name.substring(0, name.length() - 3);
    assertNotNull(traceName);
    assertFalse(traceName.isEmpty());

    /*
     * Open trace
     */
    SWTBotView projectExplorer = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorer.setFocus();
    final SWTBotTree tree = projectExplorer.bot().tree();
    /*
     * This appears to be problematic due to the length of the file name and
     * the resolution in our CI.
     */
    tree.expandNode(PROJECT_NAME, true);
    SWTBotTreeItem treeItem = tree.getTreeItem(PROJECT_NAME);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(tracesNode, treeItem));
    treeItem = treeItem.getNode(tracesNode);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(traceName, treeItem));
    treeItem = treeItem.getNode(traceName);
    treeItem.doubleClick();
    SWTBotUtils.waitForJobs();
    /*
     * Check results
     */
    SWTBotTable editor = fBot.activeEditor().bot().table();
    String c22 = editor.cell(2, 2);
    String c10 = editor.cell(1, 0);
    assertEquals("Type-1", c22);
    assertEquals("", c10);
  }
예제 #3
0
  @Test
  // Verify we can build and run the info MakeTarget tool
  public void t1canBuildAndAccessInfoTarget() throws Exception {
    clickProjectContextMenu("Build Project");

    // Wait until the project is built
    SWTBotShell shell = bot.shell("Build Project");
    bot.waitUntil(Conditions.shellCloses(shell), 120000);

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    assertNotNull(workspace);
    IWorkspaceRoot root = workspace.getRoot();
    assertNotNull(root);
    IProject project = root.getProject(projectName);
    assertNotNull(project);
    IPath path = project.getLocation();
    path = path.append("config.status");
    File f = new File(path.toOSString());
    assertTrue(f.exists());
    f = new File(path.toOSString());
    assertTrue(f.exists());

    projectExplorer.bot().tree().getTreeItem(projectName).select();
    clickContextMenu(projectExplorer.bot().tree().select(projectName), "Make Targets", "Build...");
    shell = bot.shell("Make Targets");
    shell.activate();
    bot.table().getTableItem("info").select();
    bot.button("Build").click();

    SWTBotView consoleView = viewConsole("CDT Build Console");
    Pattern p = Pattern.compile(".*make info.*", Pattern.DOTALL);
    bot.waitUntil(consoleTextMatches(consoleView, p));

    // Make Targets using right-click on project.
    clickProjectContextMenu("Make Targets", "Build...");
    shell = bot.shell("Make Targets");
    shell.activate();
    bot.table().getTableItem("check").select();
    bot.button("Build").click();
    consoleView = bot.viewByPartName("Console");
    consoleView.setFocus();
    p = Pattern.compile(".*make check.*Making check in src.*", Pattern.DOTALL);
    bot.waitUntil(consoleTextMatches(consoleView, p));
  }
  /** Test show type action on VSM and hide type action. */
  public void testShowHideTypeAction() {
    SWTBotView projectExplorer = bot.viewByTitle("Model Explorer");
    projectExplorer.setFocus();
    projectExplorer.bot().tree().expandNode(getProjectName()).expandNode(VSM_FILE).doubleClick();
    SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.setFocus();

    String nodeLabel = "platform:/resource/" + getProjectName() + "/" + VSM_FILE;
    SWTBotMenu contextualMenu =
        activeEditor
            .bot()
            .tree()
            .expandNode(nodeLabel)
            .expandNode(GROUP)
            .expandNode(VIEWPOINT_NAME)
            .expandNode(REPRESENTATION_NAME)
            .contextMenu(SHOW_TYPE);
    contextualMenu.click();
    contextualMenu =
        activeEditor
            .bot()
            .tree()
            .expandNode(nodeLabel)
            .expandNode(TYPED_GROUP)
            .expandNode(TYPED_VIEWPOINT_NAME)
            .expandNode(TYPED_REPRESENTATION_NAME)
            .contextMenu(HIDE_TYPE);
    contextualMenu.click();
    contextualMenu =
        activeEditor
            .bot()
            .tree()
            .expandNode(nodeLabel)
            .expandNode(GROUP)
            .expandNode(VIEWPOINT_NAME)
            .expandNode(REPRESENTATION_NAME)
            .contextMenu(SHOW_TYPE);
  }
예제 #5
0
 /** Test color by making all events yellow */
 @Test
 public void testYellow() {
   SWTBotView viewBot = fBot.viewById(ColorsView.ID);
   viewBot.setFocus();
   final String insert = "Insert new color setting";
   final String increasePriority = "Increase priority";
   final String decreasePriority = "Decrease priority";
   final String delete = "Delete color setting";
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(increasePriority).click();
   viewBot.toolbarButton(decreasePriority).click();
   viewBot.toolbarButton(delete).click();
   viewBot.bot().label(0).setFocus();
   viewBot.toolbarButton(delete).click();
   viewBot.bot().label(0).setFocus();
   viewBot.toolbarButton(delete).click();
   final RGB foreground = new RGB(0, 0, 0);
   final RGB background = new RGB(255, 255, 0);
   // Simulate the side effects of picking a color because we cannot
   // control native Color picker dialog in SWTBot.
   final ColorSetting[] cs = new ColorSetting[1];
   UIThreadRunnable.syncExec(
       new VoidResult() {
         @Override
         public void run() {
           cs[0] = new ColorSetting(foreground, background, foreground, new PassAll());
           ColorSettingsManager.setColorSettings(cs);
         }
       });
   final SWTBotTable eventsEditor = SWTBotUtils.activeEventsEditor(fBot).bot().table();
   // should fix race condition of loading the trace
   SWTBotUtils.waitForJobs();
   eventsEditor.select(2);
   final SWTBotTableItem tableItem = eventsEditor.getTableItem(2);
   RGB fgc =
       UIThreadRunnable.syncExec(
           new Result<RGB>() {
             @Override
             public RGB run() {
               return tableItem.widget.getForeground().getRGB();
             }
           });
   RGB bgc =
       UIThreadRunnable.syncExec(
           new Result<RGB>() {
             @Override
             public RGB run() {
               return tableItem.widget.getBackground().getRGB();
             }
           });
   assertEquals("Fg", foreground, fgc);
   assertEquals("Bg", background, bgc);
   // reset color settings
   UIThreadRunnable.syncExec(
       new VoidResult() {
         @Override
         public void run() {
           ColorSettingsManager.setColorSettings(new ColorSetting[0]);
         }
       });
 }
 /** Open the VSM */
 private void openVSM() {
   SWTBotView projectExplorer = bot.viewByTitle("Model Explorer");
   projectExplorer.setFocus();
   SWTBot projectExplorerBot = projectExplorer.bot();
   projectExplorerBot.tree().expandNode(getProjectName()).expandNode(VSM_FILE).doubleClick();
 }