def test_205_build_android_app_bundle_env_snapshot(self): """Build app with android app bundle option with --bundle and optimisations for snapshot. Verify the output(app.aab) and use bundletool to deploy on device.""" # This test will not run on windows because env.snapshot option is not available on that OS path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app-release.aab") # Configure app with snapshot optimisations source = os.path.join('assets', 'abdoid-app-bundle', 'app.gradle') target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle') File.copy(source, target) webpack_config = os.path.join(self.app_name, 'webpack.config.js') File.replace(webpack_config, 'webpackConfig: config,', """webpackConfig: config, \nuseLibs: true,\nandroidNdkPath: \"$ANDROID_NDK_HOME\",""") # env.snapshot is applicable only in release build result = Tns.build_android(self.app_path, aab=True, release=True, snapshot=True, uglify=True, verify=False) assert "The build result is located at:" in result.output assert path_to_aab in result.output assert File.exists(path_to_aab) # Verify app can be deployed on emulator via bundletool # Use bundletool to create the .apks file self.bundletool_build(self.bundletool_path, path_to_aab, self.path_to_apks) assert File.exists(self.path_to_apks) # Verify that the correct .so file is included in the package File.unzip(self.path_to_apks, os.path.join(self.app_name, 'apks')) File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), os.path.join(self.app_name, 'base_apk')) assert File.exists(os.path.join(self.app_name, 'base_apk', 'lib', 'x86', 'libNativeScript.so')) # Deploy on device self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=self.emu.id) # Start the app on device Adb.start_application(self.emu.id, "org.nativescript.TestApp") # Verify app looks correct inside emulator self.emu.wait_for_text(text='TAP')
def test_201_error_is_shown_when_metadata_folder_in_apk_is_missing(self): """ https://github.com/NativeScript/android-runtime/issues/1471 https://github.com/NativeScript/android-runtime/issues/1382 """ Adb.uninstall("org.nativescript.TestApp", self.emulator.id, True) Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True) apk_folder_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_DEBUG_PATH) apk_path = os.path.join(apk_folder_path, "app-debug.apk") unzip_folder = os.path.join(apk_folder_path, "app-debug") File.unzip(apk_path, unzip_folder) Folder.clean(os.path.join(unzip_folder, "assets", "metadata")) File.delete(apk_path) File.zip(unzip_folder, apk_path) self.sign_apk(apk_path) Adb.install(apk_path, self.emulator.id, 60) Adb.start_application(self.emulator.id, "org.nativescript.TestApp") text_on_screen = "com.tns.NativescriptException: metadata folder couldn\'t be opened!" self.emulator.wait_for_text(text_on_screen) error_message = "Missing metadata in apk is not causing the correct error! Logs: " assert self.emulator.is_text_visible(text_on_screen), error_message + self.emulator.get_text()
def test_200_build_android_app_bundle(self): """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app-debug.aab") result = Tns.build_android(self.app_path, aab=True, verify=False) assert "The build result is located at:" in result.output assert path_to_aab in result.output assert File.exists(path_to_aab) # Verify app can be deployed on emulator via bundletool # Use bundletool to create the .apks file self.bundletool_build(self.bundletool_path, path_to_aab, self.path_to_apks) assert File.exists(self.path_to_apks) # Deploy on device self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=self.emu.id) # Start the app on device Adb.start_application(self.emu.id, "org.nativescript.TestApp") # Verify app looks correct inside emulator self.emu.wait_for_text(text='TAP')
def test_05_start_application(self): if not Adb.is_application_installed(self.emu.id, "com.wdiodemoapp"): Adb.install(self.apk_path, self.emu.id) Adb.start_application(self.emu.id, "com.wdiodemoapp")