def testPathToDexForPlatformVersion_dalvikApiLevel(self): sdk_int = version_codes.KITKAT paths_to_apk = ['/some/path'] package_name = 'package.name' arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) with self.assertRaises(list_verification.UnsupportedDeviceError) as _: list_verification.FindOdexFiles(device, package_name)
def testPathToDexForPlatformVersion_lowerApiLevelNoOdexFile(self): sdk_int = version_codes.MARSHMALLOW package_name = 'package.name' paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)] arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) device.FileExists = mock.MagicMock(return_value=False) with self.assertRaises(list_verification.DeviceOSError) as _: list_verification.FindOdexFiles(device, package_name)
def testPathToDexForPlatformVersion_noPaths(self): sdk_int = version_codes.LOLLIPOP paths_to_apk = [] package_name = 'package.name' arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) with self.assertRaises(list_verification.DeviceOSError) as cm: list_verification.FindOdexFiles(device, package_name) message = str(cm.exception) self.assertIn('Could not find data directory', message)
def testPathToDexForPlatformVersion_mashmallowArm64(self): sdk_int = version_codes.MARSHMALLOW package_name = 'package.name' paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)] arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) device.FileExists = mock.MagicMock(return_value=True) odex_files = list_verification.FindOdexFiles(device, package_name) self.assertEqual(odex_files, ['/some/path/package.name-1/oat/arm64/base.odex'])
def testPathToDexForPlatformVersion_multiplePaths(self): sdk_int = version_codes.LOLLIPOP paths_to_apk = ['/first/path', '/second/path'] package_name = 'package.name' arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) odex_files = list_verification.FindOdexFiles(device, package_name) self.assertEqual(odex_files, [ '/data/dalvik-cache/arm64/data@app@[email protected]@classes.dex', '/data/dalvik-cache/arm64/data@app@[email protected]@classes.dex' ])
def testPathToDexForPlatformVersion_lollipopArm(self): sdk_int = version_codes.LOLLIPOP package_name = 'package.name' paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)] arch = 'arm' device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) device.FileExists = mock.MagicMock(return_value=True) odex_files = list_verification.FindOdexFiles(device, package_name) self.assertEqual(odex_files, [ '/data/dalvik-cache/arm/data@[email protected]@[email protected]' ])
def testPathToDexForPlatformVersion_pieNoOdexFile(self): sdk_int = version_codes.PIE package_name = 'package.name' paths_to_apk = ['/some/path/{}-1/base.apk'.format(package_name)] arch = abis.ARM_64 device = mock.Mock(build_version_sdk=sdk_int, product_cpu_abi=arch) device.GetApplicationPaths = mock.MagicMock(return_value=paths_to_apk) device.FileExists = mock.MagicMock(return_value=False) with self.assertRaises(list_verification.DeviceOSError) as cm: list_verification.FindOdexFiles(device, package_name) message = str(cm.exception) self.assertIn('you must run dex2oat on debuggable apps on >= P', message)