diff options
author | jbudorick <jbudorick@chromium.org> | 2015-06-12 06:06:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-12 13:06:54 +0000 |
commit | b049103fa4848e304102a24e78c6ba994130a535 (patch) | |
tree | 3dc71fa65201527d337aedc11dba4c2fe51c1e07 /components/test | |
parent | 23490d44633f4eaeb76e03384e08e9fd3ef2909a (diff) | |
download | chromium_src-b049103fa4848e304102a24e78c6ba994130a535.zip chromium_src-b049103fa4848e304102a24e78c6ba994130a535.tar.gz chromium_src-b049103fa4848e304102a24e78c6ba994130a535.tar.bz2 |
[Android] Refactor browser test execution.
This change allows us to run multiple browser tests within a single
invocation of an app. It does so by moving the test activity into its
own process, running each test individually within that activity, and
killing the process between each test.
BUG=472360
Review URL: https://codereview.chromium.org/1165523002
Cr-Commit-Position: refs/heads/master@{#334149}
Diffstat (limited to 'components/test')
4 files changed, 23 insertions, 41 deletions
diff --git a/components/test/DEPS b/components/test/DEPS index ec6ab2f..88da157 100644 --- a/components/test/DEPS +++ b/components/test/DEPS @@ -7,6 +7,7 @@ include_rules = [ "+content/public/app/content_main.h", "+content/public/common/content_switches.h", "+content/public/test", + "+content/shell/android/browsertests", "+content/shell/android/java/src/org/chromium/content_shell", "+content/shell/android/shell_jni_registrar.h", "+content/shell/app/shell_main_delegate.h", diff --git a/components/test/android/browsertests_apk/AndroidManifest.xml.jinja2 b/components/test/android/browsertests_apk/AndroidManifest.xml.jinja2 index 97dae9e..e2b2f15 100644 --- a/components/test/android/browsertests_apk/AndroidManifest.xml.jinja2 +++ b/components/test/android/browsertests_apk/AndroidManifest.xml.jinja2 @@ -15,7 +15,8 @@ android:launchMode="singleTask" android:theme="@android:style/Theme.Holo.Light.NoActionBar" android:configChanges="orientation|keyboardHidden|keyboard|screenSize" - android:hardwareAccelerated="true"> + android:hardwareAccelerated="true" + android:process=":test_process"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> diff --git a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java index ae94edc..77264b3 100644 --- a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java +++ b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsActivity.java @@ -5,29 +5,16 @@ package org.chromium.components_browsertests_apk; import android.os.Bundle; -import android.view.Window; -import android.view.WindowManager; - -import org.chromium.base.Log; -import org.chromium.base.annotations.SuppressFBWarnings; -import org.chromium.base.library_loader.LibraryLoader; -import org.chromium.base.library_loader.LibraryProcessType; -import org.chromium.base.library_loader.ProcessInitException; -import org.chromium.content.browser.BrowserStartupController; -import org.chromium.content_shell.ShellManager; -import org.chromium.native_test.NativeBrowserTestActivity; -import org.chromium.ui.base.ActivityWindowAndroid; -import org.chromium.ui.base.WindowAndroid; + +import org.chromium.base.PathUtils; +import org.chromium.content_shell.browsertests.ContentShellBrowserTestActivity; + +import java.io.File; /** * Android activity for running components browser tests */ -public class ComponentsBrowserTestsActivity extends NativeBrowserTestActivity { - private static final String TAG = Log.makeTag("native_test"); - - private ShellManager mShellManager; - private WindowAndroid mWindowAndroid; - +public class ComponentsBrowserTestsActivity extends ContentShellBrowserTestActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -36,25 +23,18 @@ public class ComponentsBrowserTestsActivity extends NativeBrowserTestActivity { } @Override - @SuppressFBWarnings("DM_EXIT") - protected void initializeBrowserProcess() { - try { - LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(); - } catch (ProcessInitException e) { - Log.e(TAG, "Cannot load components_browsertests.", e); - System.exit(-1); - } - BrowserStartupController.get(getApplicationContext(), LibraryProcessType.PROCESS_BROWSER) - .initChromiumBrowserProcessForTests(); - - setContentView(R.layout.test_activity); - mShellManager = (ShellManager) findViewById(R.id.shell_container); - mWindowAndroid = new ActivityWindowAndroid(this); - mShellManager.setWindow(mWindowAndroid, false); - - Window wind = this.getWindow(); - wind.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); - wind.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); - wind.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + protected File getPrivateDataDirectory() { + return new File(PathUtils.getExternalStorageDirectory(), + ComponentsBrowserTestsApplication.PRIVATE_DATA_DIRECTORY_SUFFIX); + } + + @Override + protected int getTestActivityViewId() { + return R.layout.test_activity; + } + + @Override + protected int getShellManagerViewId() { + return R.id.shell_container; } } diff --git a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java index 91ee597..ffcea44 100644 --- a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java +++ b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java @@ -17,7 +17,7 @@ public class ComponentsBrowserTestsApplication extends BaseChromiumApplication { private static final String[] MANDATORY_PAK_FILES = new String[] {"components_tests_resources.pak", "content_shell.pak", "icudtl.dat", "natives_blob.bin", "snapshot_blob.bin"}; - private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "components_shell"; + static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "components_shell"; @Override public void onCreate() { |