xref: /aosp_15_r20/platform_testing/tests/automotive/mobly_tests/dialer/dialer_test_page_refresh.py (revision dd0948b35e70be4c0246aabd6c72554a5eb8b22a)
1#  Copyright (C) 2023 The Android Open Source Project
2#
3#  Licensed under the Apache License, Version 2.0 (the "License");
4#  you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14"""
15
16Test steps:
171 Tap on Phone icon from facet rail or App launcher to launch Dialer app
182. Go to Dialpad and enter some number or go to Search and type any contact name
193. Go to Settings > More > Bluetooth and disconnect the paired mobile device
204. Tap on listed paired device and reconnect the BT connection
215. Go to dialer app again and verify that its refreshed and earlier typed phone number or contact name is not showing
22"""
23
24from bluetooth_test import bluetooth_base_test
25import logging
26from mobly import asserts
27from utilities import constants
28from utilities.main_utils import common_main
29
30
31class DialerPageRefresh(bluetooth_base_test.BluetoothBaseTest):
32
33
34
35    def setup_test(self):
36        # Pair the devices
37        self.bt_utils.pair_primary_to_secondary()
38        super().enable_recording()
39
40    def test_dialer_page_refresh(self):
41
42        test_number = constants.DIALER_THREE_DIGIT_NUMBER
43
44        # Launcher the dialer app and input a number into the dial pad
45        self.call_utils.open_phone_app()
46        self.call_utils.dial_a_number(test_number)
47
48        # Navigate to the bluetooth settings
49        self.discoverer.mbs.pressHome()
50        self.call_utils.open_bluetooth_settings()
51
52        # Disconnect and reconnect the device's bluetooth
53        self.call_utils.press_bluetooth_toggle_on_device(self.target.mbs.btGetName())
54        self.call_utils.wait_with_log(constants.BT_DEFAULT_TIMEOUT)
55        self.call_utils.press_bluetooth_toggle_on_device(self.target.mbs.btGetName())
56
57        # Navigate back to the dial pad and confirm that there is no entered number
58        self.discoverer.mbs.pressHome()
59        self.call_utils.open_phone_app()
60        self.discoverer.mbs.openDialPad()
61        stored_number = self.discoverer.mbs.getNumberInDialPad()
62
63        asserts.assert_true(stored_number == constants.DEFAULT_DIAL_PAD_ENTRY,
64                            "Expected \'%s\' in dial pad after reconnection, but found %s"
65                            % (constants.DEFAULT_DIAL_PAD_ENTRY,
66                               str(stored_number)))
67
68
69    def teardown_test(self):
70        self.call_utils.wait_with_log(5)
71        self.call_utils.press_home()
72        super().teardown_test()
73
74if __name__ == '__main__':
75    common_main()