@BeforeClass public static void beforeClass() throws Exception { MockSystemReader mockSystemReader = new MockSystemReader(); SystemReader.setInstance(mockSystemReader); mockSystemReader.setProperty( Constants.GIT_CEILING_DIRECTORIES_KEY, ResourcesPlugin.getWorkspace() .getRoot() .getLocation() .toFile() .getParentFile() .getAbsoluteFile() .toString()); TestUtil.showExplorerView(); ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); }
private void assertVariable(String expected, String variableName, String argument) throws CoreException { IResource findMember = project.findMember(TEST_FILE); SWTBotView explorerView = TestUtil.showExplorerView(); final ISelectionProvider selectionProvider = explorerView.getViewReference().getView(true).getSite().getSelectionProvider(); final StructuredSelection structuredSelection = new StructuredSelection(findMember); PlatformUI.getWorkbench() .getDisplay() .syncExec( new Runnable() { @Override public void run() { selectionProvider.setSelection(structuredSelection); } }); IDynamicVariable dynamicVariable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable(variableName); String value = dynamicVariable.getValue(argument); assertEquals(expected, value); }
@Before public void setupViews() { TestUtil.showExplorerView(); sharingWizard = new SharingWizard(); }
/** * Link with editor, both ways * * @throws Exception */ @Test @Ignore("'Link with Selection' does not activate editor on selection change (bug 409722).") public void testLinkWithSelectionEditor() throws Exception { deleteAllProjects(); shareProjects(repositoryFile); SWTBotTree tree = getOrOpenView().bot().tree(); myRepoViewUtil.getRootItem(tree, repositoryFile).select(); // the selection should be root assertTrue(tree.selection().get(0, 0).startsWith(REPO1)); SWTBotView view = TestUtil.showExplorerView(); SWTBotTree projectExplorerTree = view.bot().tree(); SWTBotTreeItem item = getProjectItem(projectExplorerTree, PROJ1).expand().getNode(FOLDER).expand().getNode(FILE1); view.show(); item.doubleClick(); item = getProjectItem(projectExplorerTree, PROJ1).expand().getNode(FOLDER).expand().getNode(FILE2); view.show(); item.doubleClick(); // now we should have two editors // the selection should be still be root assertTrue(tree.selection().get(0, 0).startsWith(REPO1)); // activate the link with selection toggleLinkWithSelection(); bot.editorByTitle(FILE2).show(); // the selection should have changed to the latest editor TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE2, 10000); bot.editorByTitle(FILE1).show(); // selection should have changed TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000); // deactivate the link with editor toggleLinkWithSelection(); bot.editorByTitle(FILE2).show(); // the selection should be still be test.txt TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000); bot.editorByTitle(FILE1).show(); myRepoViewUtil .getWorkdirItem(tree, repositoryFile) .expand() .getNode(PROJ1) .expand() .getNode(FOLDER) .expand() .getNode(FILE2) .select(); // the editor should still be test.txt assertEquals(FILE1, bot.activeEditor().getTitle()); // activate again toggleLinkWithSelection(); // make sure focus is here // tried to remove this waitInUI but failed. // tried setting focus, waiting for focus, joining RepositoriesView // refresh job waitInUI(); myRepoViewUtil .getWorkdirItem(tree, repositoryFile) .expand() .getNode(PROJ1) .expand() .getNode(FOLDER) .expand() .getNode(FILE2) .select(); TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE2), 10000); myRepoViewUtil .getWorkdirItem(tree, repositoryFile) .expand() .getNode(PROJ1) .expand() .getNode(FOLDER) .expand() .getNode(FILE1) .select(); TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000); // deactivate the link with editor toggleLinkWithSelection(); myRepoViewUtil .getWorkdirItem(tree, repositoryFile) .expand() .getNode(PROJ1) .expand() .getNode(FOLDER) .expand() .getNode(FILE2) .select(); TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000); }