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