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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/analysis/AnalysisTestUtilities.java

Issue 10809037: Fix library scan of loose files (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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
Index: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/analysis/AnalysisTestUtilities.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/analysis/AnalysisTestUtilities.java (revision 9776)
+++ editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/analysis/AnalysisTestUtilities.java (working copy)
@@ -17,6 +17,12 @@
import static junit.framework.Assert.fail;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+
public class AnalysisTestUtilities {
/**
@@ -49,4 +55,69 @@
public static void waitForIdle(long milliseconds) {
waitForIdle(SystemLibraryManagerProvider.getDefaultAnalysisServer(), milliseconds);
}
+
+ static void assertQueuedTasks(AnalysisServer server, String... expectedTaskNames)
+ throws Exception {
+ Task[] actualTasks = getServerTaskQueue(server).getTasks();
+ int index = 0;
+ for (String name : expectedTaskNames) {
+ if (index >= actualTasks.length) {
+ fail("Expected task(" + index + ") to be " + name + ", but end of queue");
+ }
+ String taskClassName = actualTasks[index].getClass().getSimpleName();
+ if (!name.equals(taskClassName)) {
+ fail("Expected task(" + index + ") to be " + name + ", but found " + taskClassName);
+ }
+ index++;
+ }
+ if (index < actualTasks.length) {
+ String message = "Expected " + expectedTaskNames.length + " tasks, but found "
+ + actualTasks.length;
+ while (index < actualTasks.length) {
+ message += "\n " + actualTasks[index].getClass().getSimpleName();
+ index++;
+ }
+ fail(message);
+ }
+ }
+
+ static void assertTrackedLibraryFiles(AnalysisServer server, File... expected) throws Exception {
+ File[] actual = getTrackedLibraryFiles(server);
+ if (actual.length == expected.length) {
+ HashSet<File> files = new HashSet<File>();
+ files.addAll(Arrays.asList(actual));
+ if (actual.length == files.size()) {
+ for (File file : expected) {
+ if (!files.remove(file)) {
+ break;
+ }
+ }
+ }
+ if (files.size() == 0) {
+ return;
+ }
+ }
+ String msg = "Expected:";
+ for (File file : expected) {
+ msg += "\n " + file;
+ }
+ msg += "\nbut found:";
+ for (File file : actual) {
+ msg += "\n " + file;
+ }
+ fail(msg);
+ }
+
+ static TaskQueue getServerTaskQueue(AnalysisServer server) throws Exception {
+ Field field = AnalysisServer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ return (TaskQueue) field.get(server);
+ }
+
+ static File[] getTrackedLibraryFiles(AnalysisServer server) throws Exception {
+ Method method = AnalysisServer.class.getDeclaredMethod("getTrackedLibraryFiles");
+ method.setAccessible(true);
+ Object result = method.invoke(server);
+ return (File[]) result;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698