1 #/usr/bin/env python3.4 2 # 3 # Copyright (C) 2016 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 # use this file except in compliance with the License. You may obtain a copy of 7 # 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, WITHOUT 13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 # License for the specific language governing permissions and limitations under 15 # the License. 16 """ 17 Test script to test PAN testcases. 18 19 Test Script assumes that an internet connection 20 is available through a telephony provider that has 21 tethering allowed. 22 23 This device was not intended to run in a sheild box. 24 """ 25 from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 26 from acts.test_utils.bt.bt_test_utils import bluetooth_enabled_check 27 from acts.test_utils.bt.bt_test_utils import orchestrate_and_verify_pan_connection 28 from acts.test_utils.tel.tel_test_utils import verify_http_connection 29 from queue import Empty 30 import time 31 32 33 class BtPanTest(BluetoothBaseTest): 34 def __init__(self, controllers): 35 BluetoothBaseTest.__init__(self, controllers) 36 self.pan_dut = self.android_devices[0] 37 self.panu_dut = self.android_devices[1] 38 39 @BluetoothBaseTest.bt_test_wrap 40 def test_pan_connection(self): 41 """Test bluetooth PAN connection 42 43 Test basic PAN connection between two devices. 44 45 Steps: 46 1. Enable Airplane mode on PANU device. Enable Bluetooth only. 47 2. Enable Bluetooth tethering on PAN Service device. 48 3. Pair the PAN Service device to the PANU device. 49 4. Verify that Bluetooth tethering is enabled on PAN Service device. 50 5. Enable PAN profile from PANU device to PAN Service device. 51 6. Verify HTTP connection on PANU device. 52 53 Expected Result: 54 PANU device has internet access. 55 56 Returns: 57 Pass if True 58 Fail if False 59 60 TAGS: Classic, PAN, tethering 61 Priority: 1 62 """ 63 return orchestrate_and_verify_pan_connection(self.pan_dut, 64 self.panu_dut) 65 66 @BluetoothBaseTest.bt_test_wrap 67 def test_pan_connection_then_disconnect(self): 68 """Test bluetooth PAN connection then disconnect service 69 70 Test basic PAN connection between two devices then disconnect 71 service. 72 73 Steps: 74 1. Enable Airplane mode on PANU device. Enable Bluetooth only. 75 2. Enable Bluetooth tethering on PAN Service device. 76 3. Pair the PAN Service device to the PANU device. 77 4. Verify that Bluetooth tethering is enabled on PAN Service device. 78 5. Enable PAN profile from PANU device to PAN Service device. 79 6. Verify HTTP connection on PANU device. 80 7. Disable Bluetooth tethering on PAN Service device. 81 8. Verify no HTTP connection on PANU device. 82 83 Expected Result: 84 PANU device does not have internet access. 85 86 Returns: 87 Pass if True 88 Fail if False 89 90 TAGS: Classic, PAN, tethering 91 Priority: 1 92 """ 93 if not orchestrate_and_verify_pan_connection(self.pan_dut, 94 self.panu_dut): 95 self.log.error("Could not establish a PAN connection.") 96 return False 97 self.pan_dut.droid.bluetoothPanSetBluetoothTethering(False) 98 if verify_http_connection(self.log, self.panu_dut): 99 self.log.error("PANU device still has internet access.") 100 return False 101 self.log.info("PANU device has no internet access as expected.") 102 return True 103