安卓CTS官方文档之兼容性测试套件简介
Compatibility Test Suite
兼容性测试套件
How does the CTS work?
CTS是如何工作的?
The CTS is an automated testing harness that includes two major software components:
CTS是一套自动化测试套件,它主要包含了两个软件组件:
-
The CTS test harness runs on your desktop machine and manages test execution.
-
CTS测试套件(框架)运行在你的桌面机器上以管理测试执行
-
Individual test cases are executed on attached mobile devices or on an emulator. The test cases are written in Java as JUnit tests and packaged as Android .apk files to run on the actual device target.
-
每个测试用例都是在挂载连接上主机的安卓移动设备或者模拟器上执行的。测试用例都是用Java编写的Junit单元测试,并且这些测试用例会被打包成安卓的.apk文件来在真实目标机器上执行。
Workflow
工作流程
This section summarizes CTS setup. Please refer to the CTS User Manual for detailed instructions.
这一小节会对如何建立CTS测试进行概要说明。如果需要详细的指导文档的话请查看CTS用户手册。
-
Download the CTS and CTS media files. / 下载CTS兼容性测试套件和CTS兼容性测试媒体文件(天地会珠海分舵注:因为有些兼容性API的测试需要设计媒体播放功能)
-
Attach at least one device (or emulator) to your machine./ 把至少一个安卓设备(或者模拟器)连接到你的主机上面(天地会珠海分舵注:注意不仅仅是连上去,还要保证SDK等正确安装,可以使用adb操作该设备)
-
For CTS versions 2.1 R2 through 4.2 R4, set up your device (or emulator) to run the accessibility tests:/如果你的目标机器版本和对应所需要的CTS版本是2.1R2到4.2R4之间的话,请根据下面的步骤来先在你的目标机器(或模拟器)上配置运行辅助功能测试:
adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
-
On the device, enable Settings > Accessibility > Accessibility > Delegating Accessibility Service/在目标设备上以下位置启动设置项: 设置>辅助功能>Delegating Accessibility Service。
-
For CTS 2.3 R4 and beyond, set up your device to run the device administration tests:/如果你的测试设备的安卓版本是2.3 R4以及以上的话,请根据下面步骤来运行设备管理测试:
adb install -r android-cts/repository/testcases/CtsDeviceAdmin.apk
-
On the device, enable the two
android.deviceadmin.cts.CtsDeviceAdminReceiver*
device administrators under Settings > Location & security > Select device administrators / 在你的设备上面的以下位置使能android.deviceadmin.cts.CtsDeviceReceiver* 这两个设备管理器:设置>安全和隐私>设备管理器Note: Make sure the
android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver
stays disabled in the same menu. / 注意: 确保在同一界面上的android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver是在关闭状态的。
-
For CTS 2.3 R12 and beyond, the CTS media files must be copied to the device's external storage. Check section 4.2 of the latest CTS manual for further details on copying these files: / 如果你使用的设备是安卓2.3 R12及以上版本,相应的CTS媒体测试文件必须拷贝到设备的外存(sd卡)上面。关于考本的详情请查看最近的CTS手册的4.2节:
-
Unzip the CTS Media zip file. / 将CTS测试媒体文件解包。
-
Run the following command. If no resolution is specified, the default maximum resolution of 480x360 is assumed: / 运行下面的命令。注意如果没有指定分辨率的话,将会假定使用的是480x360这个最高默认分辨率:
copy_media.sh [720x480|1280x720|1920x1080|all] [-s serial]
-
-
Launch the CTS. The CTS test harness loads the test plan onto the attached devices. For each test in the test harness: / 运行CTS。CTS测试套件会把测试计划加载到挂载上来的所有测试设备上。对于测试套件上的每一个测试:
-
The test harness pushes an .apk file to each device, executes the test through instrumentation, and records test results. / 测试套件会把该测试对应的一个.apk文件推送到目标测试设备上,然后通过instrumentation框架来运行该测试,并且会将测试结果记录下来。
-
The test harness removes the .apk file from each device. / 测试套件最后会在每个测试设备上删除掉该.apk文件。
-
-
Once all the tests are executed, view the test results in your browser and use them to adjust your design. You can continue to run the CTS throughout your development process. / 一旦以上所有测试都执行完毕后,你就可以在你的浏览器上查看对应的测试结果并使用它们来审核你的设计是否正确。你可以在你的整个开发过程中不停的运行CTS来验证你的设计。
Types of test cases
测试用例类型
The CTS includes the following types of test cases:
CTS包含以下几种测试用例:
-
Unit tests test atomic units of code within the Android platform; e.g. a single class, such as java.util.HashMap.
-
单元测试:测试在安卓平台中原子单元粒度的代码。比如测试一个如java.util.HashMap的类。
-
Functional tests test a combination of APIs together in a higher-level use-case.
-
功能测试:在一个更高层次的测试用例上面去测试APIs的组合
-
Reference application tests instrument a complete sample application to exercise a full set of APIs and Android runtime services.
-
应用参照测试:往一个示例应用中注入instrumentation框架来验证一整套APIs和安卓运行时服务
Future versions of the CTS will include the following types of test cases:
将来的CTS版本将会包含以下类型的测试用例:
-
Robustness tests test the durability of the system under stress.
-
健壮性测试:测试目标系统在一定压力下的可持久性
-
Performance tests test the performance of the system against defined benchmarks, for example rendering frames per second.
-
性能测试:测试系统在既定的基准点下的性能,比如测试安卓的帧渲染率。
Areas Covered
覆盖范围
The unit test cases cover the following areas to ensure compatibility:
单元测试用例将覆盖以下范围来对兼容性做出保障
Area 范围 | Description 描述 |
---|---|
Signature tests 签名测试 | For each Android release, there are XML files describing the signatures of all public APIs contained in the release. The CTS contains a utility to check those API signatures against the APIs available on the device. The results from signature checking are recorded in the test result XML file. 在每个发布的安卓版本中,都会有一个XML文件来描述所有包含的公开API的签名信息。 CTS包含有一个工具来检查验证该发布版本的API签名和目标设备上已有的API签名。 签名测试的测试结果会记录在xml格式的测试报告文档中。 |
Platform API Tests 平台API测试 | Test the platform (core libraries and Android Application Framework) APIs as documented in the SDK Class Index to ensure API correctness, including correct class, attribute and method signatures, correct method behavior, and negative tests to ensure expected behavior for incorrect parameter handling. 测试SDK文档中Class Index指定的平台(核心库和安卓应用框架)APIs,包括测试类, 类成员属性和方法签名的正确性,类成员方法的正确性, 以及通过负面测试来保证在输入参数出错时的处理是符合预期的 |
Dalvik VM Tests Dalvik VM测试 | The tests focus on testing the Dalvik Executable Format. 该测试主要是关注Dalvik可执行格式的测试 |
Platform Data Model 平台数据模型 | The CTS tests the core platform data model as exposed to application developers through content providers, as documented in the SDK android.provider package: contacts, browser, settings, etc. 这类CTS测试用例测试的是平台通过Content Provider组件暴露给应用开发者的核心数据模型, 这些数据模型在SDK的 android.provider 包中有相应的定义,比如:联系人,浏览器,设置,等等。 |
Platform Intents 平台Intents | The CTS tests the core platform intents, as documented in the SDK Available Intents. 这类CTS测试用例测试的是平台核心的Intens组件,这些是在SDK的Available Intents中进行定义的。 |
Platform Permissions 平台权限 | The CTS tests the core platform permissions, as documented in the SDK Available Permissions. 这类CTS测试用例测试的是平台的权限控制,这些是在SDK的Available Permissions中进行定义的。 |
Platform Resources 平台资源 | The CTS tests for correct handling of the core platform resource types, as documented in the SDK Available Resource Types. This includes tests for: simple values, drawables, nine-patch, animations, layouts, styles and themes, and loading alternate resources. 这类测试用例测试的是平台的核心资源类型处理的正确性, 这些是在SDK的Available Resource Types中进行定义的。 这些测试用例测试的资源类型包含以下方面:简单值类型, 可描绘资源类型,nine-patch资源类型,动画资源类型, 布局类型,风格资源类型以及主题资源类型和对可选资源的加载。 (天地会珠海分舵:后一句的翻译不敢完全确定,如果有更好的翻译版本的敬请提供,先谢过了) |
Item
Description
Warning
Author
天地会珠海分舵 转载请注明出处! 更多精彩文章请查看本人博客!Blog Address
http://blog.csdn.net/zhubaitian