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

Unified Diff: build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java

Issue 1557103002: Make _incremental usable by instrumentation tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apposed -> opposed 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
index 67c60e5e14e1eefa256ba9546ca2d791f6ee1a11..7c9bcca2ca1757405196b7a48b5cb2075b9c7a8c 100644
--- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
+++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java
@@ -118,7 +118,7 @@ public final class BootstrapApplication extends Application {
ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(),
PackageManager.GET_META_DATA);
String value = appInfo.metaData.getString(key);
- if (!value.contains(".")) {
+ if (value != null && !value.contains(".")) {
value = getPackageName() + "." + value;
}
return value;
@@ -129,11 +129,22 @@ public final class BootstrapApplication extends Application {
*/
private void initInstrumentation(String realInstrumentationName)
throws ReflectiveOperationException {
+ Instrumentation oldInstrumentation =
+ (Instrumentation) Reflect.getField(mActivityThread, "mInstrumentation");
+ if (realInstrumentationName == null) {
+ // This is the case when an incremental app is used as a target for an instrumentation
+ // test. In this case, ActivityThread can instantiate the proper class just fine since
+ // it exists within the test apk (as opposed to the incremental apk-under-test).
+ Log.i(TAG, "Running with external instrumentation");
+ mRealInstrumentation = oldInstrumentation;
+ return;
+ }
+ // For unit tests, the instrumentation class is replaced in the manifest by a build step
+ // because ActivityThread tries to instantiate it before we get a chance to load the
+ // incremental dex files.
Log.i(TAG, "Instantiating instrumentation " + realInstrumentationName);
mRealInstrumentation = (Instrumentation) Reflect.newInstance(
Class.forName(realInstrumentationName));
- Instrumentation oldInstrumentation =
- (Instrumentation) Reflect.getField(mActivityThread, "mInstrumentation");
// Initialize the fields that are set by Instrumentation.init().
String[] initFields = {"mThread", "mMessageQueue", "mInstrContext", "mAppContext",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698