Changes

Jump to: navigation, search

Mobile/Fennec/Android/Testing

924 bytes removed, 20:40, 8 February 2019
Running tests on the Android emulator
== Running tests on the Android emulator ==
The "Android 4.3 API16+ opt" and "Android 4.3 API16+ debug" tests on treeherder run in an Android ARM emulator. "Android 47.2 x86 0 x86_64 opt/debug" tests run in an Android x86 emulator. For best results reproducing test failures, try server is recommended: '''Running the same tests on the same emulator on different host hardware may produce different results'''.
Still, if you want to run the emulator locally, using the same Android image used for tests on treeherder, it is simple:
That 'android-emulator' command will download the Android 4.3 API16+ Android image from tooltool, install it, and launch the Android emulator using all the same parameters used for tests on treeherder. (The Android SDK must be installed locally. mach will try to find the emulator binary in your $PATH environment variable, via the $ANDROID_SDK_ROOT environment variable, through your Android build configuration, and finally in the default location used by 'mach bootstrap'.)
To use the Android 47.2 x86 0 x86_64 image:
./mach android-emulator --version x86-7.0
(On Linux, the x86 emulator requires that kvm is installed. The resulting emulator is '''much ''' faster than the arm emulator.)
The first time you run an emulator with any particular version, it may take several minutes to download and install the image; subsequent runs will be '''much''' faster.
./mach android-emulator && ./mach install && ./mach mochitest
For the '''very''' lazyyour convenience, most mach test commands check that an Android device is connected; if not, they suggest running an emulator. Similarly, if tests are requested on a device that doesn't have Firefox installed, mach will offer to install it. So if you just run "mach mochitest" without a phone connected and without an emulator running, you might get:
$ ./mach mochitest testing/mochitest/tests/Harness_sanity
0:01.82 TEST_START: MainThread testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPermissions.html
...
 
=== Testing with stock AVD images (Android 4.x+ only) ===
 
Testing with the above configurations is ideal, but in some cases you may prefer to use stock AVD device images from the Nexus profiles available.
 
# From the Android Virtual Device (AVD) Manager, click 'Create....'
# Choose a Nexus phone or tablet device configuration. (Nexus 9 for tablets, Nexus 5 for phones is recommended).
# Choose a system image with API level 16 or 18. (If you're not sure if you want arm or x86 then you probably want arm). If no suitable image is available, one can be installed with the Android SDK Manager.
# Next, check 'Use Host GPU' if possible. See [http://developer.android.com/tools/devices/emulator.html#acceleration Using Hardware Acceleration].
# Hit Finish and that should be it. If you have setup Firefox for Android to [[Mobile/Fennec/Android/IDEs|run on your IDE]], you should be able to launch the emulator straight from there as well.
=== Multiple emulators/devices ===
It's also is possible to test with multiple emulators or devices using the --deviceSerial argument:
$ adb devices
List of devices attached
Confirm
1,753
edits

Navigation menu