Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartReconcilingStrategyTest.java

Issue 22950010: Version 0.6.17.4 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/tools/VERSION » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartReconcilingStrategyTest.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartReconcilingStrategyTest.java (revision 26105)
+++ dart/editor/tools/plugins/com.google.dart.tools.ui_test/src/com/google/dart/tools/ui/internal/text/dart/DartReconcilingStrategyTest.java (working copy)
@@ -46,6 +46,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
public class DartReconcilingStrategyTest extends TestCase {
@@ -225,7 +226,7 @@
* Mock editor for testing {@link DartReconcilingStrategy}
*/
private final class MockEditor implements DartReconcilingEditor {
- private CountDownLatch appliedLatch = null;
+ private Semaphore applied = null;
private CompilationUnit appliedUnit = null;
private DisposeListener disposeListener = null;
private FocusListener focusListener = null;
@@ -249,13 +250,13 @@
@Override
public void applyCompilationUnitElement(CompilationUnit unit) {
appliedUnit = unit;
- if (appliedLatch != null) {
- appliedLatch.countDown();
+ if (applied != null) {
+ applied.release();
}
}
public void expectApply() {
- appliedLatch = new CountDownLatch(1);
+ applied = new Semaphore(0);
appliedUnit = null;
}
@@ -284,16 +285,15 @@
return mockSource.getShortName();
}
- public CompilationUnit waitForApply(long milliseconds, boolean expectAnother) {
- if (appliedLatch == null) {
+ public CompilationUnit waitForApply(long milliseconds) {
+ if (applied == null) {
throw new IllegalStateException("Call expectApply");
}
try {
- assertTrue(appliedLatch.await(milliseconds, TimeUnit.MILLISECONDS));
+ assertTrue(applied.tryAcquire(milliseconds, TimeUnit.MILLISECONDS));
} catch (InterruptedException e) {
- assertEquals(0, appliedLatch.getCount());
+ assertTrue(applied.tryAcquire());
}
- appliedLatch = expectAnother ? new CountDownLatch(1) : null;
return appliedUnit;
}
}
@@ -335,11 +335,12 @@
strategy.initialReconcile();
- assertNotNull(mockEditor.waitForApply(5000, true));
+ assertNotNull(mockEditor.waitForApply(5000));
CompilationUnit unit = mockContext.waitForResolution(mockSource, 5000);
assertNotNull(unit);
- assertSame(unit, mockEditor.waitForApply(5000, false));
- List<Source> priorityOrder = mockContext.waitForSetPriorityOrder(5000);
+ unit = mockEditor.waitForApply(5000);
+ assertNotNull(unit);
+ List<Source> priorityOrder = mockContext.waitForSetPriorityOrder(15000);
assertEquals(1, priorityOrder.size());
assertSame(mockSource, priorityOrder.get(0));
mockContext.assertPrioritySetBeforeBackgroundAnalysis();
@@ -360,11 +361,12 @@
strategy.initialReconcile();
- assertNotNull(mockEditor.waitForApply(5000, true));
+ assertNotNull(mockEditor.waitForApply(5000));
CompilationUnit unit = mockContext.waitForResolution(mockSource, 5000);
assertNotNull(unit);
- assertSame(unit, mockEditor.waitForApply(5000, false));
- List<Source> priorityOrder = mockContext.waitForSetPriorityOrder(5000);
+ unit = mockEditor.waitForApply(5000);
+ assertNotNull(unit);
+ List<Source> priorityOrder = mockContext.waitForSetPriorityOrder(15000);
assertEquals(1, priorityOrder.size());
assertSame(mockSource, priorityOrder.get(0));
mockContext.assertPrioritySetBeforeBackgroundAnalysis();
@@ -382,7 +384,7 @@
strategy.initialReconcile();
- assertSame(unit, mockEditor.waitForApply(5000, false));
+ assertSame(unit, mockEditor.waitForApply(5000));
List<Source> priorityOrder = mockContext.waitForSetPriorityOrder(5000);
assertEquals(1, priorityOrder.size());
assertSame(mockSource, priorityOrder.get(0));
@@ -418,15 +420,15 @@
mockEditor.expectApply();
strategy.initialReconcile();
- assertNotNull(mockEditor.waitForApply(5000, false));
+ assertNotNull(mockEditor.waitForApply(5000));
mockEditor.expectApply();
mockDocument.replace(0, 0, newText);
- assertNull(mockEditor.waitForApply(5000, false));
+ assertNull(mockEditor.waitForApply(5000));
mockEditor.expectApply();
strategy.reconcile(new DirtyRegion(0, 0, DirtyRegion.INSERT, newText), new Region(0, 0));
- CompilationUnit unit = mockEditor.waitForApply(5000, false);
+ CompilationUnit unit = mockEditor.waitForApply(5000);
assertNotNull(unit);
}
@@ -449,15 +451,15 @@
mockEditor.expectApply();
strategy.initialReconcile();
- assertNotNull(mockEditor.waitForApply(5000, false));
+ assertNotNull(mockEditor.waitForApply(5000));
mockEditor.expectApply();
mockDocument.replace(0, 0, newText);
- assertNull(mockEditor.waitForApply(5000, false));
+ assertNull(mockEditor.waitForApply(5000));
mockEditor.expectApply();
strategy.reconcile(new Region(0, newText.length()));
- CompilationUnit unit = mockEditor.waitForApply(5000, false);
+ CompilationUnit unit = mockEditor.waitForApply(5000);
assertNotNull(unit);
}
« no previous file with comments | « no previous file | dart/tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698