1#!/usr/bin/env python3.4
2#
3#   Copyright 2021 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of 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,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16"""
17    Test Script for 5G SA SMS scenarios
18"""
19
20from acts.test_decorators import test_tracker_info
21from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
22from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phones_idle
23from acts_contrib.test_utils.tel.tel_5g_test_utils import disable_apm_mode_both_devices
24from acts_contrib.test_utils.tel.tel_5g_test_utils import provision_device_for_5g
25from acts_contrib.test_utils.tel.tel_5g_test_utils import provision_both_devices_for_volte
26from acts_contrib.test_utils.tel.tel_5g_test_utils import verify_5g_attach_for_both_devices
27from acts_contrib.test_utils.tel.tel_sms_utils import _sms_test_mo
28from acts_contrib.test_utils.tel.tel_sms_utils import _long_sms_test_mo
29
30
31class Sa5gSmsTest(TelephonyBaseTest):
32    def setup_class(self):
33        super().setup_class()
34
35    def setup_test(self):
36        TelephonyBaseTest.setup_test(self)
37
38    def teardown_test(self):
39        ensure_phones_idle(self.log, self.android_devices)
40
41    """ Tests Begin """
42
43    @test_tracker_info(uuid="8949d1c7-1719-4960-b79c-041b467fb5ef")
44    @TelephonyBaseTest.tel_test_wrap
45    def test_5g_sa_sms_mo_mt(self):
46        """Test SMS between two phones in 5g SA
47
48        Provision devices in 5g SA
49        Send and Verify SMS from PhoneA to PhoneB
50        Verify both devices are still on 5g SA
51
52        Returns:
53            True if success.
54            False if failed.
55        """
56        ads = self.android_devices
57        if not provision_device_for_5g(self.log, ads, nr_type='sa'):
58            return False
59
60        if not _sms_test_mo(self.log, ads):
61            return False
62
63        if not verify_5g_attach_for_both_devices(self.log, ads, nr_type='sa'):
64            return False
65
66        self.log.info("PASS - SMS test over 5G SA validated")
67        return True
68
69    @test_tracker_info(uuid="5c7a717b-1f98-44b7-95e7-0e83afb82a84")
70    @TelephonyBaseTest.tel_test_wrap
71    def test_5g_sa_sms_long_message_mo_mt(self):
72        """Test SMS basic function between two phone.
73
74        Phones in sa 5G network.
75        Airplane mode is off.
76        Send SMS from PhoneA to PhoneB.
77        Verify received message on PhoneB is correct.
78
79        Returns:
80            True if success.
81            False if failed.
82        """
83
84        ads = self.android_devices
85
86        if not disable_apm_mode_both_devices(self.log, ads):
87            return False
88
89        if not provision_device_for_5g(self.log, ads, nr_type='sa'):
90            return False
91
92        return _long_sms_test_mo(self.log, ads)
93
94    """ Tests End """
95