在一個盒子裡完成汽車測試

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. 手機配對後,即可在設備上訪問聯繫人。