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

Unified Diff: base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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: base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java
diff --git a/base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java b/base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java
index 53dee4ab14594c4faeb99c8db7ff5be2e61e716c..4c7f3b88c4af9989b93000a5d9604607ed5e7e68 100644
--- a/base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java
+++ b/base/test/android/javatests/src/org/chromium/base/test/BaseActivityInstrumentationTestCase.java
@@ -10,17 +10,8 @@ import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
-import org.chromium.base.BaseChromiumApplication;
-import org.chromium.base.CommandLine;
import org.chromium.base.test.util.CommandLineFlags;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* Base class for all Activity-based Instrumentation tests.
*
@@ -43,26 +34,10 @@ public class BaseActivityInstrumentationTestCase<T extends Activity>
super(activityClass);
}
- /**
- * Sets up the CommandLine with the appropriate flags.
- *
- * This will add the difference of the sets of flags specified by {@link CommandLineFlags.Add}
- * and {@link CommandLineFlags.Remove} to the {@link org.chromium.base.CommandLine}. Note that
- * trying to remove a flag set externally, i.e. by the command-line flags file, will not work.
- */
@Override
protected void setUp() throws Exception {
super.setUp();
-
- CommandLine.reset();
- Context targetContext = getTargetContext();
- assertNotNull("Unable to get a non-null target context.", targetContext);
-
- BaseChromiumApplication.initCommandLine(targetContext);
- Set<String> flags = getFlags(getClass().getMethod(getName()));
- for (String flag : flags) {
- CommandLine.getInstance().appendSwitch(flag);
- }
+ CommandLineFlags.setUp(getTargetContext(), getClass().getMethod(getName()));
}
/**
@@ -88,31 +63,4 @@ public class BaseActivityInstrumentationTestCase<T extends Activity>
}
return targetContext;
}
-
- private static Set<String> getFlags(AnnotatedElement element) {
- AnnotatedElement parent = (element instanceof Method)
- ? ((Method) element).getDeclaringClass()
- : ((Class) element).getSuperclass();
- Set<String> flags = (parent == null) ? new HashSet<String>() : getFlags(parent);
-
- if (element.isAnnotationPresent(CommandLineFlags.Add.class)) {
- flags.addAll(
- Arrays.asList(element.getAnnotation(CommandLineFlags.Add.class).value()));
- }
-
- if (element.isAnnotationPresent(CommandLineFlags.Remove.class)) {
- List<String> flagsToRemove =
- Arrays.asList(element.getAnnotation(CommandLineFlags.Remove.class).value());
- for (String flagToRemove : flagsToRemove) {
- // If your test fails here, you have tried to remove a command-line flag via
- // CommandLineFlags.Remove that was loaded into CommandLine via something other
- // than CommandLineFlags.Add (probably the command-line flag file).
- assertFalse("Unable to remove command-line flag \"" + flagToRemove + "\".",
- CommandLine.getInstance().hasSwitch(flagToRemove));
- }
- flags.removeAll(flagsToRemove);
- }
-
- return flags;
- }
}

Powered by Google App Engine
This is Rietveld 408576698