1"""
2  Copyright (C) 2023 The Android Open Source Project
3
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15
16
17
18  Test Steps:
191. Tap on Phone icon from facet rail or App launcher to launch Dialer app
202. Go to Settings under Dialer-> Contact order
213. Select Contact order with 'Last name'
224. Go to contacts and see that contact list sorted with  Lastname, Firstname
23
24"""
25
26from utilities import constants
27from utilities.main_utils import common_main
28from bluetooth_test import bluetooth_base_test
29
30
31class ContactSearchByLastNameTest(bluetooth_base_test.BluetoothBaseTest):
32
33  def setup_test(self):
34    #Upload contacts to phone device
35    file_path = constants.PATH_TO_CONTACTS_VCF_FILE
36    #TODO- retest again after (b/308018112) is fixed.
37    #contacts were loaded manually for testing
38    self.call_utils.upload_vcf_contacts_to_device(self.target, file_path)
39
40    # Pair the devices
41    self.bt_utils.pair_primary_to_secondary()
42    super().enable_recording()
43
44  def test_sort_contacts_by_last_name(self):
45    # Navigate to the Contacts page
46    expected_last_name = constants.EXPECTED_CONTACT_LAST_NAME
47    self.call_utils.open_phone_app()
48    self.call_utils.open_contacts()
49    self.call_utils.wait_with_log(constants.DEFAULT_WAIT_TIME_FIVE_SECS)
50    self.call_utils.search_contact_by_name(
51        expected_last_name
52    )
53    self.call_utils.verify_search_results_contain_target_search(
54        expected_last_name
55    )
56
57if __name__ == '__main__':
58  common_main()
59