From fad9085ce0c1896764f1287ac002da454706c6be Mon Sep 17 00:00:00 2001
From: Baghmar Tarun <tarun.baghmar@in.bosch.com>
Date: Thu, 23 Apr 2020 11:00:03 +0000
Subject: [PATCH] T5734: bluez-avrcp-volume medium priority test case
 Signed-off-by: Baghmar Tarun <tarun.baghmar@in.bosch.com>

---
 test-cases/bluez-avrcp-volume.yaml | 62 +++++++++++++++++++++++-------
 1 file changed, 48 insertions(+), 14 deletions(-)

diff --git a/test-cases/bluez-avrcp-volume.yaml b/test-cases/bluez-avrcp-volume.yaml
index 6355df9..170a1e3 100644
--- a/test-cases/bluez-avrcp-volume.yaml
+++ b/test-cases/bluez-avrcp-volume.yaml
@@ -7,6 +7,7 @@ metadata:
     sdk:     [ amd64 ]
   image-deployment:
     - APT
+    - OSTree
   type: functional
   exec-type: manual
   priority: medium
@@ -15,13 +16,19 @@ metadata:
 
   resources:
     - "A Bluetooth adapter"
-    - "An A2DP Source and AVRCP capable phone (Nokia N9 — do not use an
-       Android 4.2 phone as their Bluetooth AVRCP support is broken)"
-    - "Note that you do not need to play any music on the phone; nor do you need
-       to have headphones or a speaker plugged into the Apertis device."
+    - "An A2DP Source and AVRCP capable phone 
+      (Nokia N9 — do not use an Android 4.2 phone as their Bluetooth AVRCP support is broken)"
+    - "Note that you do not need to play any music on the phone; nor do you need to have 
+       headphones or a speaker plugged into the Apertis device."
+
+  macro_ostree_preconditions: bluez-phone
+  pre-conditions:
+    - "If running the test on an SDK image, kill the blueman-applet process, as
+       it prevents the test from installing its own pairing agent."
+    - "Please note that connman disables bluetooth by default on a fresh image."
+    - "Enable device:"
+    - "$ connmanctl enable bluetooth"
 
-  macro_install_packages_preconditions: apertis-tests python3-dbus python3-gi 
-                                        chaiwala-tests
 
   expected:
     - "If success, the following output should be generated by btmon:"
@@ -32,23 +39,50 @@ metadata:
         Operation: 0x42 (VOLUME DOWN Pressed)
         Length: 0x00
         --
+        AV/C: Control: address 0x48 opcode 0x7c
+          Subunit: Panel
+          Opcode: Passthrough
+          Operation: 0xc2 (VOLUME DOWN Released)
+          Length: 0x00
+        --
         AV/C: Control: address 0x48 opcode 0x7c
         Subunit: Panel
         Opcode: Passthrough
         Operation: 0x41 (VOLUME UP Pressed)
         Length: 0x00
+        --
+        AV/C: Control: address 0x48 opcode 0x7c
+          Subunit: Panel
+          Opcode: Passthrough
+          Operation: 0xc1 (VOLUME UP Released)
+          Length: 0x00
+
+
+  notes:
+    - "Errors most frequently occurs at pairing. This can be used to circumvent
+       pairing problems, though this does not mean the test is a full pass, as
+       the pairing is part of the test:"
+    - |
+        >cd ~/bluez-avrcp-volume
+        armhf/bin/pair_two hci0 <bt address of the phone>
+        ./bluez-avrcp-volume.sh -a <address of the phone> -s
 
 run:
   steps:
+    - "The phone must be in discoverable mode for starting this test. Look for
+       the phone in this list, and save the BT address. It will be used while
+       running the test."
     - "Ensure PulseAudio is activated:"
     - $ pactl stat
     - "Run btmon before any connection happens:"
     - "$ sudo btmon  | grep -A4 'AV/C: Control'"
-    - "Start simple agent:"
-    - $ /usr/lib/chaiwala-tests/bluez/simple-agent -y
-    - "Pair both devices initiating from the phone side"
-    - "Pay attention to the simple-agent window as it requires input during
-       the pairing process."
-    - "In another terminal, execute (You can get the Bluetooth device address by
-       running hcitool scan):"
-    - $ /usr/lib/chaiwala-tests/bluez/test-avrcp.py -i hci0 device_address
+    - "Execute the test suite in another terminal:"
+    - $ ./bluez-avrcp-volume.sh
+    - "There are some options:"
+    - |
+        >-a select which device you want to pair with (specify the address)
+        -s skip pairing because the device is already paired. -a must be present when using this.
+        -x enables test debugging (only useful if a test fails)
+    - "Once the test begins, after Apertis finishes pairing with the phone, you
+       must initiate pairing from the phone and do the pairing again as part of
+       the test. You may need to unpair Apertis from within the phone first."
-- 
GitLab