def testRun_badInstall(self): self.mox.StubOutClassWithMocks(emulated_device, 'EmulatedDevice') adb_server_port = 1 adb_port = 2 emulator_port = 3 vnc_port = 4 net_type = 'fastnet' mock_device = emulated_device.EmulatedDevice( android_platform=mox.IsA(emulated_device.AndroidPlatform), adb_server_port=adb_server_port, emulator_telnet_port=emulator_port, emulator_adb_port=adb_port, enable_single_step=False, qemu_gdb_port=0, logcat_path='/foo/bar', logcat_filter='FILTER', enable_console_auth=False, enable_g3_monitor=True, enable_gps=True, add_insecure_cert=False) self.mox.StubOutWithMock(unified_launcher, '_RestartDevice') unified_launcher._RestartDevice( mock_device, enable_display=True, start_vnc_on_port=vnc_port, net_type=net_type, input_image_file=None, proto_filepath=None, system_image_files=None, open_gl_driver=emulated_device.NO_OPEN_GL, new_process_group=False, with_audio=False, window_scale=None, with_boot_anim=False, emulator_tmp_dir=None, experimental_open_gl=False) self.mox.StubOutWithMock(mock_device, 'InstallApk') self.mox.StubOutWithMock(mock_device, 'KillEmulator') self.mox.StubOutWithMock(mock_device, 'CleanUp') mock_device.InstallApk('bad_apk').AndRaise(Exception('failure!')) mock_device.KillEmulator() mock_device.SyncTime() self.mox.ReplayAll() self.assertRaises(Exception, unified_launcher._Run, adb_server_port, emulator_port, adb_port, True, vnc_port, '/foo/bar', 'FILTER', system_images=None, input_image_file=None, emulator_metadata_path=None, apks=['bad_apk'], system_apks=[], net_type='fastnet', open_gl_driver=emulated_device.NO_OPEN_GL, new_process_group=False)
def testRun_goodInstall(self): self.mox.StubOutClassWithMocks(emulated_device, 'EmulatedDevice') adb_server_port = 1 adb_port = 2 emulator_port = 3 vnc_port = 4 mock_device = emulated_device.EmulatedDevice( android_platform=mox.IsA(emulated_device.AndroidPlatform), adb_server_port=adb_server_port, emulator_telnet_port=emulator_port, emulator_adb_port=adb_port, enable_single_step=False, qemu_gdb_port=0, logcat_path='/foo/bar', logcat_filter='FILTER', enable_console_auth=False, enable_g3_monitor=True, enable_gps=True, add_insecure_cert=False) self.mox.StubOutWithMock(unified_launcher, '_RestartDevice') unified_launcher._RestartDevice( mock_device, enable_display=True, start_vnc_on_port=vnc_port, net_type='fastnet', input_image_file=None, proto_filepath=None, system_image_files=None, open_gl_driver=emulated_device.NO_OPEN_GL, new_process_group=False, with_audio=False, window_scale=None, with_boot_anim=False, emulator_tmp_dir=None, experimental_open_gl=False) self.mox.StubOutWithMock(mock_device, 'InstallApk') mock_device.InstallApk('hello_world', grant_runtime_permissions=True) mock_device.InstallApk('goodbye', grant_runtime_permissions=True) mock_device.SyncTime() mock_device.BroadcastDeviceReady(None) mock_device.ConnectDevice() self.mox.ReplayAll() unified_launcher._Run(adb_server_port, emulator_port, adb_port, True, vnc_port, '/foo/bar', 'FILTER', input_image_file=None, emulator_metadata_path=None, system_images=None, apks=['hello_world', 'goodbye'], open_gl_driver=emulated_device.NO_OPEN_GL, system_apks=[], net_type='fastnet')
def testRun_addAccounts(self): self.mox.StubOutClassWithMocks(emulated_device, 'EmulatedDevice') adb_server_port = 1 adb_port = 2 emulator_port = 3 vnc_port = 4 accounts = ['user1:password', 'user2:password'] extras1 = collections.OrderedDict() extras1['account_name'] = 'user1' extras1['password'] = '******' extras1.update(unified_launcher._ADD_ACCOUNT_BOOLEAN_EXTRAS) extras2 = collections.OrderedDict() extras2['account_name'] = 'user2' extras2['password'] = '******' extras2.update(unified_launcher._ADD_ACCOUNT_BOOLEAN_EXTRAS) mock_device = emulated_device.EmulatedDevice( android_platform=mox.IsA(emulated_device.AndroidPlatform), adb_server_port=adb_server_port, emulator_telnet_port=emulator_port, emulator_adb_port=adb_port, enable_single_step=False, qemu_gdb_port=0, logcat_path='/foo/bar', logcat_filter='FILTER', enable_console_auth=False, enable_g3_monitor=True, enable_gps=True, add_insecure_cert=False) self.mox.StubOutWithMock(unified_launcher, '_RestartDevice') unified_launcher._RestartDevice( mock_device, enable_display=True, start_vnc_on_port=vnc_port, net_type='fastnet', input_image_file=None, proto_filepath=None, system_image_files=None, open_gl_driver=emulated_device.NO_OPEN_GL, new_process_group=False, with_audio=False, window_scale=None, with_boot_anim=False, emulator_tmp_dir=None, experimental_open_gl=False) mock_device.SyncTime() mock_device.BroadcastDeviceReady(None) mock_device.ConnectDevice() mock_device.BroadcastDeviceReady( extras1, unified_launcher._ADD_ACCOUNT_BROADCAST_ACTION) mock_device.BroadcastDeviceReady( extras2, unified_launcher._ADD_ACCOUNT_BROADCAST_ACTION) self.mox.ReplayAll() unified_launcher._Run(adb_server_port, emulator_port, adb_port, True, vnc_port, '/foo/bar', 'FILTER', input_image_file=None, emulator_metadata_path=None, system_images=None, apks=[], open_gl_driver=emulated_device.NO_OPEN_GL, system_apks=[], net_type='fastnet', accounts=accounts)
def testRun_noInstall(self): self.mox.StubOutClassWithMocks(emulated_device, 'EmulatedDevice') adb_server_port = 1 adb_port = 2 emulator_port = 3 vnc_port = 4 reporter = reporting.NoOpReporter() mock_device = emulated_device.EmulatedDevice( android_platform=mox.IsA(emulated_device.AndroidPlatform), adb_server_port=adb_server_port, emulator_telnet_port=emulator_port, emulator_adb_port=adb_port, enable_single_step=False, qemu_gdb_port=0, logcat_path='/foo/bar', logcat_filter='FILTER', enable_console_auth=False, enable_g3_monitor=True, enable_gps=True, add_insecure_cert=True, reporter=reporter, mini_boot=False, sim_access_rules_file=None, source_properties=None) self.mox.StubOutWithMock(unified_launcher, '_RestartDevice') unified_launcher._RestartDevice( mock_device, enable_display=True, start_vnc_on_port=vnc_port, net_type='fastnet', input_image_file=None, proto_filepath=None, system_image_files=None, open_gl_driver=emulated_device.NO_OPEN_GL, new_process_group=True, with_audio=False, window_scale=None, with_boot_anim=False, emulator_tmp_dir=None, experimental_open_gl=False) self.mox.StubOutWithMock(mock_device, 'InstallApk') self.mox.StubOutWithMock(mock_device, 'InstallCyberVillainsCert') mock_device.SyncTime() mock_device.InstallCyberVillainsCert() mock_device.BroadcastDeviceReady({'test_message': '1234'}) mock_device.ConnectDevice() self.mox.ReplayAll() unified_launcher._Run(adb_server_port, emulator_port, adb_port, True, vnc_port, '/foo/bar', 'FILTER', system_images=None, input_image_file=None, emulator_metadata_path=None, apks=[], system_apks=[], net_type='fastnet', new_process_group=True, open_gl_driver=emulated_device.NO_OPEN_GL, broadcast_message={'test_message': '1234'}, add_insecure_cert=True, reporter=reporter, mini_boot=False)