summaryrefslogtreecommitdiff
path: root/platform/platform-tests/testSrc/com
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-tests/testSrc/com')
-rw-r--r--platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java55
-rw-r--r--platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java10
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java19
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java19
-rw-r--r--platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java (renamed from platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java)33
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java5
6 files changed, 94 insertions, 47 deletions
diff --git a/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java
new file mode 100644
index 000000000000..32ec00d1a733
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java
@@ -0,0 +1,55 @@
+package com.intellij.execution.process;
+
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Assert;
+
+import java.util.List;
+
+public class AnsiEscapeDecoderTest extends PlatformTestCase {
+
+ public void testTextWithoutColors() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("", ProcessOutputTypes.STDOUT)
+ )));
+ decoder.escapeText("simple text", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("simple text", ProcessOutputTypes.STDOUT)
+ )));
+ }
+
+ public void testSingleColoredChunk() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("Chrome 35.0.1916 (Linux): Executed 0 of 1\u001B[32m SUCCESS\u001B[39m (0 secs / 0 secs)\n", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("Chrome 35.0.1916 (Linux): Executed 0 of 1", ProcessOutputTypes.STDOUT),
+ Pair.create(" SUCCESS", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[32m")),
+ Pair.create(" (0 secs / 0 secs)\n", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[39m"))
+ )));
+ }
+
+ public void testCompoundEscSeq() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("E\u001B[41m\u001B[37mE\u001B[0mE", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("E", ProcessOutputTypes.STDOUT),
+ Pair.create("E", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[41;37m")),
+ Pair.create("E", ProcessOutputTypes.STDOUT)
+ )));
+ }
+
+ private static AnsiEscapeDecoder.ColoredChunksAcceptor createExpectedAcceptor(@NotNull final List<Pair<String, Key>> expected) {
+ return new AnsiEscapeDecoder.ColoredChunksAcceptor() {
+ @Override
+ public void coloredChunksAvailable(List<Pair<String, Key>> chunks) {
+ Assert.assertEquals(expected, chunks);
+ }
+
+ @Override
+ public void coloredTextAvailable(String text, Key attributes) {
+ throw new RuntimeException(); // shouldn't be called
+ }
+ };
+ }
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
index 6ba1e4aa12de..bbcbe9b4c2f2 100644
--- a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,7 @@ import com.intellij.history.integration.TestVirtualFile;
import com.intellij.history.integration.ui.actions.LocalHistoryAction;
import com.intellij.history.integration.ui.actions.ShowHistoryAction;
import com.intellij.history.integration.ui.actions.ShowSelectionHistoryAction;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
@@ -135,6 +131,6 @@ public class LocalHistoryActionsTest extends LocalHistoryUITestCase {
return null;
}
};
- return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), null, -1);
+ return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), ActionManager.getInstance(), -1);
}
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
index 0e2355f5c3c1..a84497a8f083 100644
--- a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
@@ -28,13 +28,13 @@ public class MasterKeyPasswordSafeTest {
@Test
public void testMasterKey() throws PasswordSafeException {
PasswordDatabase db = new PasswordDatabase();
- MasterKeyPasswordSafe s1 = testProvider(db);
+ MasterKeyPasswordSafe s1 = new MasterKeyPasswordSafe(db);
s1.resetMasterPassword("pass1", false);
s1.storePassword(null, MasterKeyPasswordSafeTest.class, "TEST", "test");
assertEquals("test", s1.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
assertTrue(s1.changeMasterPassword("pass1", "pass2", false));
assertEquals("test", s1.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
- MasterKeyPasswordSafe s2 = testProvider(db);
+ MasterKeyPasswordSafe s2 = new MasterKeyPasswordSafe(db);
assertFalse(s2.setMasterPassword("pass1"));
assertTrue(s2.setMasterPassword("pass2"));
assertEquals("test", s2.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
@@ -45,19 +45,4 @@ public class MasterKeyPasswordSafeTest {
s2.resetMasterPassword("fail", false);
assertNull(s2.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
}
-
- /**
- * Get test instance of the provider
- * @param db the database to use
- * @return a instance of the provider
- */
- private static MasterKeyPasswordSafe testProvider(final PasswordDatabase db) {
- return new MasterKeyPasswordSafe(db) {
- @Override
- protected boolean isTestMode() {
- return true;
- }
- };
- }
-
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java b/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
index 92b2ebad945c..99c6f5b5d25a 100644
--- a/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.util.treeView;
-import com.intellij.openapi.diagnostic.Log;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Progressive;
@@ -2753,22 +2752,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
return suite;
}
- @Override
- protected void tearDown() throws Exception {
- AbstractTreeUi ui = getBuilder().getUi();
- if (ui != null) {
- ui.getReady(this).doWhenProcessed(new Runnable() {
- @Override
- public void run() {
- Log.flush();
- }
- });
- } else {
- Log.flush();
- }
- super.tearDown();
- }
-
private abstract static class MyRunnable implements Runnable {
@Override
public final void run() {
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
index 2ab0446e86a4..b1ab5117dba9 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.psi;
+package com.intellij.psi.impl;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.mock.MockDocument;
@@ -27,8 +27,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.impl.DebugUtil;
-import com.intellij.psi.impl.PsiDocumentManagerImpl;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.testFramework.LeakHunter;
import com.intellij.testFramework.LightVirtualFile;
@@ -46,6 +47,13 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase {
return (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject());
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ DocumentCommitThread.getInstance();
+ UIUtil.dispatchAllInvocationEvents();
+ }
+
public void testGetCachedPsiFile_NoFile() throws Exception {
final PsiFile file = getPsiDocumentManager().getCachedPsiFile(new MockDocument());
assertNull(file);
@@ -367,4 +375,23 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase {
ProjectUtil.closeAndDispose(alienProject);
}
}
+
+ public void testCommitThreadGetSuspendedDuringWriteActions() {
+ final DocumentCommitThread commitThread = DocumentCommitThread.getInstance();
+ assertTrue(commitThread.isEnabled());
+ WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+ @Override
+ public void run() {
+ assertFalse(commitThread.isEnabled());
+ WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+ @Override
+ public void run() {
+ assertFalse(commitThread.isEnabled());
+ }
+ });
+ assertFalse(commitThread.isEnabled());
+ }
+ });
+ assertTrue(commitThread.isEnabled());
+ }
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
index 4544a7e547f1..1f3f1a8a248d 100644
--- a/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
+++ b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package com.intellij.ui.tabs.impl;
import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
@@ -46,7 +47,7 @@ public class JBTabsDemo {
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(0, 0));
final int[] count = new int[1];
- final JBTabsImpl tabs = new JBTabsImpl(null, null, null, Disposer.newDisposable());
+ final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
tabs.setTestMode(true);