mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup
This commit is contained in:
@@ -124,8 +124,8 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
|
||||
|
||||
private void assertStructureEqual(Object rootNode, String expected, int maxRowCount, Comparator comparator) {
|
||||
checkGetParentConsistency(rootNode);
|
||||
StringBuffer actual = PlatformTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo);
|
||||
assertEquals(expected, actual.toString());
|
||||
String actual = PlatformTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo).toString();
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
private void checkGetParentConsistency(Object from) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -53,7 +53,7 @@ public class AbstractTreeUpdater implements Disposable, Activatable {
|
||||
myTreeBuilder = treeBuilder;
|
||||
final JTree tree = myTreeBuilder.getTree();
|
||||
final JComponent component = tree instanceof TreeTableTree ? ((TreeTableTree)tree).getTreeTable() : tree;
|
||||
myUpdateQueue = new MergingUpdateQueue("UpdateQeue", 300, component.isShowing(), component) {
|
||||
myUpdateQueue = new MergingUpdateQueue("UpdateQueue", 300, component.isShowing(), component) {
|
||||
@Override
|
||||
protected Alarm createAlarm(Alarm.ThreadToUse thread, Disposable parent) {
|
||||
return new Alarm(thread, parent) {
|
||||
|
||||
+4
-6
@@ -54,7 +54,6 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
final Set<StructureElement> myAutoExpand = new HashSet<StructureElement>();
|
||||
final Set<StructureElement> myAlwaysShowPlus = new HashSet<StructureElement>();
|
||||
boolean mySmartExpand;
|
||||
private Thread myTestThread;
|
||||
protected Validator myValidator;
|
||||
|
||||
protected BaseTreeTestCase(boolean passThrough) {
|
||||
@@ -95,7 +94,7 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
}
|
||||
|
||||
void waitBuilderToCome(final Condition<Object> condition) throws Exception {
|
||||
boolean success = new WaitFor(600000) {
|
||||
boolean success = new WaitFor(60000) {
|
||||
@Override
|
||||
protected boolean condition() {
|
||||
final boolean[] ready = new boolean[]{false};
|
||||
@@ -120,7 +119,7 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
throw new Exception(myCancelRequest);
|
||||
}
|
||||
|
||||
if (myCancelRequest == null && !myReadyRequest) {
|
||||
if (!myReadyRequest) {
|
||||
if (!getBuilder().isDisposed()) {
|
||||
Assert.assertTrue(getBuilder().getUi().getNodeActions().isEmpty());
|
||||
}
|
||||
@@ -256,7 +255,7 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
|
||||
void _runBackgroundLoading(Runnable runnable) {
|
||||
try {
|
||||
Thread.currentThread().sleep(getChildrenLoadingDelay());
|
||||
Thread.sleep(getChildrenLoadingDelay());
|
||||
runnable.run();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
@@ -284,7 +283,7 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
AbstractTreeUpdater _createUpdater(AbstractTreeBuilder builder) {
|
||||
static AbstractTreeUpdater _createUpdater(AbstractTreeBuilder builder) {
|
||||
final AbstractTreeUpdater updater = new AbstractTreeUpdater(builder) {
|
||||
@Override
|
||||
protected void invokeLater(Runnable runnable) {
|
||||
@@ -352,7 +351,6 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
myAutoExpand.clear();
|
||||
myAlwaysShowPlus.clear();
|
||||
myForegroundLoadingNodes.clear();
|
||||
myTestThread = Thread.currentThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
updateFromRoot();
|
||||
assertTree("+/\n");
|
||||
|
||||
|
||||
buildNode("/", false);
|
||||
assertTree("+/\n");
|
||||
|
||||
@@ -119,10 +118,8 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " +[fabrique]\n"
|
||||
+ " +org\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testBatchUpdate() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
|
||||
@@ -164,7 +161,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
waitBuilderToCome(new Condition<Object>() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
@@ -189,7 +185,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertFalse(indicatorRef.get().isCanceled());
|
||||
}
|
||||
|
||||
|
||||
public void testRenameCollapsedParentAlwaysShowsPlus() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
myAlwaysShowPlus.add(myCom.getElement());
|
||||
@@ -220,7 +215,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testMoveElementToAdjacentEmptyParentWithSmartExpandAndSerialUpdateSubtrees() throws Exception {
|
||||
Node com = myRoot.addChild("com");
|
||||
Node folder1 = com.addChild("folder1");
|
||||
@@ -253,7 +247,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" [file21]\n" +
|
||||
" -folder2\n" +
|
||||
" file22\n");
|
||||
|
||||
}
|
||||
|
||||
public void testReadyCallbackWhenReleased() throws Exception {
|
||||
@@ -287,7 +280,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final Ref<Boolean> disposeRequested = new Ref<Boolean>(false);
|
||||
myElementUpdateHook = new ElementUpdateHook() {
|
||||
@Override
|
||||
@@ -305,7 +297,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -335,7 +326,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
final Ref<StringBuffer> updates = new Ref<StringBuffer>(new StringBuffer());
|
||||
notNull(getMyBuilder().getTreeModel()).addTreeModelListener(new TreeModelListener() {
|
||||
@Override
|
||||
@@ -365,7 +355,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
updateFromRoot();
|
||||
assertEquals("", updates.get().toString());
|
||||
|
||||
|
||||
myChanges.add(new NodeElement("com"));
|
||||
updateFromRoot();
|
||||
assertEquals("changed parent[/] children=[com]\n", updates.get().toString());
|
||||
@@ -376,7 +365,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
updates.set(new StringBuffer());
|
||||
|
||||
|
||||
updateFrom(new NodeElement("org"));
|
||||
assertEquals("", updates.get().toString());
|
||||
|
||||
@@ -385,7 +373,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertEquals("changed parent[/] children=[org]\n", updates.get().toString());
|
||||
updates.set(new StringBuffer());
|
||||
|
||||
|
||||
myChanges.add(new NodeElement("intellij"));
|
||||
updateFromRoot();
|
||||
assertEquals("", updates.get().toString());
|
||||
@@ -440,7 +427,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
waitBuilderToCome(new Condition<Object>() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
@@ -448,7 +434,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
assertNull(myCancelRequest);
|
||||
assertTrue(done.isRejected());
|
||||
assertTrue(indicatorRef.get().isCanceled());
|
||||
@@ -518,7 +503,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
updateFromRoot();
|
||||
|
||||
assertTree("+/\n");
|
||||
|
||||
}
|
||||
|
||||
public void testAutoExpand() throws Exception {
|
||||
@@ -534,7 +518,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " +org\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
|
||||
myAutoExpand.add(new NodeElement("jetbrains"));
|
||||
updateFromRoot();
|
||||
|
||||
@@ -573,7 +556,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
//myAutoExpand.add(new NodeElement("jetbrains"));
|
||||
myAutoExpand.add(new NodeElement("fabrique"));
|
||||
|
||||
|
||||
buildStructure(myRoot);
|
||||
//assertTree("+/\n");
|
||||
|
||||
@@ -616,10 +598,8 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " ide\n"
|
||||
+ " +org\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testExpandEqualElements() throws Exception {
|
||||
buildStructure(myRoot, false);
|
||||
notNull(myRoot.getChildNode("org")).addChild("jetbrains").addChild("community").addChild("ide");
|
||||
@@ -659,7 +639,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " +community\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
|
||||
doAndWaitForBuilder(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -677,7 +656,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " ide\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
|
||||
doAndWaitForBuilder(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -693,7 +671,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " +[jetbrains]\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
|
||||
doAndWaitForBuilder(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -709,7 +686,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " -[jetbrains]\n"
|
||||
+ " +community\n"
|
||||
+ " +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
public void testAutoExpandInNonVisibleNode() throws Exception {
|
||||
@@ -776,7 +752,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
+ " +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testClear() throws Exception {
|
||||
getBuilder().getUi().setClearOnHideDelay(Time.SECOND);
|
||||
|
||||
@@ -805,7 +780,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertNull(findNode("runner", false));
|
||||
assertNull(findNode("rcp", false));
|
||||
|
||||
|
||||
showTree();
|
||||
|
||||
assertTree("-/\n" +
|
||||
@@ -834,7 +808,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" -xUnit\n" +
|
||||
" runner\n");
|
||||
|
||||
|
||||
buildNode(myFabrique.myElement, true, false);
|
||||
assertTree("-/\n" +
|
||||
" -com\n" +
|
||||
@@ -889,13 +862,11 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" runner\n");
|
||||
}
|
||||
|
||||
|
||||
public void testSelect() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
assertTree(
|
||||
"+/\n");
|
||||
|
||||
|
||||
buildNode(myOpenApi, true);
|
||||
assertTree(
|
||||
"-/\n" +
|
||||
@@ -961,7 +932,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +[fabrique]\n" +
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
public void testCallbackOnceOnExpand() throws Exception {
|
||||
@@ -984,10 +954,8 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" ide\n" +
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testNoInfiniteAutoExpand() throws Exception {
|
||||
mySmartExpand = false;
|
||||
|
||||
@@ -1025,7 +993,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
|
||||
private void assertNoInfiniteAutoExpand(final Runnable enableExpand) throws Exception {
|
||||
class Level extends Node {
|
||||
|
||||
int myLevel;
|
||||
|
||||
Level(Node parent, int level) {
|
||||
@@ -1152,7 +1119,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testSelectionWhenChildMoved() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
assertTree("+/\n");
|
||||
@@ -1187,7 +1153,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testSelectionGoesToParentWhenOnlyChildRemove() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
buildNode("openapi", true);
|
||||
@@ -1301,7 +1266,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
getBuilder().addSubtreeToUpdateByElement(new NodeElement("intellij"));
|
||||
getBuilder().addSubtreeToUpdateByElement(new NodeElement("xUnit"));
|
||||
|
||||
|
||||
doAndWaitForBuilder(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1333,7 +1297,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
collapsePath(new TreePath(notNull(findNode("intellij", false)).getPath()));
|
||||
|
||||
assertTree(
|
||||
@@ -1345,7 +1308,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testUpdateWithNewDescriptor() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
|
||||
@@ -1465,7 +1427,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" intellij\n" +
|
||||
" jetbrains\n");
|
||||
|
||||
|
||||
intellij.addChild("ide");
|
||||
|
||||
runAndInterrupt(new MyRunnable() {
|
||||
@@ -1523,7 +1484,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}, "getChildren", new NodeElement("jetbrains"), cancelled);
|
||||
}
|
||||
|
||||
|
||||
public void testBigTreeUpdate() throws Exception {
|
||||
Node msg = myRoot.addChild("Messages");
|
||||
|
||||
@@ -1547,7 +1507,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" message 1 for 1\n" +
|
||||
" message 2 for 1\n");
|
||||
|
||||
|
||||
buildSiblings(msg, 2, 1000, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1588,20 +1547,16 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
throwProcessCancelled, invokeCancel
|
||||
}
|
||||
|
||||
private void runAndInterrupt(final Runnable action, final String interruptAction, final Object interruptElement, final Interruption interruption) throws Exception {
|
||||
private void runAndInterrupt(final Runnable action,
|
||||
final String interruptAction,
|
||||
final Object interruptElement,
|
||||
final Interruption interruption) throws Exception {
|
||||
myElementUpdate.clear();
|
||||
|
||||
final Ref<Thread> thread = new Ref<Thread>();
|
||||
|
||||
final boolean[] wasInterrupted = new boolean[] {false};
|
||||
final boolean[] wasInterrupted = new boolean[]{false};
|
||||
myElementUpdateHook = new ElementUpdateHook() {
|
||||
@Override
|
||||
public void onElementAction(String action, Object element) {
|
||||
if (thread.get() == null) {
|
||||
thread.set(Thread.currentThread());
|
||||
}
|
||||
|
||||
|
||||
boolean toInterrupt = element.equals(interruptElement) && action.equals(interruptAction);
|
||||
|
||||
if (wasInterrupted[0]) {
|
||||
@@ -1611,16 +1566,15 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" interruptAction=" + interruptAction + " interruptElement=" + interruptElement;
|
||||
myCancelRequest = new AssertionError(message);
|
||||
}
|
||||
} else {
|
||||
if (toInterrupt) {
|
||||
wasInterrupted[0] = true;
|
||||
switch (interruption) {
|
||||
case throwProcessCancelled:
|
||||
throw new ProcessCanceledException();
|
||||
case invokeCancel:
|
||||
getBuilder().cancelUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (toInterrupt) {
|
||||
wasInterrupted[0] = true;
|
||||
switch (interruption) {
|
||||
case throwProcessCancelled:
|
||||
throw new ProcessCanceledException();
|
||||
case invokeCancel:
|
||||
getBuilder().cancelUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1690,7 +1644,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
"org: update getChildren\n" +
|
||||
"runner: update\n" +
|
||||
"xUnit: update getChildren");
|
||||
|
||||
}
|
||||
|
||||
public void testQueryWhenUpdatingPresentation() throws Exception {
|
||||
@@ -1704,7 +1657,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
|
||||
myElementUpdate.clear();
|
||||
|
||||
|
||||
updateFromRoot(false);
|
||||
|
||||
assertUpdates("/: update\n" +
|
||||
@@ -1714,7 +1666,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
"xUnit: update");
|
||||
}
|
||||
|
||||
|
||||
public void testInfiniteUpdatingWhenReQueueingUpdates() throws Exception {
|
||||
buildStructure(myRoot, false);
|
||||
myCom.addChild("ibm").addChild("alphaWorks");
|
||||
@@ -1734,7 +1685,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
myElementUpdateHook = new ElementUpdateHook() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
@@ -1788,7 +1738,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
"org: update getChildren\n" +
|
||||
"runner: update\n" +
|
||||
"xUnit: update getChildren");
|
||||
|
||||
}
|
||||
|
||||
public void testQueryStructureIsAlwaysShowsPlus() throws Exception {
|
||||
@@ -1827,7 +1776,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
"ide: update\n" +
|
||||
"jetbrains: update getChildren");
|
||||
|
||||
|
||||
expand(getPath("ide"));
|
||||
assertTree("-/\n" +
|
||||
" +com\n" +
|
||||
@@ -1873,7 +1821,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
assertUpdates("ide: update getChildren");
|
||||
|
||||
|
||||
buildNode("com", false);
|
||||
assertTree("-/\n" +
|
||||
" -com\n" +
|
||||
@@ -1943,10 +1890,8 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +jetbrains\n" +
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testSorting() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
assertSorted("");
|
||||
@@ -1984,7 +1929,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
assertSorted("");
|
||||
|
||||
|
||||
expand(getPath("com"));
|
||||
assertTree("-/\n" +
|
||||
" -com\n" +
|
||||
@@ -2042,7 +1986,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
removeFromParentButKeepRef(new NodeElement("openapi"));
|
||||
|
||||
updateFromRoot();
|
||||
@@ -2128,7 +2071,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testRevalidateStructure() throws Exception {
|
||||
final NodeElement com = new NodeElement("com");
|
||||
final NodeElement actionSystem = new NodeElement("actionSystem");
|
||||
@@ -2156,7 +2098,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" -fabrique\n" +
|
||||
" ide\n");
|
||||
|
||||
|
||||
removeFromParentButKeepRef(actionSystem);
|
||||
removeFromParentButKeepRef(fabrique);
|
||||
|
||||
@@ -2207,7 +2148,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
|
||||
assertTree("-/\n" + " -com\n" + " +[intellij]\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
|
||||
|
||||
removeFromParentButKeepRef(new NodeElement("intellij"));
|
||||
myValidator = new Validator() {
|
||||
@Override
|
||||
@@ -2235,7 +2175,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertNull(reValidatedElement.get() != null ? reValidatedElement.get().toString() : null, reValidatedElement.get());
|
||||
}
|
||||
|
||||
|
||||
private void doTestSelectionOnDelete(boolean keepRef) throws Exception {
|
||||
myComparator.setDelegate(new NodeDescriptor.NodeComparator<NodeDescriptor>() {
|
||||
@Override
|
||||
@@ -2279,7 +2218,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertTree("-/\n" + " +com\n" + " +jetbrains\n" + " +org\n" + " +[xUnit]\n");
|
||||
}
|
||||
|
||||
|
||||
public void testGetChildrenOnInvalidNode() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
|
||||
@@ -2298,7 +2236,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
invalid.add(new NodeElement("com"));
|
||||
|
||||
updateFrom(new NodeElement("com"));
|
||||
@@ -2315,7 +2252,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testSelectWhenUpdatesArePending() throws Exception {
|
||||
notNull(getBuilder().getUpdater()).setDelay(1000);
|
||||
|
||||
@@ -2325,7 +2261,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
select(new Object[]{new NodeElement("intellij")}, false);
|
||||
assertTree("-/\n" + " -com\n" + " -[intellij]\n" + " openapi\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
|
||||
|
||||
myIntellij.addChild("ui");
|
||||
|
||||
DefaultMutableTreeNode intellijNode = findNode("intellij", false);
|
||||
@@ -2338,7 +2273,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertTree("-/\n" + " -com\n" + " -intellij\n" + " openapi\n" + " [ui]\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testAddNewElementToLeafElementAlwaysShowPlus() throws Exception {
|
||||
myAlwaysShowPlus.add(new NodeElement("openapi"));
|
||||
|
||||
@@ -2356,7 +2290,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
myOpenApi.addChild("ui");
|
||||
|
||||
getMyBuilder().addSubtreeToUpdate(findNode("openapi", false));
|
||||
@@ -2379,7 +2312,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
expand(getPath("openapi"));
|
||||
assertTree("-/\n" + " -com\n" + " -intellij\n" + " [openapi]\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
|
||||
|
||||
myOpenApi.addChild("ui");
|
||||
|
||||
getMyBuilder().addSubtreeToUpdate(findNode("openapi", false));
|
||||
@@ -2387,7 +2319,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertTree("-/\n" + " -com\n" + " -intellij\n" + " +[openapi]\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testUpdateAlwaysLeaf() throws Exception {
|
||||
myStructure.addLeaf(new NodeElement("openapi"));
|
||||
|
||||
@@ -2397,7 +2328,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
|
||||
assertTree("-/\n" + " -com\n" + " -intellij\n" + " openapi\n" + " +jetbrains\n" + " +org\n" + " +xUnit\n");
|
||||
|
||||
|
||||
myElementUpdate.clear();
|
||||
|
||||
invokeAndWaitIfNeeded(new Runnable() {
|
||||
@@ -2434,10 +2364,8 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +[intellij]\n" +
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testChangeRootElement() throws Exception {
|
||||
buildStructure(myRoot);
|
||||
|
||||
@@ -2470,7 +2398,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
myCom.addChild("ibm");
|
||||
|
||||
getBuilder().queueUpdateFrom(new NodeElement("com"), false, true);
|
||||
@@ -2530,7 +2457,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertTree("-/\n" + " +com\n" + " -[jetbrains]\n" + " -fabrique\n" + " ide\n" + " +org\n" + " +xUnit\n");
|
||||
}
|
||||
|
||||
|
||||
public void testUpdateCollapsedBuiltNode() throws Exception {
|
||||
buildStructure(myRoot, false);
|
||||
|
||||
@@ -2558,7 +2484,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
" +org\n" +
|
||||
" +xUnit\n");
|
||||
|
||||
|
||||
myCom.addChild(myIntellij);
|
||||
updateFrom(new NodeElement("com"));
|
||||
assertTree("-/\n" +
|
||||
@@ -2569,7 +2494,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertEquals(1, com.getChildCount());
|
||||
assertEquals("intellij", com.getChildAt(0).toString());
|
||||
|
||||
|
||||
myCom.removeAll();
|
||||
updateFrom(new NodeElement("com"));
|
||||
|
||||
@@ -2595,7 +2519,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void testAssertionOnInfiniteTree() throws Exception {
|
||||
final Node com = myRoot.addChild("com");
|
||||
final Node intellij = com.addChild("intellij");
|
||||
@@ -2658,12 +2581,14 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
assertTrue(released);
|
||||
}
|
||||
|
||||
|
||||
public static class SyncUpdate extends TreeUiTest {
|
||||
public SyncUpdate() {
|
||||
super(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class PassThrough extends TreeUiTest {
|
||||
public PassThrough() {
|
||||
super(true);
|
||||
@@ -2715,18 +2640,19 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class YieldingUpdate extends TreeUiTest {
|
||||
public YieldingUpdate() {
|
||||
super(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class BgLoadingSyncUpdate extends TreeUiTest {
|
||||
public BgLoadingSyncUpdate() {
|
||||
super(false, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getChildrenLoadingDelay() {
|
||||
return 100;
|
||||
@@ -2753,7 +2679,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
super(false, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testQueryStructure() throws Exception {
|
||||
super.testQueryStructure();
|
||||
@@ -2773,9 +2698,9 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
public void testBigTreeUpdate() throws Exception {
|
||||
//to slow, tested the same in VeryQuickBgLoadingTest
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class VeryQuickBgLoadingSyncUpdate extends TreeUiTest {
|
||||
public VeryQuickBgLoadingSyncUpdate() {
|
||||
super(false, true);
|
||||
@@ -2812,6 +2737,7 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static TestSuite suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
@@ -2843,7 +2769,7 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
abstract static class MyRunnable implements Runnable {
|
||||
private abstract static class MyRunnable implements Runnable {
|
||||
@Override
|
||||
public final void run() {
|
||||
try {
|
||||
|
||||
+32
-26
@@ -1,17 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structureView;
|
||||
|
||||
import com.intellij.ide.util.treeView.smartTree.*;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
private final Queryable.PrintInfo myPrintInfo = new Queryable.PrintInfo();
|
||||
private TestTreeModel myModel;
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public SmartTreeStructureTest() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
@@ -21,14 +40,13 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
super.setUp();
|
||||
TestTreeModel.StringTreeElement root = new TestTreeModel.StringTreeElement("root");
|
||||
myModel = new TestTreeModel(root);
|
||||
root.addChild("abc").addChild("abcde");
|
||||
root.addChild("bcd").addChild("bhgyt");
|
||||
root.addChild("abc").addChild("abc_de");
|
||||
root.addChild("bcd").addChild("bhg_yt");
|
||||
root.addChild("ade").addChild("aed");
|
||||
root.addChild("bft").addChild("ttt");
|
||||
root.addChild("xxx");
|
||||
root.addChild("eed").addChild("zzz");
|
||||
root.addChild("xxx").addChild("aaa").addChild("bbb");
|
||||
|
||||
}
|
||||
|
||||
public void testGrouping() throws Exception {
|
||||
@@ -42,12 +60,12 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..abc\n" +
|
||||
"...Group:a\n" +
|
||||
"....Group:d\n" +
|
||||
".....abcde\n" +
|
||||
".....abc_de\n" +
|
||||
".Group:b\n" +
|
||||
"..Group:d\n" +
|
||||
"...bcd\n" +
|
||||
"....Group:b\n" +
|
||||
".....bhgyt\n" +
|
||||
".....bhg_yt\n" +
|
||||
"..Group:f\n" +
|
||||
"...bft\n" +
|
||||
"....ttt\n" +
|
||||
@@ -59,13 +77,11 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..Group:a\n" +
|
||||
"...aaa\n" +
|
||||
"....Group:b\n" +
|
||||
".....bbb\n", PlatformTestUtil.DEFAULT_COMPARATOR);
|
||||
|
||||
|
||||
".....bbb\n", PlatformTestUtil.createComparator(myPrintInfo));
|
||||
}
|
||||
|
||||
public void testFiltering() throws Exception {
|
||||
myModel.addFlter(new Filter(){
|
||||
myModel.addFlter(new Filter() {
|
||||
@Override
|
||||
@NotNull
|
||||
public ActionPresentation getPresentation() {
|
||||
@@ -87,14 +103,14 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
public boolean isReverted() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
assertStructureEqual("root\n" +
|
||||
".Group:b\n" +
|
||||
"..Group:d\n" +
|
||||
"...bcd\n" +
|
||||
"....Group:b\n" +
|
||||
".....bhgyt\n" +
|
||||
".....bhg_yt\n" +
|
||||
"..Group:f\n" +
|
||||
"...bft\n" +
|
||||
"....ttt\n" +
|
||||
@@ -102,13 +118,10 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..eed\n" +
|
||||
"...zzz\n" +
|
||||
".xxx\n" +
|
||||
".xxx\n", PlatformTestUtil.DEFAULT_COMPARATOR);
|
||||
|
||||
".xxx\n", PlatformTestUtil.createComparator(myPrintInfo));
|
||||
}
|
||||
|
||||
public void testSorting() throws Exception {
|
||||
|
||||
|
||||
myModel.addSorter(new Sorter() {
|
||||
@Override
|
||||
public Comparator getComparator() {
|
||||
@@ -179,12 +192,12 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..abc\n" +
|
||||
"...Group:a\n" +
|
||||
"....Group:d\n" +
|
||||
".....abcde\n" +
|
||||
".....abc_de\n" +
|
||||
".Group:b\n" +
|
||||
"..Group:d\n" +
|
||||
"...bcd\n" +
|
||||
"....Group:b\n" +
|
||||
".....bhgyt\n" +
|
||||
".....bhg_yt\n" +
|
||||
"..Group:f\n" +
|
||||
"...bft\n" +
|
||||
"....ttt\n" +
|
||||
@@ -196,9 +209,7 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..Group:a\n" +
|
||||
"...aaa\n" +
|
||||
"....Group:b\n" +
|
||||
".....bbb\n"
|
||||
, null);
|
||||
|
||||
".....bbb\n", null);
|
||||
}
|
||||
|
||||
public void testUnsorted(){
|
||||
@@ -223,16 +234,11 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC
|
||||
"..aaa\n" +
|
||||
"...zzz\n" +
|
||||
".xxx\n", null);
|
||||
|
||||
}
|
||||
|
||||
private void assertStructureEqual(@NonNls String expected, Comparator comparator) {
|
||||
private void assertStructureEqual(@NonNls String expected, @Nullable Comparator comparator) {
|
||||
SmartTreeStructure structure = new SmartTreeStructure(myFixture.getProject(), myModel);
|
||||
|
||||
String actual = PlatformTestUtil.print(structure, structure.getRootElement(), 0, comparator, -1, '.', null).toString();
|
||||
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -72,6 +69,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
@@ -97,12 +95,16 @@ public class PlatformTestUtil {
|
||||
});
|
||||
}
|
||||
|
||||
protected static String toString(Object node, Queryable.PrintInfo printInfo) {
|
||||
@Nullable
|
||||
protected static String toString(Object node, @Nullable Queryable.PrintInfo printInfo) {
|
||||
if (node instanceof AbstractTreeNode) {
|
||||
if (printInfo != null) {
|
||||
return ((AbstractTreeNode)node).toTestString(printInfo);
|
||||
} else {
|
||||
return ((AbstractTreeNode)node).getTestPresentation();
|
||||
}
|
||||
else {
|
||||
@SuppressWarnings({"deprecation", "UnnecessaryLocalVariable"})
|
||||
final String presentation = ((AbstractTreeNode)node).getTestPresentation();
|
||||
return presentation;
|
||||
}
|
||||
}
|
||||
else if (node == null) {
|
||||
@@ -117,9 +119,8 @@ public class PlatformTestUtil {
|
||||
return print(tree, withSelection, null);
|
||||
}
|
||||
|
||||
public static String print(JTree tree, boolean withSelection, Condition<String> nodePrintCondition) {
|
||||
public static String print(JTree tree, boolean withSelection, @Nullable Condition<String> nodePrintCondition) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
final Collection<String> strings = printAsList(tree, withSelection, nodePrintCondition);
|
||||
for (String string : strings) {
|
||||
buffer.append(string).append("\n");
|
||||
@@ -127,7 +128,7 @@ public class PlatformTestUtil {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static Collection<String> printAsList(JTree tree, boolean withSelection, Condition<String> nodePrintCondition) {
|
||||
public static Collection<String> printAsList(JTree tree, boolean withSelection, @Nullable Condition<String> nodePrintCondition) {
|
||||
Collection<String> strings = new ArrayList<String>();
|
||||
Object root = tree.getModel().getRoot();
|
||||
printImpl(tree, root, strings, 0, withSelection, nodePrintCondition);
|
||||
@@ -142,7 +143,6 @@ public class PlatformTestUtil {
|
||||
@Nullable Condition<String> nodePrintCondition) {
|
||||
DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)root;
|
||||
|
||||
|
||||
final Object userObject = defaultMutableTreeNode.getUserObject();
|
||||
String nodeText;
|
||||
if (userObject != null) {
|
||||
@@ -154,33 +154,26 @@ public class PlatformTestUtil {
|
||||
|
||||
if (nodePrintCondition != null && !nodePrintCondition.value(nodeText)) return;
|
||||
|
||||
boolean expanded = tree.isExpanded(new TreePath(defaultMutableTreeNode.getPath()));
|
||||
|
||||
final StringBuilder buff = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
StringUtil.repeatSymbol(buff, ' ', level);
|
||||
if (expanded && !defaultMutableTreeNode.isLeaf()) {
|
||||
buff.append("-");
|
||||
}
|
||||
|
||||
if (!expanded && !defaultMutableTreeNode.isLeaf()) {
|
||||
buff.append("+");
|
||||
final boolean expanded = tree.isExpanded(new TreePath(defaultMutableTreeNode.getPath()));
|
||||
if (!defaultMutableTreeNode.isLeaf()) {
|
||||
buff.append(expanded ? "-" : "+");
|
||||
}
|
||||
|
||||
final boolean selected = tree.getSelectionModel().isPathSelected(new TreePath(defaultMutableTreeNode.getPath()));
|
||||
|
||||
if (withSelection && selected) {
|
||||
buff.append("[");
|
||||
}
|
||||
|
||||
|
||||
buff.append(nodeText);
|
||||
|
||||
if (withSelection && selected) {
|
||||
buff.append("]");
|
||||
}
|
||||
|
||||
//buff.append("\n");
|
||||
strings.add(buff.toString());
|
||||
|
||||
int childCount = tree.getModel().getChildCount(root);
|
||||
@@ -189,7 +182,8 @@ public class PlatformTestUtil {
|
||||
printImpl(tree, tree.getModel().getChild(root, i), strings, level + 1, withSelection, nodePrintCondition);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
StringBuilderSpinAllocator.dispose(buff);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +198,7 @@ public class PlatformTestUtil {
|
||||
|
||||
public static void assertTreeEqual(JTree tree, String expected, boolean checkSelected) {
|
||||
String treeStringPresentation = print(tree, checkSelected);
|
||||
Assert.assertEquals(expected, treeStringPresentation);
|
||||
assertEquals(expected, treeStringPresentation);
|
||||
}
|
||||
|
||||
public static void assertTreeEqualIgnoringNodesOrder(JTree tree, String expected, boolean checkSelected) {
|
||||
@@ -214,7 +208,7 @@ public class PlatformTestUtil {
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void waitForAlarm(final int delay) throws InterruptedException {
|
||||
public static void waitForAlarm(final int delay) {
|
||||
assert !ApplicationManager.getApplication().isWriteAccessAllowed(): "It's a bad idea to wait for an alarm under the write action. Somebody creates an alarm which requires read action and you are deadlocked.";
|
||||
assert ApplicationManager.getApplication().isDispatchThread();
|
||||
|
||||
@@ -242,7 +236,7 @@ public class PlatformTestUtil {
|
||||
boolean sleptAlready = false;
|
||||
while (!invoked.get()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
Thread.sleep(sleptAlready ? 10 : delay);
|
||||
TimeoutUtil.sleep(sleptAlready ? 10 : delay);
|
||||
sleptAlready = true;
|
||||
}
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
@@ -278,61 +272,32 @@ public class PlatformTestUtil {
|
||||
return now.after(raidDate(bombedAnnotation));
|
||||
}
|
||||
|
||||
public static boolean bombExplodes(int year, int month, int day, int h, int m, String who, String message) {
|
||||
final Calendar instance = Calendar.getInstance();
|
||||
instance.set(Calendar.YEAR, year);
|
||||
instance.set(Calendar.MONTH, month);
|
||||
instance.set(Calendar.DAY_OF_MONTH, day);
|
||||
instance.set(Calendar.HOUR_OF_DAY, h);
|
||||
instance.set(Calendar.MINUTE, m);
|
||||
Date time = instance.getTime();
|
||||
return isItMe(who) || new Date().after(time);
|
||||
}
|
||||
|
||||
public static boolean isRotten(Bombed bomb) {
|
||||
long bombRotPeriod = 30L * 24 * 60 * 60 * 1000; // month
|
||||
return new Date().after(new Date(raidDate(bomb).getTime() + bombRotPeriod));
|
||||
}
|
||||
|
||||
private static boolean isItMe(final String who) {
|
||||
return Comparing.equal(who, SystemProperties.getUserName(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #print(com.intellij.ide.util.treeView.AbstractTreeStructure, Object, int, java.util.Comparator, int, char,
|
||||
* com.intellij.openapi.ui.Queryable.PrintInfo)}
|
||||
*/
|
||||
public static StringBuffer print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar) {
|
||||
|
||||
return print(structure, node, currentLevel, comparator, maxRowCount, paddingChar, null);
|
||||
}
|
||||
|
||||
public static StringBuffer print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar,
|
||||
Queryable.PrintInfo printInfo) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
public static StringBuilder print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
@Nullable Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar,
|
||||
@Nullable Queryable.PrintInfo printInfo) {
|
||||
StringBuilder buffer = StringBuilderSpinAllocator.alloc();
|
||||
doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static int doPrint(StringBuffer buffer,
|
||||
private static int doPrint(StringBuilder buffer,
|
||||
int currentLevel,
|
||||
Object node,
|
||||
AbstractTreeStructure structure,
|
||||
Comparator comparator,
|
||||
@Nullable Comparator comparator,
|
||||
int maxRowCount,
|
||||
int currentLine,
|
||||
char paddingChar,
|
||||
Queryable.PrintInfo printInfo) {
|
||||
@Nullable Queryable.PrintInfo printInfo) {
|
||||
if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;
|
||||
|
||||
StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
|
||||
@@ -342,7 +307,8 @@ public class PlatformTestUtil {
|
||||
|
||||
if (comparator != null) {
|
||||
ArrayList<?> list = new ArrayList<Object>(Arrays.asList(children));
|
||||
Collections.sort(list, comparator);
|
||||
@SuppressWarnings({"UnnecessaryLocalVariable", "unchecked"}) Comparator<Object> c = comparator;
|
||||
Collections.sort(list, c);
|
||||
children = ArrayUtil.toObjectArray(list);
|
||||
}
|
||||
for (Object child : children) {
|
||||
@@ -383,15 +349,15 @@ public class PlatformTestUtil {
|
||||
}
|
||||
|
||||
public static void assertTreeStructureEquals(final AbstractTreeStructure treeStructure, final String expected) {
|
||||
Assert.assertEquals(expected, print(treeStructure, treeStructure.getRootElement(), 0, null, -1, ' ').toString());
|
||||
assertEquals(expected, print(treeStructure, treeStructure.getRootElement(), 0, null, -1, ' ', null).toString());
|
||||
}
|
||||
|
||||
public static void invokeNamedAction(final String actionId) {
|
||||
final AnAction action = ActionManager.getInstance().getAction(actionId);
|
||||
Assert.assertNotNull(action);
|
||||
assertNotNull(action);
|
||||
final Presentation presentation = new Presentation();
|
||||
final AnActionEvent event =
|
||||
new AnActionEvent(null, DataManager.getInstance().getDataContext(), "", presentation, ActionManager.getInstance(), 0);
|
||||
@SuppressWarnings("deprecation") final DataContext context = DataManager.getInstance().getDataContext();
|
||||
final AnActionEvent event = new AnActionEvent(null, context, "", presentation, ActionManager.getInstance(), 0);
|
||||
action.update(event);
|
||||
Assert.assertTrue(presentation.isEnabled());
|
||||
action.actionPerformed(event);
|
||||
@@ -411,11 +377,11 @@ public class PlatformTestUtil {
|
||||
}
|
||||
logMessage += ". Expected on my machine: " + expectedOnMyMachine + "." +
|
||||
" Actual: " + actual + "." +
|
||||
" Expected on Etalon machine: " + expected + ";" +
|
||||
" Actual on Etalon: " + actual * Timings.ETALON_TIMING / Timings.MACHINE_TIMING + ";" +
|
||||
" Expected on Standard machine: " + expected + ";" +
|
||||
" Actual on Standard: " + actual * Timings.ETALON_TIMING / Timings.MACHINE_TIMING + ";" +
|
||||
" Timings: CPU=" + Timings.CPU_TIMING +
|
||||
", I/O=" + Timings.IO_TIMING + "." +
|
||||
" (" + (int)(Timings.MACHINE_TIMING*1.0/Timings.ETALON_TIMING*100) + "% of the etalon)" +
|
||||
" (" + (int)(Timings.MACHINE_TIMING*1.0/Timings.ETALON_TIMING*100) + "% of the Standard)" +
|
||||
".";
|
||||
if (actual < expectedOnMyMachine) {
|
||||
System.out.println(logMessage);
|
||||
@@ -465,11 +431,11 @@ public class PlatformTestUtil {
|
||||
private final ThrowableRunnable test; // runnable to measure
|
||||
private final int expected; // millis the test is expected to run
|
||||
private ThrowableRunnable setup; // to run before each test
|
||||
private boolean usesAllCPUCores; // true if the test runs faster on multicore
|
||||
private boolean usesAllCPUCores; // true if the test runs faster on multi-core
|
||||
private int attempts = 4; // number of retries if performance failed
|
||||
private final String message; // to print on fail
|
||||
private boolean adjustForIO = true; // true if test uses IO, timings need to be recalibrated according to this agent disk performance
|
||||
private boolean adjustForCPU = true; // true if test uses CPU, timings need to be recalibrated according to this agent CPU speed
|
||||
private boolean adjustForIO = true; // true if test uses IO, timings need to be re-calibrated according to this agent disk performance
|
||||
private boolean adjustForCPU = true; // true if test uses CPU, timings need to be re-calibrated according to this agent CPU speed
|
||||
|
||||
private TestInfo(@NotNull ThrowableRunnable test, int expected, String message) {
|
||||
this.test = test;
|
||||
@@ -637,7 +603,7 @@ public class PlatformTestUtil {
|
||||
|
||||
Set<String> keySetAfter = mapAfter.keySet();
|
||||
Set<String> keySetBefore = mapBefore.keySet();
|
||||
Assert.assertEquals(keySetAfter, keySetBefore);
|
||||
assertEquals(keySetAfter, keySetBefore);
|
||||
|
||||
for (String name : keySetAfter) {
|
||||
VirtualFile fileAfter = mapAfter.get(name);
|
||||
@@ -662,7 +628,7 @@ public class PlatformTestUtil {
|
||||
ioPaths.add(file.getPath().replace(File.separatorChar, '/'));
|
||||
}
|
||||
|
||||
Assert.assertEquals(sortAndJoin(vfsPaths), sortAndJoin(ioPaths));
|
||||
assertEquals(sortAndJoin(vfsPaths), sortAndJoin(ioPaths));
|
||||
}
|
||||
|
||||
private static String sortAndJoin(List<String> strings) {
|
||||
@@ -699,7 +665,7 @@ public class PlatformTestUtil {
|
||||
: LoadTextUtil.getTextByBinaryPresentation(fileAfter.contentsToByteArray(false), fileAfter).toString();
|
||||
|
||||
if (textA != null && textB != null) {
|
||||
Assert.assertEquals(fileAfter.getPath(), textA, textB);
|
||||
assertEquals(fileAfter.getPath(), textA, textB);
|
||||
}
|
||||
else {
|
||||
Assert.assertArrayEquals(fileAfter.getPath(), fileAfter.contentsToByteArray(), fileBefore.contentsToByteArray());
|
||||
@@ -780,24 +746,11 @@ public class PlatformTestUtil {
|
||||
public int compare(final AbstractTreeNode o1, final AbstractTreeNode o2) {
|
||||
String displayText1 = o1.toTestString(printInfo);
|
||||
String displayText2 = o2.toTestString(printInfo);
|
||||
return displayText1.compareTo(displayText2);
|
||||
return Comparing.compare(displayText1, displayText2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link #createComparator(com.intellij.openapi.ui.Queryable.PrintInfo)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Comparator<AbstractTreeNode> DEFAULT_COMPARATOR = new Comparator<AbstractTreeNode>() {
|
||||
@Override
|
||||
public int compare(AbstractTreeNode o1, AbstractTreeNode o2) {
|
||||
String displayText1 = o1.getTestPresentation();
|
||||
String displayText2 = o2.getTestPresentation();
|
||||
return displayText1.compareTo(displayText2);
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static <T> T notNull(@Nullable T t) {
|
||||
assertNotNull(t);
|
||||
|
||||
Reference in New Issue
Block a user