Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 1 | #/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright (C) 2016 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 6 | # use this file except in compliance with the License. You may obtain a copy of |
| 7 | # the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations under |
| 15 | # the License. |
| 16 | """Test script to test PBAP contact download between two devices which can run SL4A. |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 17 | """ |
| 18 | |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 19 | import os |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 20 | import time |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 21 | |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 22 | from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 23 | from acts.base_test import BaseTestClass |
Sanket Agarwal | bd9689b | 2016-08-24 11:14:53 -0700 | [diff] [blame] | 24 | from acts.test_utils.bt import bt_contacts_utils |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 25 | from acts.test_utils.bt import bt_test_utils |
Sanket Agarwal | bd9689b | 2016-08-24 11:14:53 -0700 | [diff] [blame] | 26 | from acts.test_utils.car import car_bt_utils |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 27 | from acts.utils import exe_cmd |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 28 | import acts.test_utils.bt.BtEnum as BtEnum |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 29 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 30 | # Offset call logs by 1 minute |
| 31 | CALL_LOG_TIME_OFFSET_IN_MSEC = 60000 |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 32 | PSE_CONTACTS_FILE = "psecontacts.vcf" |
| 33 | PCE_CONTACTS_FILE = "pcecontacts.vcf" |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 34 | |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 35 | |
| 36 | class BtCarPbapTest(BluetoothBaseTest): |
| 37 | contacts_destination_path = "" |
| 38 | |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 39 | def __init__(self, controllers): |
| 40 | BaseTestClass.__init__(self, controllers) |
| 41 | self.pce = self.android_devices[0] |
| 42 | self.pse = self.android_devices[1] |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 43 | self.contacts_destination_path = self.log_path + "/" |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 44 | |
| 45 | def setup_class(self): |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 46 | if not super(BtCarPbapTest, self).setup_class(): |
| 47 | return False |
tturney | 1f7b7b5 | 2016-11-17 15:28:22 -0800 | [diff] [blame^] | 48 | permissions_list = ["android.permission.READ_CONTACTS", |
| 49 | "android.permission.WRITE_CONTACTS", |
| 50 | "android.permission.READ_EXTERNAL_STORAGE"] |
| 51 | for permission in permissions_list: |
| 52 | self.pse.adb.shell( |
| 53 | "pm grant com.google.android.contacts {}".format(permission)) |
| 54 | for permission in permissions_list: |
| 55 | self.pce.adb.shell( |
| 56 | "pm grant com.android.contacts {}".format(permission)) |
| 57 | |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 58 | |
| 59 | # Pair the devices. |
| 60 | # This call may block until some specified timeout in bt_test_utils.py. |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 61 | # Grace time inbetween stack state changes |
| 62 | |
| 63 | time.sleep(5) |
| 64 | if not bt_test_utils.pair_pri_to_sec( |
| 65 | self.pce, self.pse, attempts=4, auto_confirm=False): |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 66 | self.log.error("Failed to pair.") |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 67 | return False |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 68 | |
Sanket Agarwal | bd9689b | 2016-08-24 11:14:53 -0700 | [diff] [blame] | 69 | # Disable the HFP and A2DP profiles. This will ensure only PBAP |
| 70 | # gets connected. Also, this will eliminate the auto-connect loop. |
| 71 | car_bt_utils.set_car_profile_priorities_off(self.pce, self.pse) |
| 72 | |
| 73 | # Enable PBAP on PSE & PCE. |
| 74 | bt_test_utils.set_profile_priority( |
| 75 | self.pce, self.pse, [BtEnum.BluetoothProfile.PBAP_CLIENT], |
| 76 | BtEnum.BluetoothPriorityLevel.PRIORITY_ON) |
| 77 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 78 | self.pse.droid.bluetoothChangeProfileAccessPermission( |
| 79 | self.pce.droid.bluetoothGetLocalAddress(), |
| 80 | BtEnum.BluetoothProfile.PBAP_SERVER.value, |
| 81 | BtEnum.BluetoothAccessLevel.ACCESS_ALLOWED.value) |
| 82 | |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 83 | return True |
| 84 | |
| 85 | def setup_test(self): |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 86 | if not super(BtCarPbapTest, self).setup_test(): |
| 87 | return False |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 88 | self.pse.droid.callLogsEraseAll() |
| 89 | if not (bt_contacts_utils.erase_contacts(self.pse) and |
| 90 | bt_contacts_utils.erase_contacts(self.pce)): |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 91 | return False |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 92 | # Allow all content providers to synchronize. |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 93 | time.sleep(1) |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 94 | return True |
| 95 | |
| 96 | def teardown_test(self): |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 97 | if not super(BtCarPbapTest, self).teardown_test(): |
| 98 | return False |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 99 | self.pce.droid.bluetoothPbapClientDisconnect( |
| 100 | self.pse.droid.bluetoothGetLocalAddress()) |
| 101 | bt_contacts_utils.erase_contacts(self.pse) |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 102 | return True |
| 103 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 104 | def verify_contacts_match(self): |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 105 | bt_contacts_utils.export_device_contacts_to_vcf( |
| 106 | self.pce, self.contacts_destination_path, PCE_CONTACTS_FILE) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 107 | return bt_contacts_utils.count_contacts_with_differences( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 108 | self.contacts_destination_path, PCE_CONTACTS_FILE, |
| 109 | PSE_CONTACTS_FILE) == 0 |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 110 | |
| 111 | def connect_and_verify(self, count): |
| 112 | bt_test_utils.connect_pri_to_sec( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 113 | self.pce, self.pse, |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 114 | set([BtEnum.BluetoothProfile.PBAP_CLIENT.value])) |
| 115 | bt_contacts_utils.wait_for_phone_number_update_complete(self.pce, |
| 116 | count) |
| 117 | contacts_added = self.verify_contacts_match() |
| 118 | self.pce.droid.bluetoothPbapClientDisconnect( |
| 119 | self.pse.droid.bluetoothGetLocalAddress()) |
| 120 | contacts_removed = bt_contacts_utils.wait_for_phone_number_update_complete( |
| 121 | self.pce, 0) |
| 122 | return contacts_added and contacts_removed |
| 123 | |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 124 | #@BluetoothTest(UUID=7dcdecfc-42d1-4f41-b66e-823c8f161356) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 125 | @BluetoothBaseTest.bt_test_wrap |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 126 | def test_pbap_connect_and_disconnect(self): |
| 127 | """Test Connectivity |
| 128 | |
| 129 | Test connecting with the server enabled and disabled |
| 130 | |
| 131 | Precondition: |
| 132 | 1. Devices are paired. |
| 133 | |
| 134 | Steps: |
| 135 | 1. Disable permission on PSE to prevent PCE from connecting |
| 136 | 2. Attempt to connect PCE to PSE |
| 137 | 3. Verify connection failed |
| 138 | 4. Enable permission on PSE to allow PCE to connect |
| 139 | 5. Attempt to connect PCE to PSE |
| 140 | 6. Verify connection succeeded |
| 141 | |
| 142 | Returns: |
| 143 | Pass if True |
| 144 | Fail if False |
| 145 | """ |
| 146 | self.pse.droid.bluetoothChangeProfileAccessPermission( |
| 147 | self.pce.droid.bluetoothGetLocalAddress(), |
| 148 | BtEnum.BluetoothProfile.PBAP_SERVER.value, |
| 149 | BtEnum.BluetoothAccessLevel.ACCESS_DENIED.value) |
| 150 | if bt_test_utils.connect_pri_to_sec( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 151 | self.pce, self.pse, |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 152 | set([BtEnum.BluetoothProfile.PBAP_CLIENT.value])): |
| 153 | self.log.error("Client connected and shouldn't be.") |
| 154 | return False |
Sanket Agarwal | bd9689b | 2016-08-24 11:14:53 -0700 | [diff] [blame] | 155 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 156 | self.pce.droid.bluetoothPbapClientDisconnect( |
| 157 | self.pse.droid.bluetoothGetLocalAddress()) |
| 158 | |
| 159 | self.pse.droid.bluetoothChangeProfileAccessPermission( |
| 160 | self.pce.droid.bluetoothGetLocalAddress(), |
| 161 | BtEnum.BluetoothProfile.PBAP_SERVER.value, |
| 162 | BtEnum.BluetoothAccessLevel.ACCESS_ALLOWED.value) |
Sanket Agarwal | bd9689b | 2016-08-24 11:14:53 -0700 | [diff] [blame] | 163 | |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 164 | if not bt_test_utils.connect_pri_to_sec(self.pce, self.pse, set( |
| 165 | [BtEnum.BluetoothProfile.PBAP_CLIENT.value])): |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 166 | self.log.error("No client connected and should be.") |
| 167 | return False |
| 168 | |
| 169 | return True |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 170 | |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 171 | #@BluetoothTest(UUID=1733efb9-71af-4956-bd3a-0d3167d94d0c) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 172 | @BluetoothBaseTest.bt_test_wrap |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 173 | def test_contact_download(self): |
| 174 | """Test Contact Download |
| 175 | |
| 176 | Test download of contacts from a clean state. |
| 177 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 178 | Precondition: |
| 179 | 1. Devices are paired. |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 180 | |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 181 | Steps: |
| 182 | 1. Erase contacts from PSE and PCE. |
| 183 | 2. Add a predefined list of contacts to PSE. |
| 184 | 3. Connect PCE to PSE to perform transfer. |
| 185 | 4. Compare transfered contacts. |
| 186 | 5. Disconnect. |
| 187 | 6. Verify PCE cleaned up contact list. |
| 188 | |
| 189 | Returns: |
| 190 | Pass if True |
| 191 | Fail if False |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 192 | """ |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 193 | bt_contacts_utils.generate_contact_list(self.contacts_destination_path, |
| 194 | PSE_CONTACTS_FILE, 100) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 195 | phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 196 | self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 197 | bt_test_utils.connect_pri_to_sec( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 198 | self.pce, self.pse, |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 199 | set([BtEnum.BluetoothProfile.PBAP_CLIENT.value])) |
| 200 | bt_contacts_utils.wait_for_phone_number_update_complete( |
| 201 | self.pce, phone_numbers_added) |
| 202 | if not self.verify_contacts_match(): |
| 203 | return False |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 204 | return bt_contacts_utils.erase_contacts(self.pce) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 205 | |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 206 | #@BluetoothTest(UUID=99dc6ac6-b7cf-45ce-927b-8c4ebf8ab664) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 207 | @BluetoothBaseTest.bt_test_wrap |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 208 | def test_modify_phonebook(self): |
| 209 | """Test Modify Phonebook |
| 210 | |
| 211 | Test changing contacts and reconnecting PBAP. |
| 212 | |
| 213 | Precondition: |
| 214 | 1. Devices are paired. |
| 215 | |
| 216 | Steps: |
| 217 | 1. Add a predefined list of contacts to PSE. |
| 218 | 2. Connect PCE to PSE to perform transfer. |
| 219 | 3. Verify that contacts match. |
| 220 | 4. Change some contacts on the PSE. |
| 221 | 5. Reconnect PCE to PSE to perform transfer. |
| 222 | 6. Verify that new contacts match. |
| 223 | |
| 224 | Returns: |
| 225 | Pass if True |
| 226 | Fail if False |
| 227 | """ |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 228 | bt_contacts_utils.generate_contact_list(self.contacts_destination_path, |
| 229 | PSE_CONTACTS_FILE, 100) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 230 | phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 231 | self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 232 | if not self.connect_and_verify(phone_numbers_added): |
| 233 | return False |
| 234 | |
Joseph Pirozzo | 66fb3f6 | 2016-05-31 16:57:39 -0700 | [diff] [blame] | 235 | bt_contacts_utils.erase_contacts(self.pse) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 236 | bt_contacts_utils.generate_contact_list(self.contacts_destination_path, |
| 237 | PSE_CONTACTS_FILE, 110, 2) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 238 | phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 239 | self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 240 | return self.connect_and_verify(phone_numbers_added) |
| 241 | |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 242 | #@BluetoothTest(UUID=bbe31bf5-51e8-4175-b266-1c7750e44f5b) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 243 | @BluetoothBaseTest.bt_test_wrap |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 244 | def test_special_contacts(self): |
| 245 | """Test Special Contacts |
| 246 | |
| 247 | Test numerous special cases of contacts that could cause errors. |
| 248 | |
| 249 | Precondition: |
| 250 | 1. Devices are paired. |
| 251 | |
| 252 | Steps: |
| 253 | 1. Add a predefined list of contacts to PSE that includes special cases: |
| 254 | 2. Connect PCE to PSE to perform transfer. |
| 255 | 3. Verify that contacts match. |
| 256 | |
| 257 | Returns: |
| 258 | Pass if True |
| 259 | Fail if False |
| 260 | """ |
| 261 | |
| 262 | vcards = [] |
| 263 | |
| 264 | # Generate a contact with no email address |
| 265 | current_contact = bt_contacts_utils.VCard() |
| 266 | current_contact.first_name = "Mr." |
| 267 | current_contact.last_name = "Smiley" |
| 268 | current_contact.add_phone_number( |
| 269 | bt_contacts_utils.generate_random_phone_number()) |
| 270 | vcards.append(current_contact) |
| 271 | |
| 272 | # Generate a 2nd contact with the same name but different phone number |
| 273 | current_contact = bt_contacts_utils.VCard() |
| 274 | current_contact.first_name = "Mr." |
| 275 | current_contact.last_name = "Smiley" |
| 276 | current_contact.add_phone_number( |
| 277 | bt_contacts_utils.generate_random_phone_number()) |
| 278 | vcards.append(current_contact) |
| 279 | |
| 280 | # Generate a contact with no name |
| 281 | current_contact = bt_contacts_utils.VCard() |
| 282 | current_contact.email = "{}@gmail.com".format( |
| 283 | bt_contacts_utils.generate_random_string()) |
| 284 | current_contact.add_phone_number( |
| 285 | bt_contacts_utils.generate_random_phone_number()) |
| 286 | vcards.append(current_contact) |
| 287 | |
| 288 | # Generate a contact with random characters in its name |
| 289 | current_contact = bt_contacts_utils.VCard() |
| 290 | current_contact.first_name = bt_contacts_utils.generate_random_string() |
| 291 | current_contact.last_name = bt_contacts_utils.generate_random_string() |
| 292 | current_contact.add_phone_number( |
| 293 | bt_contacts_utils.generate_random_phone_number()) |
| 294 | vcards.append(current_contact) |
| 295 | |
| 296 | # Generate a contact with only a phone number |
| 297 | current_contact = bt_contacts_utils.VCard() |
| 298 | current_contact.add_phone_number( |
| 299 | bt_contacts_utils.generate_random_phone_number()) |
| 300 | vcards.append(current_contact) |
| 301 | |
| 302 | # Generate a 2nd contact with only a phone number |
| 303 | current_contact = bt_contacts_utils.VCard() |
| 304 | current_contact.add_phone_number( |
| 305 | bt_contacts_utils.generate_random_phone_number()) |
| 306 | vcards.append(current_contact) |
| 307 | |
| 308 | bt_contacts_utils.create_new_contacts_vcf_from_vcards( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 309 | self.contacts_destination_path, PSE_CONTACTS_FILE, vcards) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 310 | |
| 311 | phone_numbers_added = bt_contacts_utils.import_device_contacts_from_vcf( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 312 | self.pse, self.contacts_destination_path, PSE_CONTACTS_FILE) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 313 | |
| 314 | return self.connect_and_verify(phone_numbers_added) |
| 315 | |
Phillip Walker | 827112a | 2016-09-08 16:27:19 -0700 | [diff] [blame] | 316 | #@BluetoothTest(UUID=2aa2bd00-86cc-4f39-a06a-90b17ea5b320) |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 317 | @BluetoothBaseTest.bt_test_wrap |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 318 | def test_call_log(self): |
| 319 | """Test Call Log |
| 320 | |
| 321 | Test that Call Logs are transfered |
| 322 | |
| 323 | Precondition: |
| 324 | 1. Devices are paired. |
| 325 | |
| 326 | Steps: |
| 327 | 1. Add a predefined list of calls to the PSE call log. |
| 328 | 2. Connect PCE to PSE to allow call log transfer |
| 329 | 3. Verify the Missed, Incoming, and Outgoing Call History |
| 330 | |
| 331 | Returns: |
| 332 | Pass if True |
| 333 | Fail if False |
| 334 | """ |
| 335 | |
| 336 | bt_contacts_utils.add_call_log( |
| 337 | self.pse, bt_contacts_utils.INCOMMING_CALL_TYPE, |
| 338 | bt_contacts_utils.generate_random_phone_number().phone_number, |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 339 | int(time.time() * 1000)) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 340 | bt_contacts_utils.add_call_log( |
| 341 | self.pse, bt_contacts_utils.INCOMMING_CALL_TYPE, |
| 342 | bt_contacts_utils.generate_random_phone_number().phone_number, |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 343 | int(time.time()) * 1000 - 4 * CALL_LOG_TIME_OFFSET_IN_MSEC) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 344 | bt_contacts_utils.add_call_log( |
| 345 | self.pse, bt_contacts_utils.OUTGOING_CALL_TYPE, |
| 346 | bt_contacts_utils.generate_random_phone_number().phone_number, |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 347 | int(time.time()) * 1000 - CALL_LOG_TIME_OFFSET_IN_MSEC) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 348 | bt_contacts_utils.add_call_log( |
| 349 | self.pse, bt_contacts_utils.MISSED_CALL_TYPE, |
| 350 | bt_contacts_utils.generate_random_phone_number().phone_number, |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 351 | int(time.time()) * 1000 - 2 * CALL_LOG_TIME_OFFSET_IN_MSEC) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 352 | bt_contacts_utils.add_call_log( |
| 353 | self.pse, bt_contacts_utils.MISSED_CALL_TYPE, |
| 354 | bt_contacts_utils.generate_random_phone_number().phone_number, |
tturney | 4606078 | 2016-11-14 16:44:38 -0800 | [diff] [blame] | 355 | int(time.time()) * 1000 - 2 * CALL_LOG_TIME_OFFSET_IN_MSEC) |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 356 | |
| 357 | bt_test_utils.connect_pri_to_sec( |
tturney | e3934a2 | 2016-10-20 15:47:34 -0700 | [diff] [blame] | 358 | self.pce, self.pse, |
Joseph Pirozzo | f304d36 | 2016-06-17 15:15:40 -0700 | [diff] [blame] | 359 | set([BtEnum.BluetoothProfile.PBAP_CLIENT.value])) |
| 360 | pse_call_log_count = self.pse.droid.callLogGetCount() |
| 361 | self.log.info("Waiting for {} call logs to be transfered".format( |
| 362 | pse_call_log_count)) |
| 363 | bt_contacts_utils.wait_for_call_log_update_complete(self.pce, |
| 364 | pse_call_log_count) |
| 365 | |
| 366 | if not bt_contacts_utils.get_and_compare_call_logs( |
| 367 | self.pse, self.pce, bt_contacts_utils.INCOMMING_CALL_TYPE): |
| 368 | return False |
| 369 | if not bt_contacts_utils.get_and_compare_call_logs( |
| 370 | self.pse, self.pce, bt_contacts_utils.OUTGOING_CALL_TYPE): |
| 371 | return False |
| 372 | if not bt_contacts_utils.get_and_compare_call_logs( |
| 373 | self.pse, self.pce, bt_contacts_utils.MISSED_CALL_TYPE): |
| 374 | return False |
| 375 | |
| 376 | return True |