1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - 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 ViWiFi live call test 18""" 19 20import time 21from queue import Empty 22from acts.test_decorators import test_tracker_info 23from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 24from acts.test_utils.tel.tel_defines import AUDIO_ROUTE_EARPIECE 25from acts.test_utils.tel.tel_defines import AUDIO_ROUTE_SPEAKER 26from acts.test_utils.tel.tel_defines import CALL_STATE_ACTIVE 27from acts.test_utils.tel.tel_defines import CALL_STATE_HOLDING 28from acts.test_utils.tel.tel_defines import CALL_CAPABILITY_MANAGE_CONFERENCE 29from acts.test_utils.tel.tel_defines import CALL_CAPABILITY_MERGE_CONFERENCE 30from acts.test_utils.tel.tel_defines import CALL_CAPABILITY_SWAP_CONFERENCE 31from acts.test_utils.tel.tel_defines import CALL_PROPERTY_CONFERENCE 32from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_VIDEO_SESSION_EVENT 33from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_VOLTE_ENABLED 34from acts.test_utils.tel.tel_defines import VT_STATE_AUDIO_ONLY 35from acts.test_utils.tel.tel_defines import VT_STATE_BIDIRECTIONAL 36from acts.test_utils.tel.tel_defines import VT_STATE_BIDIRECTIONAL_PAUSED 37from acts.test_utils.tel.tel_defines import VT_VIDEO_QUALITY_DEFAULT 38from acts.test_utils.tel.tel_defines import VT_STATE_RX_ENABLED 39from acts.test_utils.tel.tel_defines import VT_STATE_TX_ENABLED 40from acts.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING 41from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL 42from acts.test_utils.tel.tel_defines import EVENT_VIDEO_SESSION_EVENT 43from acts.test_utils.tel.tel_defines import EventTelecomVideoCallSessionEvent 44from acts.test_utils.tel.tel_defines import SESSION_EVENT_RX_PAUSE 45from acts.test_utils.tel.tel_defines import SESSION_EVENT_RX_RESUME 46from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 47from acts.test_utils.tel.tel_test_utils import call_setup_teardown 48from acts.test_utils.tel.tel_test_utils import disconnect_call_by_id 49from acts.test_utils.tel.tel_test_utils import hangup_call 50from acts.test_utils.tel.tel_test_utils import multithread_func 51from acts.test_utils.tel.tel_test_utils import num_active_calls 52from acts.test_utils.tel.tel_test_utils import verify_http_connection 53from acts.test_utils.tel.tel_test_utils import verify_incall_state 54from acts.test_utils.tel.tel_test_utils import wait_for_video_enabled 55from acts.test_utils.tel.tel_video_utils import get_call_id_in_video_state 56from acts.test_utils.tel.tel_video_utils import \ 57 is_phone_in_call_video_bidirectional 58from acts.test_utils.tel.tel_video_utils import \ 59 is_phone_in_call_viwifi_bidirectional 60from acts.test_utils.tel.tel_video_utils import is_phone_in_call_voice_hd 61from acts.test_utils.tel.tel_video_utils import phone_setup_video 62from acts.test_utils.tel.tel_video_utils import \ 63 verify_video_call_in_expected_state 64from acts.test_utils.tel.tel_video_utils import video_call_downgrade 65from acts.test_utils.tel.tel_video_utils import video_call_modify_video 66from acts.test_utils.tel.tel_video_utils import video_call_setup_teardown 67from acts.test_utils.tel.tel_voice_utils import get_audio_route 68from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 69from acts.test_utils.tel.tel_voice_utils import phone_setup_volte 70from acts.test_utils.tel.tel_voice_utils import set_audio_route 71from acts.test_utils.tel.tel_voice_utils import get_cep_conference_call_id 72from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan 73 74DEFAULT_LONG_DURATION_CALL_TOTAL_DURATION = 1 * 60 * 60 # default 1 hour 75 76 77class TelWifiVideoTest(TelephonyBaseTest): 78 def setup_class(self): 79 super().setup_class() 80 81 self.stress_test_number = self.get_stress_test_number() 82 83 self.long_duration_call_total_duration = self.user_params.get( 84 "long_duration_call_total_duration", 85 DEFAULT_LONG_DURATION_CALL_TOTAL_DURATION) 86 87 """ Tests Begin """ 88 89 @test_tracker_info(uuid="375e9b88-8d8e-45fe-8502-e4da4147682d") 90 @TelephonyBaseTest.tel_test_wrap 91 def test_call_video_to_video_wifi_preferred(self): 92 """ Test ViWifi<->ViWifi call functionality. 93 94 Make Sure PhoneA is in iWLAN mode (with Video Calling). 95 Make Sure PhoneB is in iWLAN mode (with Video Calling). 96 Connect to Wifi 97 Call from PhoneA to PhoneB as Bi-Directional Video, 98 Accept on PhoneB as video call, hang up on PhoneA. 99 100 Returns: 101 True if pass; False if fail. 102 """ 103 ads = self.android_devices 104 tasks = [ 105 (phone_setup_iwlan, 106 (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED, 107 self.wifi_network_ssid, self.wifi_network_pass)), 108 (phone_setup_iwlan, 109 (self.log, ads[1], False, WFC_MODE_WIFI_PREFERRED, 110 self.wifi_network_ssid, self.wifi_network_pass)), 111 ] 112 if not multithread_func(self.log, tasks): 113 self.log.error("Phone Failed to Set Up Properly.") 114 return False 115 116 if not video_call_setup_teardown( 117 self.log, 118 ads[0], 119 ads[1], 120 ads[0], 121 video_state=VT_STATE_BIDIRECTIONAL, 122 verify_caller_func=is_phone_in_call_viwifi_bidirectional, 123 verify_callee_func=is_phone_in_call_viwifi_bidirectional): 124 self.log.error("Failed to setup+teardown a call") 125 return False 126 127 return True 128 129 @test_tracker_info(uuid="0c6782b4-fa81-4c18-a7bf-9f0f5cc05d6d") 130 @TelephonyBaseTest.tel_test_wrap 131 def test_call_video_to_video_wifi_preferred_apm(self): 132 """ Test ViWifi<->ViWifi call functionality in APM Mode. 133 134 Make Sure PhoneA is in iWLAN mode (with Video Calling). 135 Make Sure PhoneB is in iWLAN mode (with Video Calling). 136 Turn on APM Mode 137 Connect to Wifi 138 Call from PhoneA to PhoneB as Bi-Directional Video, 139 Accept on PhoneB as video call, hang up on PhoneA. 140 141 Returns: 142 True if pass; False if fail. 143 """ 144 ads = self.android_devices 145 tasks = [ 146 (phone_setup_iwlan, 147 (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED, 148 self.wifi_network_ssid, self.wifi_network_pass)), 149 (phone_setup_iwlan, 150 (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED, 151 self.wifi_network_ssid, self.wifi_network_pass)), 152 ] 153 if not multithread_func(self.log, tasks): 154 self.log.error("Phone Failed to Set Up Properly.") 155 return False 156 157 if not video_call_setup_teardown( 158 self.log, 159 ads[0], 160 ads[1], 161 ads[0], 162 video_state=VT_STATE_BIDIRECTIONAL, 163 verify_caller_func=is_phone_in_call_viwifi_bidirectional, 164 verify_callee_func=is_phone_in_call_viwifi_bidirectional): 165 self.log.error("Failed to setup+teardown a call") 166 return False 167 168 return True 169 170 171""" Tests End """ 172