当前位置: 首页>>代码示例>>Java>>正文


Java SWTWorkbenchBot类代码示例

本文整理汇总了Java中org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot的典型用法代码示例。如果您正苦于以下问题:Java SWTWorkbenchBot类的具体用法?Java SWTWorkbenchBot怎么用?Java SWTWorkbenchBot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SWTWorkbenchBot类属于org.eclipse.swtbot.eclipse.finder包,在下文中一共展示了SWTWorkbenchBot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
public static GW4EProject create (SWTWorkbenchBot bot,String gwproject) throws CoreException, FileNotFoundException  {
	GW4EProject project = new GW4EProject(bot, gwproject);
	project.resetToJavPerspective();
	project.createProject();
	
	File path = new File("src/test/resources/petclinic");
	IContainer destFolder = (IContainer) ResourceManager.getResource(gwproject+ "/src/test/resources");
	ImportHelper.copyFiles(path,destFolder);
	
	String[] folders = PreferenceManager.getAuthorizedFolderForGraphDefinition();
	String[] temp = new String[2];
	temp[0] = gwproject;
	temp[1] = folders[1];
	project.generateSource(temp);
	bot.waitUntil(new EditorOpenedCondition(bot, "VeterinariensSharedStateImpl.java"), 3 * 60000);
	project.waitForBuildAndAssertNoErrors();
	return project;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:19,代码来源:PetClinicProject.java

示例2: openNewGraphWalkerModel

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
public static void openNewGraphWalkerModel(SWTWorkbenchBot bot) {
	
	SWTBotMenu all = bot.menu("File").menu("New");
	
	/*
	Function<String, String>   f =  new Function<String, String> () {

		@Override
		public String apply(String t) {
			return t;
		}
		
	};
	all.menuItems().stream().map(f);
	*/
	
	bot.menu("File").menu("New").menu("GW4E Model").click();
	bot.waitUntil(new ShellActiveCondition("GW4E"));
	SWTBotShell shell = bot.shell("GW4E");
	assertTrue(shell.isOpen());
	shell.bot().button("Cancel").click();
	bot.waitUntil(Conditions.shellCloses(shell));
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:GW4EPerspective.java

示例3: hasErrorsInProblemsView

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
public static boolean hasErrorsInProblemsView(SWTWorkbenchBot bot) {
	// Open Problems View by Window -> show view -> Problems
	bot.menu("Window").menu("Show View").menu("Problems").click();

	SWTBotView view = bot.viewByTitle("Problems");
	view.show();
	SWTBotTree tree = view.bot().tree();

	for (SWTBotTreeItem item : tree.getAllItems()) {
		String text = item.getText();
		if (text != null && text.startsWith("Errors")) {
			return true;
		}
	}

	return false;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:18,代码来源:ProblemView.java

示例4: openPreferencesDialog

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Opens the preferences dialog from the main Eclipse window.
 * <p>
 * Note: There are some platform-specific intricacies that this abstracts
 * away.
 */
public static void openPreferencesDialog(final SWTWorkbenchBot bot) {
  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      if (SwtBotTestingUtilities.isMac()) {
        // TODO: Mac has "Preferences..." under the "Eclipse" menu item.
        // However,
        // the "Eclipse" menu item is a system menu item (like the Apple menu
        // item), and can't be reached via SWTBot.
        openPreferencesDialogViaEvents(bot);
      } else {
        SWTBotMenu windowMenu = bot.menu("Window");
        windowMenu.menu("Preferences").click();
      }
    }
  });
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:24,代码来源:SwtBotWorkbenchActions.java

示例5: waitUntilTreeItemHasChild

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Wait until a tree item contains a child with the given text.
 * 
 * @throws TimeoutException if the child does not appear within the default timeout
 */
public static void waitUntilTreeItemHasChild(SWTWorkbenchBot bot, final SWTBotTreeItem treeItem,
    final String childText) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public String getFailureMessage() {
      System.err.println(treeItem + ": expanded? " + treeItem.isExpanded());
      for (SWTBotTreeItem childNode : treeItem.getItems()) {
        System.err.println("    " + childNode);
      }
      return "Tree item never appeared";
    }

    @Override
    public boolean test() throws Exception {
      return treeItem.getNodes().contains(childText);
    }
  });
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:24,代码来源:SwtBotTreeUtilities.java

示例6: waitUntilTreeContainsText

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Wait until the tree item contains the given text with the timeout specified.
 */
public static void waitUntilTreeContainsText(SWTWorkbenchBot bot,
                                             final SWTBotTreeItem treeItem,
                                             final String text,
                                             long timeout) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public boolean test() throws Exception {
      return treeItem.getText().contains(text);
    }

    @Override
    public String getFailureMessage() {
      return "Text never appeared";
    }
  }, timeout);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:20,代码来源:SwtBotTreeUtilities.java

示例7: createJavaClass

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Creates a Java class with the specified name.
 *
 * @param projectName the name of the project the class should be created in
 * @param sourceFolder the name of the source folder in which the class should be created.
 *        Typically "src" for normal Java projects, or "src/main/java" for Maven projects
 * @param packageName the name of the package the class should be created in
 * @param className the name of the class to be created
 */
public static void createJavaClass(final SWTWorkbenchBot bot, String sourceFolder,
    String projectName,
    String packageName, final String className) {
  SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName);
  selectProjectItem(project, sourceFolder, packageName).select();
  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class");
      new SWTBotMenu(menuItem).click();
    }
  });

  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      bot.activeShell();
      bot.textWithLabel("Name:").setText(className);
      SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish"));
    }
  });
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:32,代码来源:SwtBotProjectActions.java

示例8: openImportProjectsWizard

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
private static void openImportProjectsWizard(SWTWorkbenchBot bot,
    String wizardCategory, String importWizardName) {
  for (int tries = 1; true; tries++) {
    SWTBotShell shell = null;
    try {
      bot.menu("File").menu("Import...").click();
      shell = bot.shell("Import");
      shell.activate();

      SwtBotTreeUtilities.waitUntilTreeHasItems(bot, bot.tree());
      SWTBotTreeItem treeItem = bot.tree().expandNode(wizardCategory);
      SwtBotTreeUtilities.waitUntilTreeItemHasChild(bot, treeItem, importWizardName);
      treeItem.select(importWizardName);
      break;
    } catch (TimeoutException e) {
      if (tries == 2) {
        throw e;
      } else if (shell != null) {
        shell.close();
      }
    }
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:24,代码来源:SwtBotAppEngineActions.java

示例9: importMavenProject

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Import a Maven project from a zip file
 */
public static IProject importMavenProject(SWTWorkbenchBot bot, String projectName,
    File extractedLocation) {

  openImportProjectsWizard(bot, "Maven", "Existing Maven Projects");
  bot.button("Next >").click();

  bot.comboBoxWithLabel("Root Directory:").setText(extractedLocation.getAbsolutePath());
  bot.button("Refresh").click();

  try {
    SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish"));
  } catch (TimeoutException ex) {
    System.err.println("FATAL: timed out while waiting for the wizard to close. Forcibly killing "
        + "all shells: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1925");
    System.err.println("FATAL: You will see tons of related errors: \"Widget is disposed\", "
        + "\"Failed to execute runnable\", \"IllegalStateException\", etc.");
    SwtBotWorkbenchActions.killAllShells(bot);
    throw ex;
  }
  SwtBotTimeoutManager.resetTimeout();
  IProject project = waitUntilFacetedProjectExists(bot, getWorkspaceRoot().getProject(projectName));
  SwtBotWorkbenchActions.waitForProjects(bot, project);
  return project;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:28,代码来源:SwtBotAppEngineActions.java

示例10: assertShellWithDataTypeVisible

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Tests if a shell with a specific type of data contained (e.g. Window).
 * 
 * @param bot
 *          to use
 * @param clazz
 *          class of data contained to check for
 */
@SuppressWarnings("rawtypes")
public static void assertShellWithDataTypeVisible(final SWTWorkbenchBot bot, final Class clazz) {
  bot.waitUntil(Conditions.waitForShell(new BaseMatcher<Shell>() {
    @SuppressWarnings("unchecked")
    public boolean matches(final Object item) {
      return UIThreadRunnable.syncExec(new Result<Boolean>() {
        public Boolean run() {
          if (item instanceof Shell) {
            Object shellData = ((Shell) item).getData();
            if (shellData != null) {
              return clazz.isAssignableFrom(shellData.getClass());
            }
          }
          return false;
        }
      });
    }

    public void describeTo(final Description description) {
      description.appendText("Shell for " + clazz.getName());
    }
  }));
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:32,代码来源:ShellUiTestUtil.java

示例11: openView

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Open view.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param category
 *          the category, must not be {@code null}
 * @param view
 *          the name of the view, must not be {@code null}
 */
public static void openView(final SWTWorkbenchBot bot, final String category, final String view) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(category, "category");
  Assert.isNotNull(view, ARGUMENT_VIEW);
  bot.menu("Window").menu("Show View").menu("Other...").click();
  bot.shell("Show View").activate();
  final SWTBotTree tree = bot.tree();

  for (SWTBotTreeItem item : tree.getAllItems()) {
    if (category.equals(item.getText())) {
      CoreSwtbotTools.waitForItem(bot, item);
      final SWTBotTreeItem[] node = item.getItems();

      for (SWTBotTreeItem swtBotTreeItem : node) {
        if (view.equals(swtBotTreeItem.getText())) {
          swtBotTreeItem.select();
        }
      }
    }
  }
  assertTrue("View or Category found", bot.button().isEnabled());
  bot.button("OK").click();
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:34,代码来源:CoreSwtbotTools.java

示例12: safeBlockingCollapse

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * 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();
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:34,代码来源:CoreSwtbotTools.java

示例13: setUp

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
/**
 * Pre flight initialization (run once for each test _case_)
 */
@Before
public void setUp() throws Exception {
	// Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc
	// see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb
	Display.getDefault().syncExec(new Runnable() {
		public void run() {
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
		}
	});
	
	bot = new SWTWorkbenchBot();

	// Wait for the Toolbox shell to be available
	final Matcher<Shell> withText = withText("TLA+ Toolbox");
	bot.waitUntil(Conditions.waitForShell(withText), 30000);
	
	// Wait for the Toolbox UI to be fully started.
	final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File");
	final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class),
			withMnemonic);
	bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:26,代码来源:AbstractTest.java

示例14: beforeClass

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	RCPTestSetupHelper.beforeClass();
	
	// Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc
	// see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb
	Display.getDefault().syncExec(new Runnable() {
		public void run() {
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
		}
	});
	
	bot = new SWTWorkbenchBot();

	// Wait for the Toolbox shell to be available
	final Matcher<Shell> withText = withText("TLA+ Toolbox");
	bot.waitUntil(Conditions.waitForShell(withText), 30000);
	
	// Wait for the Toolbox UI to be fully started.
	final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File");
	final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class),
			withMnemonic);
	bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:25,代码来源:DeleteSpecHandlerTest.java

示例15: beforeClass

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; //导入依赖的package包/类
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;
			}
		}
	});
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:18,代码来源:RCPTestSetupHelper.java


注:本文中的org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。