一、CTS搭建
1. 下载CTS相关的测试包
2. 在被测设备上安装CtsDelegatingAccessibilityService.apk
$ sudo ./adb install -r CtsDelegatingAccessibilityService.apk
$ 设置Settings > Accessibility > Accessibility > Delegating Accessibility Service
3. 进入/CTS/android-cts-2.2_r3/tools目录下,修改startcts脚本文件,将脚本中
的SDK_ROOT改成自己的android SDK路径.
$cd home/tester/CTS/android-cts-2.2_r3/tools $vim startcts // 修改脚本 出现的第一个SDK_ROOT,如"SDK_ROOT=/home/tester/CTS/SDK
4.执行startcts脚本。在执行CTS测试计划时(执行一段时间后,大于5分钟)会出现没有足够权限启动devices,使用$sudo ./startcts可解决该问题
5.出现如下提示符表示启动cts并连接设备成功。(红色部分未deviceID,视设备号而定)
Android CTS version 2.1_r2
Device(CB511KADGR) connected
cts_host > cts_host >
6. 在“cts_host >”提示符下输入命令,以下为几个常用的命令
help查看所有
exit退出
ls -p列出所有的测试包
ls --plan列出所有的测试方案
start --plan plan_name运行一个测试方案,如:start --plan CTS
start --plan plan_name -p package_name//运行一个特定的测试包,如: start --plan CTS -p android.bluetooth
start --plan CTS -t android.app.cts.AlertDialogTest#testAlertDialog
//只运行某个用例包中的某个用例
二、查看测试报告
运行测试时,在CTS运行界面能看到测试报告与运行状况。测试完成后可在/CTS/android-cts-2.2_r3/repository/results/下生成详细的测试报告和一些附加信息,其中用日期和时间命名的文件夹下为所有的测试结果,同时文件夹也会被打成一个对应的.zip包方便提交。用浏览器打开.xml文件(默认就是,直接双击)就可以查看所用的测试报告了
三、常见问题:
a)问题描述:在执行paln时,执行一段时间后会抛异常,异常如下:
CTS_INFO >>> Restarting device ...
Device(HC09MPL00037) disconnected
Exceptioninthread "Thread-17" com.android.ddmlib.AdbCommandRejectedException: insufficient permissions for device
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.SyncService.openSync(SyncService.java:164)
at com.android.ddmlib.Device.getSyncService(Device.java:253)
at com.android.cts.DeviceManager$DeviceServiceMonitor.run(DeviceManager.java:217)
解决方案:是因为权限不够,提升至root权限可解决,命令如下$sudo ./startcts
b)问题描述:输入./adb shell出现如下异常:
error: insufficient permissions for device
解决方案:输入:
$sudo -s
./adb kill-server
./adb devices
c)问题描述:error: device not found。
解决方法:
(1)请确认你的设备是否连接电脑,
(2)以连接PC,重新拔下来,再连一次
(3)如果2操作后还不行,看下USB连接方式是否为默认(仅充电),选htc或USB连接。
d)写入测试结果时报Too many open files的错误,这是因为网络请求过多,也就导致了系统打开的文件过多。每一个连接都会当成“文件”看待的。
解决方案:用ulimit –a命令查看每个用户允许打开的最大文件数,看到是的1024,把它改大点,用命令:ulimit -n 4096
三、补充说明:
为了避免一些没必要的错误,在测试前先更改一下设备设置:
1. Make sure the”Wi-Fi” development option is checked(Settings->Wireless and network->Wi-Fi).
2. Make sure the “Wi-Fi” is connected (Settings->Wireless and network->Wi-Fi settings).
3. Make sure “Bluetooth” development option is checked(Settings->Wireless and network->Bluetooth).
4. Make sure the”Wi-Fi sleep policy”is set to “Never”(Settings->Wireless and network->Wi-Fi settings->Menu->Advanced->Wi-Fi sleep policy).
5. Make sure the "Screen Timeout" is set to "Never "or “The max time of time out”(Setting->Display settings->Screen timeout).
6. Check "Stay Awake", "Allow mock locations" and "User Debugging" from Settings->Application->Development
7. Make sure "Use wireless networks " development option is checked (Settings->Location and security->Use wireless networks ).
8. Set the language to English(Settings->Locale and text-Select language).
9. Copy the “svox” file to the device,make sure the “English(United States)”and “English (United Kingdom)”has been Installed.(Settings->Voice input and output settings->Text-to-speech settings->Pico TTs)
10. Install CtsDelegatingAccessibilityService.apk, then the “Accessibility” and” Delegating Accessibility Service” development options are checked (Settings->Accessibility->Delegating Accessibility Service)
11. Set the Date and Time.(Settings -> Date&time ->Set date / Set time),set the “Select time zone” to “Beijing”(Setting->Select time zone).
12. Clear browser cache and history (Internet->Menu->Settings)
13. SD card and have enough space and copy smaple audio and video media files
14. Make sure no lock pattern is set on the device.
15. Make sure the device is at the home screen at the start of CTS (Press the home button).
16. Do not press any keys on the device while CTS is running.
17. Click the voice Recorder application,to record and save.
18. Make sure My location is Located on “Maps”
19. Make sure “turn off USB”