Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 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 | |
| 16 | INTRODUCTION |
| 17 | |
| 18 | The Android theme tests ensure that the Holo and Material themes have not been |
| 19 | modified. They consist of API-specific sets of reference images representing |
| 20 | specific themes and widgets that must be identical across devices. To pass the |
| 21 | theme tests, a device must be able to generate images that are identical to the |
| 22 | reference images. |
| 23 | |
| 24 | NOTE: 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 | |
| 28 | INSTRUCTIONS |
| 29 | |
| 30 | I. Generating reference images (CTS maintainers only) |
| 31 | |
| 32 | Reference images are typically only generated for new API revisions. To |
| 33 | generate a new set of reference images, do the following: |
| 34 | |
Alan Viverette | 598c692 | 2017-04-28 18:32:23 -0400 | [diff] [blame] | 35 | 1. Obtain the emulator image for the current platform. You can either build |
| 36 | these from scratch (not recommended) via: |
| 37 | |
| 38 | make PRODUCT-sdk_phone_x86_64-sdk sdk_repo -j32 |
| 39 | |
| 40 | Or obtain them from the sdk-repo-linux-system-images-<build-id>.zip |
| 41 | artifact from the sdk_phone_x86_64-sdk build server target. |
| 42 | |
| 43 | 2. Start one AVD emulator image for each DPI bucket (ldpi, xxxhdpi, etc.) |
| 44 | that you wish to generate references images for. Anecdotally, up to three |
| 45 | emulators can run reliably at the same time. Confirm that all emulators |
| 46 | are connected with: |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 47 | |
| 48 | adb devices |
| 49 | |
Alan Viverette | 598c692 | 2017-04-28 18:32:23 -0400 | [diff] [blame] | 50 | 3. Set up your build environment for x86_64 and build CTS: |
| 51 | |
| 52 | lunch sdk_x86_64-eng && make cts -j32 |
| 53 | |
| 54 | 2. Generate the reference images. Generation occurs on all devices in |
| 55 | parallel. Resulting sets of reference images are automatically saved in |
| 56 | assets/<platform>/<dpi>.zip and will overwrite any existing sets. Image |
| 57 | generation may be started using: |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 58 | |
Alan Viverette | e2da81e | 2016-05-31 12:08:24 -0400 | [diff] [blame] | 59 | ./cts/hostsidetests/theme/generate_images.sh |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 60 | |
| 61 | A complete collection of reference images for a given API revision must include |
| 62 | a set for each possible DPI bucket (tvdpi, xxhdpi, etc.) that may be tested. |
| 63 | |
Alan Viverette | 4f560b6 | 2016-06-06 09:58:40 -0400 | [diff] [blame] | 64 | For a list of devices and their DPI buckets, see Device Metrics: |
| 65 | |
| 66 | https://design.google.com/devices/ |
| 67 | |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 68 | |
| 69 | II. Building theme tests |
| 70 | |
| 71 | 1. If you have not already built the CTS tests, run an initial make: |
| 72 | |
| 73 | make cts -j32 |
| 74 | |
| 75 | 2. Subsequent changes to the theme tests, including changes to the reference |
| 76 | images, may be built using mmm: |
| 77 | |
| 78 | mmm cts/hostsidetests/theme -j32 |
| 79 | |
| 80 | |
| 81 | III. Running theme tests |
| 82 | |
Alan Viverette | b246d96 | 2016-08-03 12:38:20 -0400 | [diff] [blame] | 83 | To obtain reliable results, theme tests should be run against the device's |
| 84 | native density; however, many of the tests will also work in a scaled density. |
| 85 | If you don't possess a device for a given density and would still like to run |
| 86 | tests for that density, you can manually force scaling via: |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 87 | |
Alan Viverette | b246d96 | 2016-08-03 12:38:20 -0400 | [diff] [blame] | 88 | adb shell wm density <dpi> |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 89 | |
Alan Viverette | b246d96 | 2016-08-03 12:38:20 -0400 | [diff] [blame] | 90 | As of API 24, the results will NOT be 100% reliable due to scaling artifacts. |
| 91 | To reset the device to its native density, run: |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 92 | |
Alan Viverette | b246d96 | 2016-08-03 12:38:20 -0400 | [diff] [blame] | 93 | adb shell wm density reset |
Alan Viverette | c15ea9f | 2015-08-26 16:33:17 -0400 | [diff] [blame] | 94 | |
Alan Viverette | b246d96 | 2016-08-03 12:38:20 -0400 | [diff] [blame] | 95 | Once the device is in the desired state, do the following: |
| 96 | |
| 97 | 1. Connect the device that you wish to test. Confirm that is is connected with: |
| 98 | |
| 99 | adb devices |
| 100 | |
| 101 | 2. Run the theme tests using cts-tradefed: |
| 102 | |
| 103 | cts-tradefed run singleCommand cts-dev --module CtsThemeHostTestCases \ |
| 104 | --test android.theme.cts.ThemeHostTest |
| 105 | |
| 106 | 3. Wait for the tests to complete. This should take less than five minutes. |
| 107 | |
Alan Viverette | 40115c4 | 2017-04-04 13:11:08 -0400 | [diff] [blame] | 108 | If any test failures are encountered, diff PNGs will be generated and collected |
| 109 | in the "diffs" directory of the CTS results indicated by "Test Result:" in the |
| 110 | test output. |