• Home
Name Date Size #Lines LOC

..--

app/03-May-2024-2,5881,251

assets/03-May-2024-

src/android/theme/cts/03-May-2024-531383

Android.bpD03-May-20241.4 KiB4744

AndroidTest.xmlD03-May-20241.6 KiB3217

OWNERSD03-May-202458 33

READMED03-May-20245.1 KiB13687

android_device.pyD03-May-20244.6 KiB13690

avd.pyD03-May-20242.7 KiB8653

generate_images.pyD03-May-20247.8 KiB265193

README

1* 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
33generate a new set of reference images from an emulator, do the following:
34
35  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:
37
38     export ANDROID_SDK_ROOT = /path/to/sdk
39
40  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.
43
44  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".
47
48  4. From the console, set up your build environment for x86_64 and build CTS:
49
50     source build/envsetup.sh && lunch sdk_x86_64-eng && make cts -j32
51
52  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.
56
57     ./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
69
70There 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
86A 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
89For a list of devices and their DPI buckets, see Device Metrics:
90
91    https://design.google.com/devices/
92
93
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
108To 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:
112
113  adb shell wm density <dpi>
114
115As of API 24, the results will NOT be 100% reliable due to scaling artifacts.
116To reset the device to its native density, run:
117
118  adb shell wm density reset
119
120Once 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
133If 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.
136