1#!/usr/bin/env python3.4 2# 3# Copyright 2022 - 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 18import time 19from acts import asserts 20from acts import signals 21from acts.test_decorators import test_tracker_info 22from acts.libs.utils.multithread import multithread_func 23from acts.utils import get_current_epoch_time 24from acts_contrib.test_utils.net import ui_utils as uutils 25from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 26from acts.controllers.android_lib.errors import AndroidDeviceError 27from acts_contrib.test_utils.tel.tel_logging_utils import log_screen_shot 28from acts_contrib.test_utils.tel.tel_logging_utils import get_screen_shot_log 29from acts_contrib.test_utils.tel.tel_logging_utils import get_screen_shot_logs 30from acts_contrib.test_utils.tel.tel_rcs_utils import go_to_message_app 31from acts_contrib.test_utils.tel.tel_rcs_utils import go_to_rcs_settings 32from acts_contrib.test_utils.tel.tel_rcs_utils import is_rcs_enabled 33from acts_contrib.test_utils.tel.tel_rcs_utils import enable_chat_feature 34from acts_contrib.test_utils.tel.tel_rcs_utils import disable_chat_feature 35from acts_contrib.test_utils.tel.tel_rcs_utils import is_rcs_connected 36 37 38 39class TelLiveGFTRcsTest(TelephonyBaseTest): 40 def setup_class(self): 41 super().setup_class() 42 self.my_error_msg = "" 43 44 def setup_test(self): 45 TelephonyBaseTest.setup_test(self) 46 for ad in self.android_devices: 47 ad.send_keycode("HOME") 48 49 def teardown_test(self): 50 TelephonyBaseTest.teardown_test(self) 51 get_screen_shot_logs(self.android_devices) 52 53 def teardown_class(self): 54 TelephonyBaseTest.teardown_class(self) 55 56 57 def test_is_single_reg_capable(self): 58 """ Tests single registration provisioning. 59 60 """ 61 for ad in self.android_devices: 62 isRcsVolteSingleRegistrationCapable = ad.droid.isRcsVolteSingleRegistrationCapable() 63 ad.log.info("isRcsVolteSingleRegistrationCapable: %r", 64 isRcsVolteSingleRegistrationCapable) 65 66 @TelephonyBaseTest.tel_test_wrap 67 @test_tracker_info(uuid="eb68fdc6-b070-4ba2-92f4-3dd8aca78a2b") 68 def test_rcs_enable(self): 69 """1.1.1 - First time Registration over Cellular - Successful 70 """ 71 tasks = [(enable_chat_feature, (ad,)) for ad in self.android_devices] 72 if not multithread_func(self.log, tasks): 73 raise signals.TestFailure("enable_chat_feature failure: %s" 74 %(self.my_error_msg)) 75 76 @TelephonyBaseTest.tel_test_wrap 77 @test_tracker_info(uuid="176a0230-c35d-454d-a1f7-c706f71c5dbd") 78 def test_rcs_message(self): 79 """Sends rcs message 80 81 Returns: 82 True if pass; False if fail 83 """ 84 try: 85 for ad in self.android_devices: 86 enable_chat_feature(ad) 87 # Go to message 88 go_to_message_app(ad) 89 time.sleep(2) 90 if uutils.has_element(ad, text="Start chat"): 91 uutils.wait_and_click(ad, text="Start chat") 92 time.sleep(2) 93 log_screen_shot(ad, "click_start_chat") 94 # input MT phone number 95 uutils.wait_and_input_text(ad, input_text=ad.mt_phone_number) 96 time.sleep(2) 97 self.log.info("input mt phone number") 98 log_screen_shot(ad, "input_message_phone_num") 99 self.log.info("select receiver") 100 # com.google.android.apps.messaging:id/contact_picker_create_group 101 uutils.wait_and_click(ad, resource_id="com.google.android.apps." 102 "messaging:id/contact_picker_create_group") 103 time.sleep(2) 104 log_screen_shot(ad, "message_select_receiver") 105 # input chat message 106 uutils.wait_and_input_text(ad, input_text="RCS test") 107 self.log.info("input rcs message") 108 time.sleep(2) 109 log_screen_shot(ad, "message_input_rcs") 110 self.log.info("click send message button") 111 uutils.wait_and_click(ad, resource_id="com.google.android.apps." 112 "messaging:id/send_message_button_icon") 113 time.sleep(2) 114 log_screen_shot(ad, "message_click_send") 115 is_rcs_connected(ad) 116 return True 117 except AndroidDeviceError: 118 return False 119 120 121