blob: 4bf32cdefbd66fdf1b5ac1ae2de9e3fb31ea5369 [file] [log] [blame]
Alan Viverettec15ea9f2015-08-26 16:33:17 -04001* Copyright (C) 2015 The Android Open Source Project
2*
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14
15
16INTRODUCTION
17
18The Android theme tests ensure that the Holo and Material themes have not been
19modified. They consist of API-specific sets of reference images representing
20specific themes and widgets that must be identical across devices. To pass the
21theme tests, a device must be able to generate images that are identical to the
22reference images.
23
24NOTE: Reference images should only be updated by the CTS test maintainers. Any
25 modifications to the reference images will invalidate the test results.
26
27
28INSTRUCTIONS
29
30I. Generating reference images (CTS maintainers only)
31
32Reference images are typically only generated for new API revisions. To
Alan Viverette7d87cea2017-09-26 13:39:21 -040033generate a new set of reference images from an emulator, do the following:
Alan Viverettec15ea9f2015-08-26 16:33:17 -040034
Alan Viverette7d87cea2017-09-26 13:39:21 -040035 1. Ensure the Android SDK is installed locally. Either a public or internal
36 distribution is fine. From the console, set the ANDROID_SDK_ROOT env var:
Alan Viverette598c6922017-04-28 18:32:23 -040037
Alan Viverette7d87cea2017-09-26 13:39:21 -040038 export ANDROID_SDK_ROOT = /path/to/sdk
Alan Viverette598c6922017-04-28 18:32:23 -040039
Alan Viverette7d87cea2017-09-26 13:39:21 -040040 2. Obtain an x86_64 emulator image from the build server by using the script
41 available internally at go/emu-dev. This script will install the image in
42 your SDK.
Alan Viverette598c6922017-04-28 18:32:23 -040043
Alan Viverette7d87cea2017-09-26 13:39:21 -040044 3. Use the SDK's AVD Manager tool to create a single virtual device using the
45 emulator image from step 2. The exact configuration doesn't really matter;
46 you can use Nexus 5 as a template. Name the emulator "theme_emulator".
Alan Viverettec15ea9f2015-08-26 16:33:17 -040047
Alan Viverette7d87cea2017-09-26 13:39:21 -040048 4. From the console, set up your build environment for x86_64 and build CTS:
Alan Viverette598c6922017-04-28 18:32:23 -040049
50 lunch sdk_x86_64-eng && make cts -j32
51
Alan Viverette7d87cea2017-09-26 13:39:21 -040052 5. Use the reference image script to generate the reference images. The script
53 will automatically start the emulator in the required configurations and
54 install the resulting reference images in assets/<platform>/<dpi>.zip,
55 overwriting any existing images.
Alan Viverettec15ea9f2015-08-26 16:33:17 -040056
Alan Viverette7d87cea2017-09-26 13:39:21 -040057 ./cts/hostsidetests/theme/generate_images.py theme_emulator
58
59You can also generate reference images using a real device. To generate a new set
60of reference images from a real device, do the following:
61
62 1. Connect the device. Verify the device is connected:
63
64 adb devices
65
66 2. Use the reference image script to generate the reference images:
67
68 ./cts/hostsidetests/theme/generate_images.py
Alan Viverettec15ea9f2015-08-26 16:33:17 -040069
Stan Iliev3baab432017-11-10 11:28:48 -050070There is an option to build locally an Android system image and use an emulator that is stored in
71Android source tree under "prebuilts/android-emulator/linux-x86_64/emulator". This option does not
72require a SDK and can be used to generate images with locally modified source code: for example
73right before making a test breaking change.
74
75 1. From the console, set up your build environment for sdk_phone_x86_64 and build Android and CTS:
76
77 lunch sdk_phone_x86_64-userdebug && make -j32 && make cts -j32
78
79 2. Use the reference image script to generate the reference images. The script
80 will automatically start the emulator in the required configurations and
81 install the resulting reference images in assets/<platform>/<dpi>.zip,
82 overwriting any existing images.
83
84 ./cts/hostsidetests/theme/generate_images.py local
85
Alan Viverettec15ea9f2015-08-26 16:33:17 -040086A complete collection of reference images for a given API revision must include
87a set for each possible DPI bucket (tvdpi, xxhdpi, etc.) that may be tested.
88
Alan Viverette4f560b62016-06-06 09:58:40 -040089For a list of devices and their DPI buckets, see Device Metrics:
90
91 https://design.google.com/devices/
92
Alan Viverettec15ea9f2015-08-26 16:33:17 -040093
94II. Building theme tests
95
961. If you have not already built the CTS tests, run an initial make:
97
98 make cts -j32
99
1002. Subsequent changes to the theme tests, including changes to the reference
101 images, may be built using mmm:
102
103 mmm cts/hostsidetests/theme -j32
104
105
106III. Running theme tests
107
Alan Viveretteb246d962016-08-03 12:38:20 -0400108To obtain reliable results, theme tests should be run against the device's
109native density; however, many of the tests will also work in a scaled density.
110If you don't possess a device for a given density and would still like to run
111tests for that density, you can manually force scaling via:
Alan Viverettec15ea9f2015-08-26 16:33:17 -0400112
Alan Viveretteb246d962016-08-03 12:38:20 -0400113 adb shell wm density <dpi>
Alan Viverettec15ea9f2015-08-26 16:33:17 -0400114
Alan Viveretteb246d962016-08-03 12:38:20 -0400115As of API 24, the results will NOT be 100% reliable due to scaling artifacts.
116To reset the device to its native density, run:
Alan Viverettec15ea9f2015-08-26 16:33:17 -0400117
Alan Viveretteb246d962016-08-03 12:38:20 -0400118 adb shell wm density reset
Alan Viverettec15ea9f2015-08-26 16:33:17 -0400119
Alan Viveretteb246d962016-08-03 12:38:20 -0400120Once the device is in the desired state, do the following:
121
122 1. Connect the device that you wish to test. Confirm that is is connected with:
123
124 adb devices
125
126 2. Run the theme tests using cts-tradefed:
127
128 cts-tradefed run singleCommand cts-dev --module CtsThemeHostTestCases \
129 --test android.theme.cts.ThemeHostTest
130
131 3. Wait for the tests to complete. This should take less than five minutes.
132
Alan Viverette40115c42017-04-04 13:11:08 -0400133If any test failures are encountered, diff PNGs will be generated and collected
134in the "diffs" directory of the CTS results indicated by "Test Result:" in the
135test output.