1 # 2 # Copyright 2017 - 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 from acts import asserts 17 from acts import base_test 18 from acts.controllers import adb 19 from acts.test_decorators import test_tracker_info 20 from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection 21 from acts.test_utils.tel.tel_test_utils import verify_http_connection 22 from acts.test_utils.wifi import wifi_test_utils as wutils 23 24 dum_class = "com.android.tests.connectivity.uid.ConnectivityTestActivity" 25 26 27 class CoreNetworkingTest(base_test.BaseTestClass): 28 """ Tests for UID networking """ 29 30 def setup_class(self): 31 """ Setup devices for tests and unpack params """ 32 self.dut = self.android_devices[0] 33 wutils.wifi_toggle_state(self.dut, False) 34 self.dut.droid.telephonyToggleDataConnection(True) 35 wait_for_cell_data_connection(self.log, self.dut, True) 36 asserts.assert_true( 37 verify_http_connection(self.log, self.dut), 38 "HTTP verification failed on cell data connection") 39 40 def teardown_class(self): 41 """ Reset devices """ 42 wutils.wifi_toggle_state(self.dut, True) 43 44 """ Test Cases """ 45 46 @test_tracker_info(uuid="0c89d632-aafe-4bbd-a812-7b0eca6aafc7") 47 def test_uid_derace_data_saver_mode(self): 48 """ Verify UID de-race data saver mode 49 50 Steps: 51 1. Connect DUT to data network and verify internet 52 2. Enable data saver mode 53 3. Launch app and verify internet connectivity 54 4. Disable data saver mode 55 """ 56 # Enable data saver mode 57 self.log.info("Enable data saver mode") 58 self.dut.adb.shell("cmd netpolicy set restrict-background true") 59 60 # Launch app, check internet connectivity and close app 61 self.log.info("Launch app and test internet connectivity") 62 res = self.dut.droid.launchForResult(dum_class) 63 64 # Disable data saver mode 65 self.log.info("Disable data saver mode") 66 self.dut.adb.shell("cmd netpolicy set restrict-background false") 67 68 # Return test result 69 self.log.info("Internet connectivity status after app launch: %s " 70 % res['extras']['result']) 71 return res['extras']['result'] 72