OLD | NEW |
(Empty) | |
| 1 # Device Setup |
| 2 Tests are runnable on physical devices or emulators. See the instructions below
for setting up either a physical device or an emulator. |
| 3 |
| 4 ## Physical Device Setup |
| 5 **ADB Debugging** |
| 6 |
| 7 In order to allow the ADB to connect to the device, you must enable USB debuggin
g: |
| 8 * Before Android 4.1 (Jelly Bean): |
| 9 * Go to "System Settings" |
| 10 * Go to "Developer options" |
| 11 * Check "USB debugging". |
| 12 * Un-check "Verify apps over USB". |
| 13 * On Jelly Bean, developer options are hidden by default. To unhide them: |
| 14 * Go to "About phone" |
| 15 * Tap 10 times on "Build number" |
| 16 * The "Developer options" menu will now be available. |
| 17 * Check "USB debugging". |
| 18 * Un-check "Verify apps over USB". |
| 19 |
| 20 **Screen** |
| 21 |
| 22 You MUST ensure that the screen stays on while testing: |
| 23 ``` |
| 24 adb shell svc power stayon usb |
| 25 ``` |
| 26 Or do this manually on the device: Settings -> Developer options -> Stay Awake. |
| 27 |
| 28 If this option is greyed out, stay awake is probably disabled by policy. In that
case, get another device or log in with a normal, unmanaged account (because th
e tests will break in exciting ways if stay awake is off). |
| 29 |
| 30 **Enable Asserts!** |
| 31 ``` |
| 32 adb shell setprop debug.assert 1 |
| 33 ``` |
| 34 |
| 35 **Disable Verify Apps** |
| 36 |
| 37 You may see a dialog like [this one](http://www.samsungmobileusa.com/simulators/
ATT_GalaxyMega/mobile/screens/06-02_12.jpg), which states, _Google may regularly
check installed apps for potentially harmful behavior._ This can interfere with
the test runner. To disable this dialog, run: |
| 38 ``` |
| 39 adb shell settings put global package_verifier_enable 0 |
| 40 ``` |
| 41 |
| 42 ## Emulator Setup |
| 43 **Option 1:** |
| 44 |
| 45 Use an emulator (i.e. Android Virtual Device, AVD): Enabling Intel's Virtualizat
on support provides the fastest, most reliable emulator configuration available
(i.e. x86 emulator with GPU acceleration and KVM support). |
| 46 |
| 47 1. Enable Intel Virtualization support in the BIOS. |
| 48 |
| 49 2. Set up your environment: |
| 50 ``` |
| 51 . build/android/envsetup.sh |
| 52 ``` |
| 53 3. Install emulator deps: |
| 54 ``` |
| 55 build/android/install_emulator_deps.py --api-level=19 |
| 56 ``` |
| 57 This script will download Android SDK and place it a directory called android\_t
ools in the same parent directory as your chromium checkout. It will also downlo
ad the system-images for the emulators (i.e. arm and x86). Note that this is a d
ifferent SDK download than the Android SDK in the chromium source checkout (i.e.
src/third\_party/android\_emulator\_sdk). |
| 58 |
| 59 4. Run the avd.py script. To start up _num_ emulators use -n. For non-x86 use --
abi. |
| 60 ``` |
| 61 build/android/avd.py --api-level=19 |
| 62 ``` |
| 63 > This script will attempt to use GPU emulation, so you must be running the emul
ators in an environment with hardware rendering available. See `avd.py --help` f
or more details. |
| 64 |
| 65 **Option 2:** |
| 66 |
| 67 Alternatively, you can create an run your own emulator using the tools provided
by the Android SDK. When doing so, be sure to enable GPU emulation in hardware s
ettings, since Chromium requires it to render. |
| 68 |
| 69 # Building Tests |
| 70 It may not be immediately obvious where your test code gets compiled to, so here
are some general rules: |
| 71 * If your test code lives under /content, it will probably be built as part of
the content\_shell\_test\_apk |
| 72 * If your test code lives under /chrome (or higher), it will probably be built
as part of the chrome\_shell\_test\_apk |
| 73 * (Please fill in more details here if you know them) |
| 74 NB: We used to call the chrome\_shell\_test\_apk the chromium\_shell\_test\_apk.
There may still be references to this kicking around, but wherever you see chro
mium\_shell\_test you should replace with chrome\_shell\_test. |
| 75 |
| 76 Once you know what to build, just do it like you normally would build anything e
lse, e.g.: |
| 77 ``` |
| 78 ninja -C out/Release chrome_shell_test_apk |
| 79 ``` |
| 80 |
| 81 # Running Tests |
| 82 All functional tests are run using `build/android/test_runner.py`. Tests are sha
rded across all attached devices. In order to run tests, call: |
| 83 ``` |
| 84 build/android/test_runner.py <test_type> [options] |
| 85 ``` |
| 86 For a list of valid test types, see `test_runner.py --help`. For help on a speci
fic test type, run `test_runner.py <test_type> --help`. |
| 87 |
| 88 The commands used by the buildbots are printed in the logs. Look at http://build
.chromium.org/ to duplicate the same test command as a particular builder. |
| 89 |
| 90 If you build in an output directory other than "out", you may have to tell test\
_runner.py where you place it. Say you build your android code in out\_android,
then do `export CHROMIUM_OUT_DIR=out_android` before running the command below. |
| 91 |
| 92 ## INSTALL\_FAILED\_CONTAINER\_ERROR or INSTALL\_FAILED\_INSUFFICIENT\_STORAGE |
| 93 If you see this error when test\_runner.py is attempting to deploy the test bina
ries to the AVD emulator, you may need to resize your userdata partition with th
e following commands: |
| 94 ``` |
| 95 # Resize userdata partition to be 1G |
| 96 resize2fs android_emulator_sdk/sdk/system-images/android-19/x86/userdata.img 1G |
| 97 # Set filesystem parameter to continue on errors; Android doesn't like some thin
gs e2fsprogs does. |
| 98 tune2fs -e continue android_emulator_sdk/sdk/system-images/android-19/x86/userda
ta.img |
| 99 ``` |
| 100 |
| 101 ## Symbolizing Crashes |
| 102 Crash stacks are logged and can be viewed using adb logcat. To symbolize the tra
ces, pipe the output through `third_party/android_platform/development/scripts/s
tack`. If you build in an output directory other than "out", pass `--chrome-symb
ols-dir=out_directory/{Debug,Release}/lib` to the script as well. |
| 103 |
| 104 ## Gtests |
| 105 ``` |
| 106 // Build a test suite |
| 107 ninja -C out/Release content_unittests_apk |
| 108 |
| 109 // Run a test suite |
| 110 build/android/test_runner.py gtest -s content_unittests --release -vvv |
| 111 |
| 112 // Run a subset of tests |
| 113 build/android/test_runner.py gtest -s content_unittests --release -vvv --gtest-f
ilter ByteStreamTest.* |
| 114 ``` |
| 115 |
| 116 ## Instrumentation Tests |
| 117 |
| 118 In order to run instrumentation tests, you must leave your device screen ON and
UNLOCKED. Otherwise, the test will timeout trying to launch an intent. Optionall
y you can disable screen lock under Settings -> Security -> Screen Lock -> None. |
| 119 |
| 120 Next, you need to build the app, build your tests, install the application APK,
and then run your tests (which will install the test APK automatically). Example
s: |
| 121 |
| 122 ContentShell tests: |
| 123 ``` |
| 124 # Build the code under test |
| 125 ninja -C out/Release content_shell_apk |
| 126 # Build the tests themselves |
| 127 ninja -C out/Release content_shell_test_apk |
| 128 # Install the code under test |
| 129 build/android/adb_install_apk.py out/Release/apks/ContentShell.apk |
| 130 # Run the test (will automagically install the test APK) |
| 131 build/android/test_runner.py instrumentation --test-apk=ContentShellTest --isola
te-file-path content/content_shell_test_apk.isolate --release -vv |
| 132 ``` |
| 133 ChromeShell tests: |
| 134 ``` |
| 135 # Build the code under test |
| 136 ninja -C out/Release chrome_shell_apk |
| 137 # Build the tests themselves |
| 138 ninja -C out/Release chrome_shell_test_apk |
| 139 # Install the code under test |
| 140 build/android/adb_install_apk.py out/Release/apks/ChromeShell.apk |
| 141 # Run the test (will automagically install the test APK) |
| 142 build/android/test_runner.py instrumentation --test-apk=ChromeShellTest --isolat
e-file-path chrome/chrome_shell_test_apk.isolate --release -vv |
| 143 ``` |
| 144 AndroidWebView tests: |
| 145 ``` |
| 146 ninja -C out/Release android_webview_apk |
| 147 ninja -C out/Release android_webview_test_apk |
| 148 build/android/adb_install_apk.py out/Release/apks/AndroidWebView.apk |
| 149 build/android/test_runner.py instrumentation --test-apk=AndroidWebViewTest --tes
t_data webview:android_webview/test/data/device_files --release -vvv |
| 150 ``` |
| 151 |
| 152 Use adb\_install\_apk.py to install the app under test, then run the test comman
d. In order to run a subset of tests, use -f to filter based on test class/metho
d or -A/-E to filter using annotations. |
| 153 |
| 154 Filtering examples: |
| 155 ``` |
| 156 // Run a test suite |
| 157 build/android/test_runner.py instrumentation --test-apk=ContentShellTest |
| 158 |
| 159 // Run a specific test class |
| 160 build/android/test_runner.py instrumentation --test-apk=ContentShellTest -f Addr
essDetectionTest |
| 161 |
| 162 // Run a specific test method |
| 163 build/android/test_runner.py instrumentation --test-apk=ContentShellTest -f Addr
essDetectionTest#testAddressLimits |
| 164 |
| 165 // Run a subset of tests by size (Smoke, SmallTest, MediumTest, LargeTest, Enorm
ousTest) |
| 166 build/android/test_runner.py instrumentation --test-apk=ContentShellTest -A Smok
e |
| 167 |
| 168 // Run a subset of tests by annotation, such as filtering by Feature |
| 169 build/android/test_runner.py instrumentation --test-apk=ContentShellTest -A Feat
ure=Navigation |
| 170 ``` |
| 171 |
| 172 You might want to add stars `*` to each as a regular expression, e.g. `*`Address
DetectionTest`*` |
| 173 |
| 174 # Running Blink Layout Tests |
| 175 See https://sites.google.com/a/chromium.org/dev/developers/testing/webkit-layout
-tests |
| 176 |
| 177 # Running GPU tests (e.g. the "Android Debug (Nexus 7)" bot on the chromium.gpu
waterfall) |
| 178 |
| 179 See http://www.chromium.org/developers/testing/gpu-testing for details. Use --br
owser=android-content-shell. Examine the stdio from the test invocation on the b
ots to see arguments to pass to src/content/test/gpu/run\_gpu\_test.py. |
OLD | NEW |