def test_AndroidDevice_build_info(self, MockFastboot, MockAdbProxy): """Verifies the AndroidDevice object's basic attributes are correctly set after instantiation. """ ad = android_device.AndroidDevice(serial='1') build_info = ad.build_info self.assertEqual(build_info['build_id'], 'AB42') self.assertEqual(build_info['build_type'], 'userdebug')
def test_AndroidDevice_snippet_cleanup(self, MockGetPort, MockSnippetClient, MockFastboot, MockAdbProxy): ad = android_device.AndroidDevice(serial='1') ad.services.start_all() ad.load_snippet('snippet', MOCK_SNIPPET_PACKAGE_NAME) ad.unload_snippet('snippet') self.assertFalse(hasattr(ad, 'snippet'))
def test_AndroidDevice_take_bug_report_with_destination( self, create_dir_mock, FastbootProxy, MockAdbProxy): mock_serial = '1' ad = android_device.AndroidDevice(serial=mock_serial) dest = tempfile.gettempdir() ad.take_bug_report("test_something", "sometime", destination=dest) expected_path = os.path.join(dest) create_dir_mock.assert_called_with(expected_path)
def test_AndroidDevice_update_serial_with_service_running( self, stop_proc_mock, start_proc_mock, creat_dir_mock, FastbootProxy, MockAdbProxy): ad = android_device.AndroidDevice(serial='1') ad.services.register('logcat', logcat.Logcat) expected_msg = '.* Cannot change device serial number when there is service running.' with self.assertRaisesRegex(android_device.Error, expected_msg): ad.update_serial('2')
def test_AndroidDevice_load_snippet_dup_package( self, MockGetPort, MockSnippetClient, MockFastboot, MockAdbProxy): ad = android_device.AndroidDevice(serial='1') ad.load_snippet('snippet', MOCK_SNIPPET_PACKAGE_NAME) expected_msg = ('Snippet package "%s" has already been loaded under ' 'name "snippet".') % MOCK_SNIPPET_PACKAGE_NAME with self.assertRaisesRegex(android_device.Error, expected_msg): ad.load_snippet('snippet2', MOCK_SNIPPET_PACKAGE_NAME)