summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Turney <tturney@google.com>2018-05-21 18:39:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-05-21 18:39:07 +0000
commite36bc09fcc6299eb49fa574cbcca40e21d5a5ec2 (patch)
treedf8f4a99d951b6684b21f63dddf068dd27d5327f
parent9f21821604e9dcf2946a677ce3ad86c57ca875db (diff)
parent30aaf6af2e3c8a7e71a3d73a192d7b7086053464 (diff)
downloadplatform_tools_test_connectivity-e36bc09fcc6299eb49fa574cbcca40e21d5a5ec2.tar.gz
platform_tools_test_connectivity-e36bc09fcc6299eb49fa574cbcca40e21d5a5ec2.tar.bz2
platform_tools_test_connectivity-e36bc09fcc6299eb49fa574cbcca40e21d5a5ec2.zip
Merge " BtCarPbap Test merge from AOSP" into pi-dev
-rw-r--r--acts/framework/acts/test_utils/bt/bt_contacts_utils.py17
-rw-r--r--acts/tests/google/bt/car_bt/BtCarPbapTest.py47
2 files changed, 30 insertions, 34 deletions
diff --git a/acts/framework/acts/test_utils/bt/bt_contacts_utils.py b/acts/framework/acts/test_utils/bt/bt_contacts_utils.py
index 91d37cc915..70eac5e091 100644
--- a/acts/framework/acts/test_utils/bt/bt_contacts_utils.py
+++ b/acts/framework/acts/test_utils/bt/bt_contacts_utils.py
@@ -24,7 +24,7 @@ import logging
import re
import random
import string
-from time import sleep
+import time
from acts.utils import exe_cmd
import queue
@@ -274,7 +274,7 @@ def get_contact_count(device):
return len(contact_list)
-def import_device_contacts_from_vcf(device, destination_path, vcf_file):
+def import_device_contacts_from_vcf(device, destination_path, vcf_file, timeout=10):
"""Uploads and import vcf file to device.
"""
number_count = phone_number_count(destination_path, vcf_file)
@@ -283,10 +283,15 @@ def import_device_contacts_from_vcf(device, destination_path, vcf_file):
phone_phonebook_path = "{}{}".format(STORAGE_PATH, vcf_file)
device.adb.push("{} {}".format(local_phonebook_path, phone_phonebook_path))
device.droid.importVcf("file://{}{}".format(STORAGE_PATH, vcf_file))
- # keyevent to allow contacts import from vcf file
- sleep(1)
- for key in ["ENTER", "DPAD_RIGHT", "ENTER"]:
- device.adb.shell("input keyevent KEYCODE_{}".format(key))
+ start_time = time.time()
+ while time.time() < start_time + timeout:
+ #TODO: use unattended way to bypass contact import module instead of keyevent
+ if "ImportVCardActivity" in device.get_my_current_focus_window():
+ # keyevent to allow contacts import from vcf file
+ for key in ["DPAD_RIGHT", "DPAD_RIGHT", "ENTER"]:
+ device.adb.shell("input keyevent KEYCODE_{}".format(key))
+ break
+ time.sleep(1)
if wait_for_phone_number_update_complete(device, number_count):
return number_count
else:
diff --git a/acts/tests/google/bt/car_bt/BtCarPbapTest.py b/acts/tests/google/bt/car_bt/BtCarPbapTest.py
index a3ae194f5d..9d195bc1ce 100644
--- a/acts/tests/google/bt/car_bt/BtCarPbapTest.py
+++ b/acts/tests/google/bt/car_bt/BtCarPbapTest.py
@@ -1,4 +1,4 @@
-# /usr/bin/env python3.4
+#/usr/bin/env python3.4
#
# Copyright (C) 2016 The Android Open Source Project
#
@@ -55,7 +55,7 @@ class BtCarPbapTest(BluetoothBaseTest):
"android.permission.WRITE_CONTACTS",
"android.permission.READ_EXTERNAL_STORAGE"
]
- for device in [self.pce, self.pse, self.pse2]:
+ for device in self.android_devices:
for permission in permissions_list:
device.adb.shell(
"pm grant com.google.android.contacts {}".format(permission))
@@ -103,23 +103,24 @@ class BtCarPbapTest(BluetoothBaseTest):
if not super(BtCarPbapTest, self).setup_test():
return False
self.pse.droid.callLogsEraseAll()
- if not (bt_contacts_utils.erase_contacts(self.pse) and
- bt_contacts_utils.erase_contacts(self.pce)):
- return False
- # Allow all content providers to synchronize.
- time.sleep(1)
- return True
+ return self.erase_all_contacts()
def teardown_test(self):
if not super(BtCarPbapTest, self).teardown_test():
return False
- for device in [self.pce, self.pse, self.pse2]:
+ for device in self.android_devices:
bt_contacts_utils.delete_vcf_files(device)
self.pce.droid.bluetoothPbapClientDisconnect(
self.pse.droid.bluetoothGetLocalAddress())
- bt_contacts_utils.erase_contacts(self.pse)
- return True
+ return self.erase_all_contacts()
+
+ def erase_all_contacts(self):
+ try:
+ return all(bt_contacts_utils.erase_contacts(device) for device in self.android_devices)
+ finally:
+ # Allow all content providers to synchronize.
+ time.sleep(1)
def verify_contacts_match(self):
bt_contacts_utils.export_device_contacts_to_vcf(
@@ -215,8 +216,6 @@ class BtCarPbapTest(BluetoothBaseTest):
PSE_CONTACTS_FILE, 100)
phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(
self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE)
-
- bt_test_utils.reset_bluetooth([self.pce])
bt_test_utils.connect_pri_to_sec(
self.pce, self.pse,
set([BtEnum.BluetoothProfile.PBAP_CLIENT.value]))
@@ -252,7 +251,6 @@ class BtCarPbapTest(BluetoothBaseTest):
PSE_CONTACTS_FILE, 100)
phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(
self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE)
- bt_test_utils.reset_bluetooth([self.pce])
if not self.connect_and_verify(phone_numbers_added):
return False
@@ -261,7 +259,6 @@ class BtCarPbapTest(BluetoothBaseTest):
PSE_CONTACTS_FILE, 110, 2)
phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(
self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE)
- bt_test_utils.reset_bluetooth([self.pce])
return self.connect_and_verify(phone_numbers_added)
@test_tracker_info(uuid='bbe31bf5-51e8-4175-b266-1c7750e44f5b')
@@ -335,7 +332,6 @@ class BtCarPbapTest(BluetoothBaseTest):
phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(
self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE)
- bt_test_utils.reset_bluetooth([self.pce])
return self.connect_and_verify(phone_numbers_added)
@test_tracker_info(uuid='2aa2bd00-86cc-4f39-a06a-90b17ea5b320')
@@ -357,7 +353,6 @@ class BtCarPbapTest(BluetoothBaseTest):
Pass if True
Fail if False
"""
-
bt_contacts_utils.add_call_log(
self.pse, bt_contacts_utils.INCOMMING_CALL_TYPE,
bt_contacts_utils.generate_random_phone_number().phone_number,
@@ -431,22 +426,20 @@ class BtCarPbapTest(BluetoothBaseTest):
Pass if True
Fail if False
"""
-
PSE1_CONTACTS_FILE = "{}{}".format(PSE_CONTACTS_FILE, "1")
PSE2_CONTACTS_FILE = "{}{}".format(PSE_CONTACTS_FILE, "2")
bt_contacts_utils.generate_contact_list(self.contacts_destination_path,
PSE1_CONTACTS_FILE, 100)
- phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(self.pse,
- self.contacts_destination_path,
- PSE1_CONTACTS_FILE)
+ bt_contacts_utils.import_device_contacts_from_vcf(self.pse,
+ self.contacts_destination_path,
+ PSE1_CONTACTS_FILE)
bt_contacts_utils.generate_contact_list(self.contacts_destination_path,
PSE2_CONTACTS_FILE, 100)
- phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf(self.pse2,
- self.contacts_destination_path,
- PSE2_CONTACTS_FILE)
+ bt_contacts_utils.import_device_contacts_from_vcf(self.pse2,
+ self.contacts_destination_path,
+ PSE2_CONTACTS_FILE)
- bt_test_utils.reset_bluetooth([self.pce])
self.pce.droid.bluetoothPbapClientDisconnect(
self.pse.droid.bluetoothGetLocalAddress())
self.pce.droid.bluetoothPbapClientDisconnect(
@@ -465,9 +458,7 @@ class BtCarPbapTest(BluetoothBaseTest):
bt_test_utils.connect_pri_to_sec(
self.pce, self.pse2,
set([BtEnum.BluetoothProfile.PBAP_CLIENT.value]))
-
bt_contacts_utils.wait_for_phone_number_update_complete(self.pce, 200)
-
bt_contacts_utils.export_device_contacts_to_vcf(
self.pce, self.contacts_destination_path, PCE_CONTACTS_FILE)
@@ -495,4 +486,4 @@ class BtCarPbapTest(BluetoothBaseTest):
bt_contacts_utils.erase_contacts(self.pse)
bt_contacts_utils.erase_contacts(self.pse2)
- return pse1_matches and pse2_matches and pse1andpse2_matches
+ return pse1_matches and pse2_matches and pse1andpse2_matches \ No newline at end of file