blob: 1f8f8e69d85df7cf85f3b1cbed67472c5fc760b5 [file] [log] [blame] [view]
Skyler Kaufman991ae4d2011-04-07 12:30:41 -07001# CTS Development #
2
3## Initializing Your Repo Client ##
4
5Follow the [instructions](/source/downloading.html)
6to get and build the Android source code but specify `-b froyo`
7when issuing the `repo init` command. This assures that your CTS
8changes will be included in the next CTS release and beyond.
9
10## Setting Up Eclipse ##
11
12Follow the [instructions](/source/using-eclipse.html)
13to setup Eclipse but execute the following command to generate the
14`.classpath` file rather than copying the one from the development
15project:
16
17 cd /path/to/android/root
18 ./cts/development/ide/eclipse/genclasspath.sh > .classpath
19 chmod u+w .classpath
20
21This `.classpath` file will contain both the Android framework
22packages and the CTS packages.
23
24## Building and Running CTS ##
25
26Execute the following commands to build CTS and start the interactive
27CTS console:
28
29 cd /path/to/android/root
30 make cts
31 cts
32
33Provide arguments to CTS to immediately start executing a test:
34
35 cts start --plan CTS -p android.os.cts.BuildVersionTest
36
37## Writing CTS Tests ##
38
39CTS tests use JUnit and the Android testing APIs. Review the
40[Testing and Instrumentation](http://d.android.com/guide/topics/testing/testing_android.html)
41tutorial while perusing the existing tests under the
42`cts/tests/tests` directory. You will see that CTS tests mostly follow the same
43conventions used in other Android tests.
44
45Since CTS runs across many production devices, the tests must follow
46these rules:
47
48- Must take into account varying screen sizes, orientations, and keyboard layouts.
49- Only use public API methods. In other words, avoid all classes, methods, and fields that are annotated with the "hide" annotation.
50- Avoid relying upon particular view layouts or depend on the dimensions of assets that may not be on some device.
51- Don't rely upon root privileges.
52
53### Test Naming and Location ###
54
55Most CTS test cases target a specific class in the Android API. These tests
56have Java package names with a `cts` suffix and class
57names with the `Test` suffix. Each test case consists of
58multiple tests, where each test usually exercises a particular API method of
59the API class being tested. Each test is annotated with a `@TestTargetNew`
60annotation to indicate what API method is being exercised. These tests are
61arranged in a directory structure where tests are grouped into different
62categories like "widgets" and "views."
63
64For example, the CTS test for `android.widget.TextView` is
65`android.widget.cts.TextViewTest` found under the
66`cts/tests/tests/widget/src/android/widget/cts` directory with its
67Java package name as `android.widget.cts` and its class name as
68`TextViewTest`. The `TextViewTest` class has a test called `testSetText`
69that exercises the "setText" method and a test named "testSetSingleLine" that
70calls the `setSingleLine` method. Each of those tests have `@TestTargetNew`
71annotations indicating what they cover.
72
73Some CTS tests do not directly correspond to an API class but are placed in
74the most related package possible. For instance, the CTS test,
75`android.net.cts.ListeningPortsTest`, is in the `android.net.cts`, because it
76is network related even though there is no `android.net.ListeningPorts` class.
77Thus, use your best judgement when adding new tests and refer to other tests
78as examples.
79
80### New Test Packages ###
81
82When adding new tests, there may not be an existing directory to place your
83test. In that case, refer to the example under `cts/tests/tests/example` and
84create a new directory. Furthermore, make sure to add your new package's
85module name from its `Android.mk` to `CTS_COVERAGE_TEST_CASE_LIST` in
86`cts/CtsTestCaseList.mk`. This Makefile is used by `build/core/tasks/cts.mk`
87to glue all the tests together to create the final CTS package.
88
89### Test Stubs and Utilities ###
90
91Some tests use additional infrastructure like separate activities
92and various utilities to perform tests. These are located under the
93`cts/tests/src` directory. These stubs aren't separated into separate test
94APKs like the tests, so the `cts/tests/src` directory does not have additional
95top level directories like "widget" or "view." Follow the same principle of
96putting new classes into a package with a name that correlates to the purpose
97of your new class. For instance, a stub activity used for testing OpenGL like
98`GLSurfaceViewStubActivity` belongs in the `android.opengl.cts` package under
99the `cts/tests/src/android/opengl` directory.
100
101## Other Tasks ##
102
103Besides adding new tests there are other ways to contribute to CTS:
104
105- Fix or remove tests annotated with BrokenTest and KnownFailure.
106
107## Submitting Your Changes ##
108
109Follow the [Android Contributors' Workflow](/source/submit-patches.html)
110to contribute changes to CTS. A reviewer
111will be assigned to your change, and your change should be reviewed shortly!
112