com.intellij.testFramework.EdtTestUtil Java Examples
The following examples show how to use
com.intellij.testFramework.EdtTestUtil.
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: MavenTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Override protected void tearDown() throws Exception { new RunAll( () -> MavenServerManager.getInstance().shutdown(true), () -> MavenArtifactDownloader.awaitQuiescence(100, TimeUnit.SECONDS), () -> myProject = null, () -> EdtTestUtil.runInEdtAndWait(() -> tearDownFixtures()), () -> MavenIndicesManager.getInstance().clear(), () -> super.tearDown(), () -> { FileUtil.delete(myDir); // cannot use reliably the result of the com.intellij.openapi.util.io.FileUtil.delete() method // because com.intellij.openapi.util.io.FileUtilRt.deleteRecursivelyNIO() does not honor this contract if (myDir.exists()) { System.err.println("Cannot delete " + myDir); //printDirectoryContent(myDir); myDir.deleteOnExit(); } }, () -> resetClassFields(getClass()) ).run(); }
Example #2
Source File: LightPlatformTestCaseExtension.java From GitToolBox with Apache License 2.0 | 6 votes |
private void destroy(ExtensionContext context) throws Exception { adapter.destroy(context); ParameterHolder.removeHolder(getStore(context)); if (IdeaLogger.ourErrorsOccurred != null) { throw IdeaLogger.ourErrorsOccurred; } // just to make sure all deferred Runnable's to finish waitForAllLaters(); if (IdeaLogger.ourErrorsOccurred != null) { throw IdeaLogger.ourErrorsOccurred; } try { EdtTestUtil.runInEdtAndWait(() -> { cleanupApplicationCaches(getProject()); resetAllFields(); }); } catch (Throwable ignored) { //ignored } }
Example #3
Source File: HeavyPlatformTestCaseExtension.java From GitToolBox with Apache License 2.0 | 6 votes |
private void destroy(ExtensionContext context) throws Exception { adapter.destroy(context); ParameterHolder.removeHolder(getStore(context)); if (IdeaLogger.ourErrorsOccurred != null) { throw IdeaLogger.ourErrorsOccurred; } // just to make sure all deferred Runnable's to finish waitForAllLaters(); if (IdeaLogger.ourErrorsOccurred != null) { throw IdeaLogger.ourErrorsOccurred; } try { EdtTestUtil.runInEdtAndWait(() -> { cleanupApplicationCaches(getProject()); resetAllFields(); }); } catch (Throwable ignored) { //ignored } }
Example #4
Source File: MavenTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); ensureTempDirCreated(); myDir = new File(ourTempDir, getTestName(false)); FileUtil.ensureExists(myDir); setUpFixtures(); myProject = myTestFixture.getProject(); MavenWorkspaceSettingsComponent.getInstance(myProject).loadState(new MavenWorkspaceSettings()); String home = getTestMavenHome(); if (home != null) { getMavenGeneralSettings().setMavenHome(home); } EdtTestUtil.runInEdtAndWait(() -> { restoreSettingsFile(); ApplicationManager.getApplication().runWriteAction(() -> { try { setUpInWriteAction(); } catch (Throwable e) { try { tearDown(); } catch (Exception e1) { e1.printStackTrace(); } throw new RuntimeException(e); } }); }); }
Example #5
Source File: CsvAnnotatorTest.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
private long collectAndCheckHighlighting(@NotNull ExpectedHighlightingDataWrapper data) { Project project = myFixture.getProject(); EdtTestUtil.runInEdtAndWait(() -> { PsiDocumentManager.getInstance(project).commitAllDocuments(); }); PsiFileImpl file = (PsiFileImpl)this.getHostFile(); FileElement hardRefToFileElement = file.calcTreeElement(); if (!DumbService.isDumb(project)) { ServiceManager.getService(project, CacheManager.class).getFilesWithWord("XXX", (short)2, GlobalSearchScope.allScope(project), true); } long start = System.currentTimeMillis(); Disposable disposable = Disposer.newDisposable(); List<HighlightInfo> infos; try { infos = myFixture.doHighlighting(); this.removeDuplicatedRangesForInjected(infos); } finally { Disposer.dispose(disposable); } long elapsed = System.currentTimeMillis() - start; data.checkResultWrapper(file, infos, file.getText()); hardRefToFileElement.hashCode(); return elapsed; }
Example #6
Source File: EditorTestHelper.java From intellij with Apache License 2.0 | 5 votes |
public void setCaretPosition(Editor editor, int lineNumber, int columnNumber) { final CaretInfo info = new CaretInfo(new LogicalPosition(lineNumber, columnNumber), null); EdtTestUtil.runInEdtAndWait( (ThrowableRunnable<Throwable>) () -> EditorTestUtil.setCaretsAndSelection( editor, new CaretAndSelectionState(ImmutableList.of(info), null))); }
Example #7
Source File: EdtRule.java From intellij with Apache License 2.0 | 5 votes |
@Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { TestRunnerUtil.replaceIdeEventQueueSafely(); EdtTestUtil.runInEdtAndWait((ThrowableRunnable<Throwable>) base::evaluate); } }; }
Example #8
Source File: L2Test.java From azure-devops-intellij with MIT License | 5 votes |
@Override protected void tearDown() throws Exception { disposeRegisteredServerContexts(); disposeJerseyPool(); try { /*if (myDialogManager != null) { myDialogManager.cleanup(); } if (myVcsNotifier != null) { myVcsNotifier.cleanup(); }*/ ServerPollingManager.getInstance().stopPolling(); OperationExecutor.getInstance().shutdown(); if (myProjectFixture != null) { EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() { @Override public void run() throws Throwable { myProjectFixture.tearDown(); } }); } } finally { try { String tempTestIndicator = myTestStartedIndicator; clearFields(this); myTestStartedIndicator = tempTestIndicator; } finally { super.tearDown(); } } }
Example #9
Source File: TestCaseJUnit5Adapter.java From GitToolBox with Apache License 2.0 | 5 votes |
void initialize(ExtensionContext context) throws Exception { adapted.setTestName(getTestName(context)); if (adapted.runInEdt()) { TestRunnerUtil.replaceIdeEventQueueSafely(); EdtTestUtil.runInEdtAndWait(adapted::doSetUp); } else { adapted.doSetUp(); } }
Example #10
Source File: TestCaseJUnit5Adapter.java From GitToolBox with Apache License 2.0 | 5 votes |
void destroy(ExtensionContext context) throws Exception { if (adapted.runInEdt()) { EdtTestUtil.runInEdtAndWait(adapted::doTearDown); } else { adapted.doTearDown(); } }
Example #11
Source File: BaseFunctionalTestCase.java From intellij-xquery with Apache License 2.0 | 5 votes |
private void doRunTest() throws Throwable { EdtTestUtil.runInEdtAndWait(() -> { try { BaseFunctionalTestCase.super.runTest(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }); }
Example #12
Source File: AbtractTemplateTest.java From idea-php-typo3-plugin with MIT License | 4 votes |
private void configureByFile() { EdtTestUtil.runInEdtAndWait(() -> myFixture.configureByFile(getTestName(true) + ".fluid")); }
Example #13
Source File: MockSdkUtil.java From intellij with Apache License 2.0 | 4 votes |
/** * Creates a mock SDK and register it in {@link ProjectJdkTable}. * * <p>Same as {link #registerSdk} but provides user ability to customize root content of SDK and * dummy files to create. It can be used to mock corrupt {@link ProjectJdkTable}/ missing SDK in * local. * * @param workspace test file system * @param major major version of SDK * @param minor minor version of SDK * @param roots root content of SDK * @param createSubFiles whether create subdirectory and files in file system for SDK. Set this to * false would lead to fail to add SDK to Jdk table and cannot retrieve its repo package * @return a mock sdk for the given target and name. The sdk is registered with the {@link * ProjectJdkTable}. */ public static Sdk registerSdk( WorkspaceFileSystem workspace, String major, String minor, MultiMap<OrderRootType, VirtualFile> roots, boolean createSubFiles) { String targetHash = String.format(TARGET_HASH, major); String sdkName = String.format(SDK_NAME, major); WorkspacePath workspacePathToAndroid = new WorkspacePath(PLATFORM_DIR, targetHash); if (createSubFiles) { workspace.createFile( new WorkspacePath(workspacePathToAndroid, "package.xml"), "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", "<ns2:repository xmlns:ns2=\"http://schemas.android.com/repository/android/common/01\"", " xmlns:ns3=\"http://schemas.android.com/repository/android/generic/01\"", " xmlns:ns4=\"http://schemas.android.com/sdk/android/repo/addon2/01\"", " xmlns:ns5=\"http://schemas.android.com/sdk/android/repo/repository2/01\"", " xmlns:ns6=\"http://schemas.android.com/sdk/android/repo/sys-img2/01\">", "<localPackage path=\"platforms;" + targetHash + "\" obsolete=\"false\">", "<type-details xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:type=\"ns5:platformDetailsType\">", "<api-level>", major, "</api-level>", "<layoutlib api=\"15\"/>", "</type-details>", "<revision>", " <major>", major, " </major>", " <minor>", minor, " </minor>", " <micro>", "0", " </micro>", "</revision>", "<display-name>", sdkName, "</display-name>", "</localPackage>", "</ns2:repository>"); workspace.createFile(new WorkspacePath(workspacePathToAndroid, "build.prop")); workspace.createFile(new WorkspacePath(workspacePathToAndroid, "android.jar")); workspace.createDirectory(new WorkspacePath(workspacePathToAndroid, "data/res")); workspace.createFile(new WorkspacePath(workspacePathToAndroid, "data/annotations.zip")); } String sdkHomeDir = workspace.createDirectory(SDK_DIR).getPath(); AndroidSdkData.getSdkData(new File(sdkHomeDir), true); MockSdk sdk = new MockSdk( sdkName, sdkHomeDir, String.format("%s.%s.0", major, minor), roots, AndroidSdkType.getInstance()); AndroidSdkAdditionalData data = new AndroidSdkAdditionalData(sdk); data.setBuildTargetHashString(targetHash); sdk.setSdkAdditionalData(data); EdtTestUtil.runInEdtAndWait( () -> ApplicationManager.getApplication() .runWriteAction(() -> ProjectJdkTable.getInstance().addJdk(sdk))); return sdk; }
Example #14
Source File: BlazeIntegrationTestCase.java From intellij with Apache License 2.0 | 4 votes |
private static void runWriteAction(Runnable writeAction) { EdtTestUtil.runInEdtAndWait( () -> ApplicationManager.getApplication().runWriteAction(writeAction)); }
Example #15
Source File: EditorTestHelper.java From intellij with Apache License 2.0 | 4 votes |
public Editor openFileInEditor(VirtualFile file) { EdtTestUtil.runInEdtAndWait( (ThrowableRunnable<Throwable>) () -> testFixture.openFileInEditor(file)); return testFixture.getEditor(); }
Example #16
Source File: CreatePullRequestTest.java From azure-devops-intellij with MIT License | 4 votes |
@Test(timeout = 60000) public void testCreatePullRequest() throws Exception { // need to create a context to start so that we aren't prompted in the middle of the test final ServerContext context = ServerContextManager.getInstance().getUpdatedContext(getRepoUrl(), true); // Create a temp folder for the clone final File tempFolder = L2Test.createTempDirectory(); final long currentTimeMillis = System.currentTimeMillis(); final String branchName = BRANCH_NAME_PREFIX + currentTimeMillis; final String prName = PR_NAME_PREFIX + currentTimeMillis; final String prDescription = PR_DESCRIPTION_PREFIX + currentTimeMillis; Debug.println("tempFolder", tempFolder.getPath()); Debug.println("branchName", branchName); Debug.println("prName", prName); Debug.println("prDescription", prDescription); // clone repo and checkout branch final Project currentProject = L2GitUtil.cloneRepo(myProject, tempFolder, myGit, getRepoUrl(), getTeamProject()); final VirtualFile baseDirectory = LocalFileSystem.getInstance().findFileByIoFile(new File(tempFolder, getTeamProject())); Assert.assertTrue(baseDirectory.exists()); final git4idea.repo.GitRepository repository = GitRepositoryImpl.getInstance(baseDirectory, currentProject, true); myGit.checkoutNewBranch(repository, branchName, null); repository.update(); // edit file final File readme = new File(baseDirectory.getPath(), README_FILE); L2GitUtil.editAndCommitFile(readme, repository, currentProject); // create PR model and set inputs final CreatePullRequestDialog mockDialog = mock(CreatePullRequestDialog.class); final CreatePullRequestModel model = new CreatePullRequestModel(currentProject, repository); try { model.setTitle(prName); model.setDescription(prDescription); // verify model created correctly Assert.assertTrue(model.getRemoteBranchDropdownModel().getSize() >= 1); Assert.assertEquals("origin/master", model.getTargetBranch().getName()); final CreatePullRequestController controller = new CreatePullRequestController(mockDialog, model); controller.actionPerformed(new ActionEvent(this, 1, BaseDialog.CMD_OK)); // verify PR created correctly final GitPullRequestSearchCriteria criteria = new GitPullRequestSearchCriteria(); criteria.setRepositoryId(context.getGitRepository().getId()); criteria.setStatus(PullRequestStatus.ACTIVE); criteria.setIncludeLinks(false); criteria.setCreatorId(context.getUserId()); criteria.setSourceRefName("refs/heads/" + branchName); //query server and add results final GitHttpClient gitHttpClient = context.getGitHttpClient(); final List<GitPullRequest> pullRequests = gitHttpClient.getPullRequests(context.getGitRepository().getId(), criteria, 256, 0, 101); Assert.assertEquals(1, pullRequests.size()); Assert.assertEquals(prName, pullRequests.get(0).getTitle()); Assert.assertEquals(prDescription, pullRequests.get(0).getDescription()); // TODO: this was working, investigating (commit it there but not returning) // Assert.assertEquals(L2GitUtil.COMMIT_MESSAGE, pullRequests.get(0).getCommits()[0].getComment()); // cleanup final GitPullRequest pullRequestToUpdate = new GitPullRequest(); pullRequestToUpdate.setStatus(PullRequestStatus.ABANDONED); gitHttpClient.updatePullRequest(pullRequestToUpdate, pullRequests.get(0).getRepository().getId(), pullRequests.get(0).getPullRequestId()); myGit.branchDelete(repository, branchName, true, mock(GitLineHandlerListener.class)); FileUtils.deleteDirectory(tempFolder); context.dispose(); // Close currentProject EdtTestUtil.runInEdtAndWait(() -> { ProjectManager.getInstance().closeProject(currentProject); ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(currentProject)); }); } finally { assertTrue(model.dispose(10, TimeUnit.SECONDS)); } }