获取cts工具有两种方法:
1、直接下载,CTS下载地址:
http://source.android.com/compatibility/downloads.html
2、android工程中有cts目录,可以自己编译cts工具。
3、工作流程:
摘录自:http://source.android.com/compatibility/cts-intro.html
Workflow
@1 Download the CTS.
@2 Attach at least one device (or emulator) to your machine.
@3 For CTS 2.1 R2 and beyond, setup your device (or emulator) to run the accessibility tests:
#1 adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
#2 On the device, enable Settings > Accessibility > Accessibility > Delegating Accessibility Service
@4 Launch the CTS. The CTS test harness loads the test plan onto the attached devices. For each test in the test harness:
The test harness pushes a .apk file to each device, executes the test through instrumentation, and records test results. The test harness removes the .apk file from each device.
@5 Once all the tests are executed, you can view the test results in your browser and use the results to adjust your design. You can continue to run the CTS throughout your development process.
主机端需要完成的工作:
$ cd $work_dir$ unzip android-cts.zip
$ cp -a /release/android/tools/android-sdk-linux_86/ .
$ export SDK_ROOT=$work_dir/android-sdk-linux_86/
$ export PATH=$PATH:$work_dir/android-sdk-linux_86/bin
$ adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
#### On the device, enable Settings > Accessibility > Accessibility > Delegating Accessibility Service
$ vi android-cts/repository/host_config.xml
#### 修改 <IntValue name="maxTestCount" value="200" /> to <IntValue name="maxTestCount" value="0" />
$ cd android-cts/tools
$ ./startcts
Android CTS version 2.2_r3 Device(4C5499EE119E) connected
cts_host > start --plan CTS
客户端要完成的工作(例子只是参考,根据实际情况设置):
- 设置好Wifi
- 设置语言为英文
- 设置好google account
- 确保SDCard正常mount
- 调整好time zone,以及date的format,12小时格式
- Screen lock unchecked
- Screen Timeout -> 30 Minutes
- Insert SIM Card
- Check "Stay Awake", "Allow mock locations" and "USB Debugging" from Settings/Application/Development
- Download TTS files: Settings/Voice Input & Output/Text-to-speech settings/Install voice data
如果要单独测试一个case,需要写全测试用例名称:
格式如下:
java_package_name.class_name#method_name
例:
start --plan CTS -t android.net.cts.ConnectivityManagerTest#testStartUsingNetworkFeature