1*800a58d9SAndroid Build Coastguard Worker# Copyright 2021 - The Android Open Source Project 2*800a58d9SAndroid Build Coastguard Worker# 3*800a58d9SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*800a58d9SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*800a58d9SAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*800a58d9SAndroid Build Coastguard Worker# 7*800a58d9SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*800a58d9SAndroid Build Coastguard Worker# 9*800a58d9SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*800a58d9SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*800a58d9SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*800a58d9SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*800a58d9SAndroid Build Coastguard Worker# limitations under the License. 14*800a58d9SAndroid Build Coastguard Worker"""Tests for GoldfishRemoteHost.""" 15*800a58d9SAndroid Build Coastguard Worker 16*800a58d9SAndroid Build Coastguard Workerimport unittest 17*800a58d9SAndroid Build Coastguard Worker 18*800a58d9SAndroid Build Coastguard Workerfrom unittest import mock 19*800a58d9SAndroid Build Coastguard Worker 20*800a58d9SAndroid Build Coastguard Workerfrom acloud.create import avd_spec 21*800a58d9SAndroid Build Coastguard Workerfrom acloud.create import create 22*800a58d9SAndroid Build Coastguard Workerfrom acloud.internal import constants 23*800a58d9SAndroid Build Coastguard Workerfrom acloud.internal.lib import driver_test_lib 24*800a58d9SAndroid Build Coastguard Workerfrom acloud.public.actions import common_operations 25*800a58d9SAndroid Build Coastguard Workerfrom acloud.public.actions import remote_host_gf_device_factory 26*800a58d9SAndroid Build Coastguard Worker 27*800a58d9SAndroid Build Coastguard Workerclass GoldfishRemoteHostTest(driver_test_lib.BaseDriverTest): 28*800a58d9SAndroid Build Coastguard Worker """Test GoldfishRemoteHost method.""" 29*800a58d9SAndroid Build Coastguard Worker 30*800a58d9SAndroid Build Coastguard Worker # pylint: disable=no-member 31*800a58d9SAndroid Build Coastguard Worker def testRun(self): 32*800a58d9SAndroid Build Coastguard Worker """Test Create AVD of goldfish remote host.""" 33*800a58d9SAndroid Build Coastguard Worker args = mock.MagicMock() 34*800a58d9SAndroid Build Coastguard Worker args.skip_pre_run_check = True 35*800a58d9SAndroid Build Coastguard Worker spec = mock.MagicMock() 36*800a58d9SAndroid Build Coastguard Worker spec.avd_type = constants.TYPE_GF 37*800a58d9SAndroid Build Coastguard Worker spec.instance_type = constants.INSTANCE_TYPE_HOST 38*800a58d9SAndroid Build Coastguard Worker spec.image_source = constants.IMAGE_SRC_REMOTE 39*800a58d9SAndroid Build Coastguard Worker spec.num = 1 40*800a58d9SAndroid Build Coastguard Worker spec.connect_webrtc = True 41*800a58d9SAndroid Build Coastguard Worker spec.serial_log_file = None 42*800a58d9SAndroid Build Coastguard Worker self.Patch(avd_spec, "AVDSpec", return_value=spec) 43*800a58d9SAndroid Build Coastguard Worker self.Patch(remote_host_gf_device_factory, 44*800a58d9SAndroid Build Coastguard Worker "RemoteHostGoldfishDeviceFactory") 45*800a58d9SAndroid Build Coastguard Worker self.Patch(common_operations, "CreateDevices") 46*800a58d9SAndroid Build Coastguard Worker create.Run(args) 47*800a58d9SAndroid Build Coastguard Worker remote_host_gf_device_factory.RemoteHostGoldfishDeviceFactory.assert_called_once() 48*800a58d9SAndroid Build Coastguard Worker common_operations.CreateDevices.assert_called_once() 49*800a58d9SAndroid Build Coastguard Worker 50*800a58d9SAndroid Build Coastguard Worker 51*800a58d9SAndroid Build Coastguard Workerif __name__ == '__main__': 52*800a58d9SAndroid Build Coastguard Worker unittest.main() 53