在一个盒子里完成汽车测试

Complete Automotive Tests in a Box (CATBox) 是一个开源软件包,它提供了以最少的配置简化和执行汽车测试所需的框架和工具。 CATBox 可扩展并与您用于测试和验证 Android Automotive OS (AAOS) 实施的工具、基础架构和测试兼容。因此,您可以向市场提供高质量的产品。

CATBox 设计与实现

CATBox 测试套件提供了在汽车目标设备上执行功能和性能测试所需的工具、框架和测试。

下图说明了 CATBox 包的高级设计。

CATBox

图 1. CATBox 包

Tradefed

Tradefed 是一个开源持续测试框架,用于在 Android 设备上执行测试。有关详细信息,请参阅贸易联盟概述

汽车测试框架

CATBox 基于名为 Spectatio 的汽车测试框架,该框架提供 API 用于测试汽车设备上的各种应用程序。它建立在UI Automator之上,这是一个开源测试框架,它提供了一组 API 来构建与用户和系统应用程序交互的 UI 测试。

CATBox 测试套件下载

安卓 12

Android 12 是开发里程碑代号 S 的发布。使用以下链接下载适用于 Android 12 的 CATBox 测试套件:

安卓 11

Android 11 是开发里程碑代号 R 的发布。使用以下链接下载适用于 Android 11 的 CATBox 测试套件:

构建 CATBox

一旦 Android AOSP 代码在本地工作站上可用,请使用catbox build 命令。要在本地构建 CATBox 包:

  1. 选择设备目标并运行以下命令:

    # Select Device Target Based on Device Architecture
    $ lunch <target>
    
  2. 要构建 CATBox,请运行以下命令:

    # Build CATBox
    $ make catbox
    

    此命令在/out/host/linux-x86/catbox目录中创建android-catbox.zip文件,然后可以使用该文件运行测试。

环境设置

执行 CATBox 测试所需的环境设置类似于设置 CTS 。要设置环境,请完成以下每个任务:

CATBox 设置和执行

使用 Tradefed 测试框架在 Android 设备上运行测试。在 CATBox 设置之前,请先熟悉Trade Federation 概述

要设置和运行 CATBox,请参阅以下部分。

设备设置

在运行测试计划之前,请完成以下步骤来设置您的设备:

  1. 确保您已安装最新版本的Android Debug Bridge (adb)Android Asset Packaging Tool (AAPT) ,并将这些工具的位置添加到您机器的系统路径中。有关详细信息,请参阅ADB 和 AAPT

  2. 连接至少一个设备并准备被测设备 (DUT),如下所示:

    1. 要将汽车设备恢复出厂设置,请单击设置 > 系统 > 重置选项 > 擦除所有数据
    2. 等待设备自动重启。
    3. 确保启用了 adb。要确认设备可用,请运行以下命令:

      $ adb devices
      
    4. 要启用 root,请运行以下命令:

      # Enable Root
      $ adb -s DEVICE_SERIAL root
      

      DEVICE_SERIAL替换为汽车设备的序列号。

    5. 连接到无线网络。

提取 CATBox 包

完成设备设置后,解压 CATBox 包并进入解压文件夹:

# Extract the CATBox Package
$ unzip android-catbox.zip

# Navigate to extracted CATBox Package
$ cd android-catbox

在 CATBox 中执行测试

要使用 CATBox 包中的测试计划运行 CATBox,请运行以下命令:

./tools/catbox-tradefed run commandAndExit TEST_PLAN_NAME --serial DEVICE_SERIAL

DEVICE_SERIAL替换为汽车设备的序列号。如果您有多个设备连接到主机,请使用DEVICE_SERIAL来区分它们。将TEST_PLAN_NAME替换为您要运行的测试计划的名称。

要获取可用测试计划的完整列表,请运行以下命令:

./tools/catbox-tradefed list plans | grep -i catbox

下表按类型显示可用的测试计划:

测试类型姓名
功能测试计划catbox-functional-notification
catbox-functional-setting
catbox-functional-dial
catbox-functional-system-setting
catbox-functional-app-info-setting
catbox-functional-network-setting
catbox-functional-security-setting
catbox-functional-sound-setting
catbox-functional-date-time-setting
catbox-functional-appgrid
catbox-functional-home
catbox-functional-lock-screen
catbox-functional-navigation-bar
catbox-functional-ux-restriction
catbox-functional-bluetooth-audio
性能测试计划catbox-performance-cold-app-start-up-settings
catbox-performance-hot-app-start-up-settings
catbox-performance-jank-settings
catbox-performance-cold-app-start-up-dialer
catbox-performance-hot-app-start-up-dialer
catbox-performance-jank-contact-list
catbox-performance-jank-notifications
catbox-performance-jank-appgrid
catbox-performance-cold-app-start-up-mediacenter
catbox-performance-hot-app-start-up-mediacenter
catbox-performance-create-and-switch-to-new-guest
catbox-performance-create-and-switch-to-new-user
catbox-performance-create-and-switch-to-precreated-guest
catbox-performance-create-and-switch-to-precreated-user
catbox-performance-switch-to-existing-user

CATBox 测试结果

测试结果保存在android-catbox/results/latest文件夹中,用于功能和性能测试执行。

  • 有关测试结果,请参阅test_result.xml
  • 有关失败测试的详细信息,请参阅test_result_failures_suite.html
  • 有关性能指标结果,请参阅report-log-files目录中的CatboxPerformanceTests.reportlog.json

日志保存在路径android-catbox/logs/latest用于功能和性能测试执行。

某些测试(例如拨号、蓝牙音频和联系人列表卡顿测试)需要额外的设备设置。

拨号测试

拨号测试需要设备设置和运行时参数。要设置设备:

  1. 通过蓝牙将移动设备连接到汽车主机。
  2. 确保测试电话包含用于运行拨号测试的 SIM 卡并已连接到移动网络。
  3. 拨号测试使用手机上存储的默认联系人。使用contacts.vcf在手机上加载联系人。
  4. COMPANION_SERIAL替换为电话的序列号并运行以下命令:

    # Contacts can be loaded on the phone by pushing the contacts.vcf file on
    the phone and importing it in the Contacts application.
    
    OR
    
    # Importing contacts using adb.
    
    # Push contacts VCF file to phone
    
    $ adb -s COMPANION_SERIAL push <path-to-downloaded-contacts-vcf-file> /storage/emulated/0/Android/data/com.google.android.contacts/contacts.vcf
    
    # Grant Read Permissions
    
    $ adb -s COMPANION_SERIAL shell pm grant com.google.android.contacts
    android.permission.READ_EXTERNAL_STORAGE
    
    # Import contacts from the VCF file
    
    $ adb -s COMPANION_SERIAL shell am start-activity -W -t 'text/x-vcard' -d file:///storage/emulated/0/Android/data/com.google.android.contacts/contacts.vcf
    -a android.intent.action.VIEW com.google.android.contacts
    
    # Then accept the prompts on the UI to load the contacts.
    
运行时参数

拨号测试使用大小电话号码进行测试执行。拨号测试还使用联系人姓名和联系电话进行搜索测试。使用以下参数提供此信息:

Parameters for Large Phone Number:
--module-arg AndroidAutomotiveDialTests:instrumentation-arg:large-phone-number:=< 10 digit phone number>

Parameters for Small Phone Number:
--module-arg AndroidAutomotiveDialTests:instrumentation-arg:small-phone-number:=< 3 digit phone number>

Parameters for Search Contact Name:
--module-arg AndroidAutomotiveDialTests:instrumentation-arg:search-contact-name:=< some contact name stored on the phone >

Parameters for Search Contact Number:
--module-arg AndroidAutomotiveDialTests:instrumentation-arg:search-contact-number:=< contact number of the name provided in the search contact name >

蓝牙音频测试

为蓝牙音频测试设置设备:

  1. 确保手机上安装了 YouTube Music 应用,并且您已登录帐户。如果没有,请安装应用程序并登录帐户。
  2. 通过蓝牙手动将手机与车载设备配对。
  3. 手机配对后,在手机上播放一首歌曲,然后开始执行测试。

通讯录卡顿测试

要为联系人列表卡顿测试设置设备:

  1. 确保手机有多个联系人,以便测试可以滚动联系人列表以收集卡顿指标。
  2. 通过蓝牙手动将手机与车载设备配对。
  3. 手机配对后,即可在设备上访问联系人。