Ejemplo n.º 1
0
    def testStopDeviceAndOutputState(self):
        mock_device = emulated_device.EmulatedDevice()
        self.mox.StubOutWithMock(mock_device, 'TakeSnapshot')
        self.mox.StubOutWithMock(mock_device, 'KillEmulator')
        self.mox.StubOutWithMock(mock_device, 'StoreAndCompressUserdata')
        self.mox.StubOutWithMock(mock_device, 'GetEmulatorMetadataProto')
        mock_device.KillEmulator(politely=True)

        output_dir = tempfile.mkdtemp()

        mock_device.StoreAndCompressUserdata(
            os.path.join(output_dir, 'userdata_images.dat'))
        mock_device.GetEmulatorMetadataProto().AndReturn(self._test_proto)

        self.mox.ReplayAll()

        unified_launcher._StopDeviceAndOutputState(mock_device, output_dir)
        self.assertTrue(
            os.path.exists(
                os.path.join(output_dir,
                             unified_launcher._METADATA_FILE_NAME)))

        written_file = open(
            os.path.join(output_dir, unified_launcher._METADATA_FILE_NAME),
            'rb')
        written_proto = emulator_meta_data_pb2.EmulatorMetaDataPb()
        written_proto.ParseFromString(written_file.read())
        written_file.close()
        self.assertEquals(written_proto, self._test_proto)
  def testBoot_display(self):
    self.mox.StubOutClassWithMocks(emulated_device, 'EmulatedDevice')
    initial_boot_device = emulated_device.EmulatedDevice(
        android_platform=mox.IsA(emulated_device.AndroidPlatform),
        qemu_gdb_port=0,
        enable_single_step=False)
    self.mox.StubOutWithMock(initial_boot_device, 'Configure')
    self.mox.StubOutWithMock(initial_boot_device, 'StartDevice')
    skin = 'rabbit_fur'
    memory = '42'
    initial_boot_device.Configure(
        self._tempdir,
        skin,
        memory,
        133,
        36,
        source_properties=None,
        default_properties=None,
        kvm_present=mox.IsA(bool),
        system_image_path=os.path.join(self._tempdir, 'system.img'),
        data_image_path=os.path.join(self._tempdir, 'userdata.img'),
        vendor_img_path=None,
        encryptionkey_img_path=None,
        advanced_features_ini=None,
        build_prop_path=os.path.join(self._tempdir, 'build.prop'))

    initial_boot_device.StartDevice(enable_display=False,
                                    start_vnc_on_port=0,
                                    emulator_tmp_dir=None,
                                    build_time_only_no_op_rendering=True)

    self.mox.StubOutWithMock(initial_boot_device, 'InstallApk')
    self.mox.StubOutWithMock(initial_boot_device, 'KillEmulator')
    self.mox.StubOutWithMock(initial_boot_device, 'IsInstalled')
    self.mox.StubOutWithMock(unified_launcher, '_StopDeviceAndOutputState')

    initial_boot_device.LogToDevice('Device booted.')
    initial_boot_device.InstallApk('hello_world.apk')
    unified_launcher._StopDeviceAndOutputState(initial_boot_device, '/foobar')
    initial_boot_device.CleanUp()

    self.mox.ReplayAll()

    unified_launcher._FirstBootAtBuildTimeOnly(
        [
            os.path.join(self._tempdir, 'system.img'),
            os.path.join(self._tempdir, 'userdata.img'),
            os.path.join(self._tempdir, 'build.prop')
        ],
        skin,
        133,
        memory,
        '/foobar',
        vm_size=36,
        source_properties=None,
        default_properties=None,
        qemu_gdb_port=0,
        enable_single_step=False,
        emulator_tmp_dir=None,
        boot_time_apks=['hello_world.apk'])