Android CTS

来源:互联网 发布:网络域名交易合同骗局 编辑:程序博客网 时间:2024/05/19 22:58

1. Android SDK及环境变量配置。

        在运行CTS之前,确保安装了最新版本的Android Debug Bridge (adb) 和Android Asset Packaging Tool(AAPT) ,并成功的配置了环境变量。

        可以通过 $ which adb和 $ which aapt查看adb及aapt的安装及配置情况。

        安装ADB连接:https://developer.android.com/studio/index.html#Other

        配置环境变量:

           $ exportPATH=$PATH:$HOME/android-sdk-linux/platform-tools

           $ export PATH=$PATH:$HOME/android-sdk-linux/build-tools/<version>

2. 安装JDK

安装相应版本的JDK,具体可以参考官方推荐

Please note, since there are no available supported OpenJDK 8packages for Ubuntu 14.04, the Ubuntu 15.04 packages must be installedmanually. See JDKfor Ubuntu LTS 14.04 for precise instructions.

    • The master branch of Android in AOSP: Ubuntu - OpenJDK 8, Mac OS - jdk 8u45 or newer
    • Android 5.x (Lollipop) - Android 6.0 (Marshmallow): Ubuntu - OpenJDK 7, Mac OS - jdk-7u71-macosx-x64.dmg
    • Android 2.3.x (Gingerbread) - Android 4.4.x (KitKat): Ubuntu - Java JDK 6, Mac OS - Java JDK 6
    • Android 1.5 (Cupcake) - Android 2.2.x (Froyo): Ubuntu - Java JDK 5

3. 根据平台下载CTS 文件 

https://source.android.com/compatibility/downloads.html

Note: Windows 使用 X86版本;Linux使用ARM版本。

4. 下载CTS Media Files文件

 https://source.android.com/compatibility/downloads.html#cts-media-files

5. 按照Android device configuration对设备进行配置。 

  1. Factory data reset the device: Settings > Backup & reset > Factory data reset

    Warning: This will erase all user data from the device.

  2. Set your device's language to English (United States) from: Settings > Language & input > Language
  3. Turn on the location setting if there is a GPS or Wi-Fi / Cellular network feature on the device:Settings > Location > On
  4. Connect to a Wi-Fi network that supports IPv6, can treat the DeviceUnder Test (DUT) as anisolated client (see thePhysical Environment section above), and has aninternet connection: Settings > Wi-Fi
  5. Make sure no lock pattern or password is set on the device: Settings > Security > Screen lock > None
  6. Enable USB debugging on your device: Settings > Developer options > USB debugging.

    Note: On Android 4.2 and later, Developer options is hidden by default. To make them available, go toSettings > About phone and tapBuild number seven times. Return to the previous screen to findDeveloper options. SeeEnabling On-device Developer Options for additional details.

  7. Select: Settings > Developer options > Stay Awake > On
  8. Select: Settings > Developer options > Allow mock locations > On

    Note: This mock locations setting is applicable only in Android 5.x and 4.4.x.

  9. Select: Settings > Developer options > Verify apps over USB > Off

    Note: This verify apps step became required in Android 4.2.

  10. Launch the browser and dismiss any startup/setup screen.
  11. Connect the desktop machine that will be used to test the device with a USB cable

    Note: When you connect a device running Android 4.2.2 or later to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. SelectAllow USB debugging.

  12. Install and configure helper apps on the device.

    Note: For CTS versions 2.1 R2 through 4.2 R4, set up your device (or emulator)to run the accessibility tests with:
    adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
    On the device, enable: Settings > Accessibility > Accessibility >Delegating Accessibility Service

    Note: For CTS 2.3 R4 and beyond on devices that declare theandroid.software.device_admin feature, set up your device to runthe device administration tests with:
    adb install -r android-cts/repository/testcases/CtsDeviceAdmin.apk
    On the device, enable only the twoandroid.deviceadmin.cts.CtsDeviceAdminReceiver* deviceadministrators under:Settings > Security > Select deviceadministrators. Make sure theandroid.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver and anyother preloaded device administrators stay disabled in the same menu.

  13. Copy the CTS media files to the device as follows:

    Note: For CTS 2.3 R12 and beyond, if thedevice supports video codecs, the CTS media files must be copied to thedevice.

    • Navigate (cd) to the path the media files are downloaded and unzipped to.
    • Change the file permissions: chmod u+x copy_media.sh
    • Run copy_media.sh:
      • To copy clips up to a resolution of 720x480, run: ./copy_media.sh 720x480
      • If you are not sure about the maximum resolution, try ./copy_media.sh all so that all files are copied.
      • If there are multiple devices under adb, add the -s (serial) option to the end. For example, to copy up to 720x480 to the device with serial 1234567, run:./copy_media.sh 720x480 -s 1234567

6. 执行 CTS 命令

./android-cts/tools/cts-tradefed

  1. 执行整个CTS测试:cts-tf > run cts -plan CTS
  2. 测试某个包:cts-tf > run cts -p <package_name>
    • 例如,要测试android.view.cts包下的所有case,执行命令:cts-tf > run cts -p android.view.cts
  3. 测试某个类:cts-tf > run cts -c <class_name>
    • 例如,要测试android.view.cts包下的WindowTest类,执行命令:cts-tf > run cts -c android.view.cts.WindowTest
  4. 测试某个case:cts-tf > run cts -c <class_name> -m <case_name>
    • 例如,要测试android.view.cts包下WindowTest类的testDecorView,执行命令:cts-tf > run cts -c android.view.cts.WindowTest -m testDecorView
  5. 查看帮助信息:cts-tf > run cts -help

7. 查看CTS测试报告

CTS测试时,会在android-cts/repository/results目录下,生成一个以开始时间命名的文件夹。测试结束后,在相应的文件夹下生成一个testResult.xml文件,用于查看测试结果。

1 0