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 MMS 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 verify_5g_attach_for_both_devices
26from acts_contrib.test_utils.tel.tel_mms_utils import _mms_test_mo
27from acts_contrib.test_utils.tel.tel_mms_utils import _long_mms_test_mo
28from acts_contrib.test_utils.tel.tel_wifi_utils import ensure_wifi_connected
29
30
31class Sa5gMmsTest(TelephonyBaseTest):
32    def setup_class(self):
33        super().setup_class()
34        self.number_of_devices = 2
35
36    def setup_test(self):
37        TelephonyBaseTest.setup_test(self)
38
39    def teardown_test(self):
40        ensure_phones_idle(self.log, self.android_devices)
41
42    """ Tests Begin """
43
44    @test_tracker_info(uuid="74e2ae79-aee4-46e0-9326-fcd3b7f19128")
45    @TelephonyBaseTest.tel_test_wrap
46    def test_5g_sa_mms_mo_mt(self):
47        """Test MMS between two phones in 5g SA
48
49        Provision devices in 5g SA
50        Send and Verify MMS from PhoneA to PhoneB
51        Verify both devices are still on 5g SA
52
53        Returns:
54            True if success.
55            False if failed.
56        """
57        ads = self.android_devices
58        if not provision_device_for_5g(self.log, ads, nr_type='sa'):
59            return False
60
61        if not _mms_test_mo(self.log, ads):
62            return False
63
64        if not verify_5g_attach_for_both_devices(self.log, ads, nr_type='sa'):
65            return False
66
67        self.log.info("PASS - mms test over 5g sa validated")
68        return True
69
70    @test_tracker_info(uuid="6cd173f5-bd1d-44bb-aac2-ac63f37b9a62")
71    @TelephonyBaseTest.tel_test_wrap
72    def test_5g_sa_mms_long_message_mo_mt(self):
73        """Test MMS basic function between two phone. Phones in sa 5G network.
74
75        Airplane mode is off. Phone in 5G SA.
76        Send MMS 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_mms_test_mo(self.log, ads)
93
94    @test_tracker_info(uuid="83d24fb5-1ebd-42e0-a3d1-b85b607234e2")
95    @TelephonyBaseTest.tel_test_wrap
96    def test_5g_sa_mms_mo_mt_wifi(self):
97        """Test MMS basic function between two phone. Phones in sa 5g network.
98
99        Airplane mode is off. Phone in sa 5G.
100        Connect to Wifi.
101        Send MMS from PhoneA to PhoneB.
102        Verify received message on PhoneB is correct.
103
104        Returns:
105            True if success.
106            False if failed.
107        """
108
109        ads = self.android_devices
110
111        if not disable_apm_mode_both_devices(self.log, ads):
112            return False
113
114        if not provision_device_for_5g(self.log, ads, nr_type='sa'):
115            return False
116
117        ensure_wifi_connected(self.log, ads[0], self.wifi_network_ssid,
118                              self.wifi_network_pass)
119
120        return _mms_test_mo(self.log, ads)
121
122    """ Tests End """
123