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#  Licensed under the Apache License, Version 2.0 (the "License");
16#  you may not use this file except in compliance with the License.
17#  You may obtain a copy of the License at
18#
19#       http://www.apache.org/licenses/LICENSE-2.0
20#
21#  Unless required by applicable law or agreed to in writing, software
22#  distributed under the License is distributed on an "AS IS" BASIS,
23#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24#  See the License for the specific language governing permissions and
25#  limitations under the License.
26
27
28from bluetooth_sms_test import bluetooth_sms_base_test
29from mobly.controllers import android_device
30from utilities.main_utils import common_main
31from utilities.common_utils import CommonUtils
32
33# Number of seconds for the target to stay discoverable on Bluetooth.
34DISCOVERABLE_TIME = 60
35
36class SMSNewUnreadSMSAutoSyncTest(bluetooth_sms_base_test.BluetoothSMSBaseTest):
37
38    def setup_class(self):
39      super().setup_class()
40      self.common_utils = CommonUtils(self.target, self.discoverer)
41    def setup_test(self):
42
43      # pair the devices
44      self.bt_utils.pair_primary_to_secondary()
45
46      # wait for user permissions popup & give contacts and sms permissions
47      self.call_utils.wait_with_log(20)
48      self.common_utils.click_on_ui_element_with_text('Allow')
49
50      # Clearing the sms from the phone
51      self.call_utils.clear_sms_app(self.target)
52      # Reboot Phone
53      self.target.unload_snippet('mbs')
54      self.call_utils.reboot_device(self.target)
55      self.call_utils.wait_with_log(30)
56      self.target.load_snippet('mbs', android_device.MBS_PACKAGE)
57
58    def test_no_messages_sms(self):
59      # To test 'No messages' appears on HU, when there is no sms
60
61      # Open the sms app
62      self.call_utils.open_sms_app()
63
64      # Verify that there is no new sms currently
65      self.call_utils.verify_sms_no_messages_displayed(True)
66
67    def teardown_test(self):
68      # Go to home screen
69      self.call_utils.press_home()
70      super().teardown_test()
71
72if __name__ == '__main__':
73  common_main()