def test_002_build_android_release_uglify_snapshot_sourcemap(self): # https://github.com/NativeScript/nativescript-dev-webpack/issues/920 result = Tns.build_android(self.app_name, release=True, uglify=True, snapshot=True, source_map=True) assert "ERROR in NativeScriptSnapshot. Snapshot generation failed!" not in result.output assert "Target architecture: arm64-v8a" not in result.output # Verify snapshot files in the built .apk apk_path = TnsPaths.get_apk_path(app_name=self.app_name, release=True) if Settings.HOST_OS != OSType.WINDOWS: TnsAssert.snapshot_build(apk_path, self.temp_folder) # Verify app is built with android sdk 29 by default TnsAssert.string_in_android_manifest(apk_path, 'compileSdkVersion="29"') # Configs are respected assert File.exists(TnsPaths.get_apk_path(self.app_name, release=True)) # Create zip command = "tar -czf " + self.app_name + "/app/app.tar.gz " + self.app_name + "/app/app.js" run(cmd=command, cwd=Settings.TEST_RUN_HOME, wait=True) assert File.exists(os.path.join(self.app_path, 'app', 'app.tar.gz'))
def run_hello_world_js_ts(app_name, platform, device, bundle=True, hmr=True, uglify=False, release=False, aot=False, snapshot=False, instrumented=False, sync_all_files=False, just_launch=False, default_andr_sdk='29', timeout=240): # Execute `tns run` and wait until logs are OK result = Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False, bundle=bundle, hmr=hmr, release=release, uglify=uglify, aot=aot, snapshot=snapshot, sync_all_files=sync_all_files, just_launch=just_launch) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.UNKNOWN, bundle=bundle, hmr=hmr, instrumented=instrumented, device=device, release=release, snapshot=snapshot) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=timeout) # Verify it looks properly device.wait_for_text(text=Changes.JSHelloWord.JS.old_text) device.wait_for_text(text=Changes.JSHelloWord.XML.old_text) blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE) assert blue_count > 100, 'Failed to find blue color on {0}'.format(device.name) initial_state = os.path.join(Settings.TEST_OUT_IMAGES, device.name, 'initial_state.png') device.get_screen(path=initial_state) if platform == Platform.ANDROID: # Verify android sdk the app is built with if release: apk_path = TnsPaths.get_apk_path(app_name=app_name, release=True) else: apk_path = TnsPaths.get_apk_path(app_name=app_name, release=False) TnsAssert.string_in_android_manifest(apk_path, 'compileSdkVersion="{0}"'.format(default_andr_sdk)) if snapshot and Settings.HOST_OS != OSType.WINDOWS: TnsAssert.snapshot_build(TnsPaths.get_apk_path(app_name=app_name, release=True), Settings.TEST_OUT_TEMP) return result
def test_001_build_android(self): Tns.build_android(self.app_name) assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.plist')) assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.android.js')) assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.ios.js')) src = os.path.join(self.app_name, 'app', 'app.js') dest_1 = os.path.join(self.app_name, 'app', 'new.android.js') dest_2 = os.path.join(self.app_name, 'app', 'new.ios.js') File.copy(src, dest_1) File.copy(src, dest_2) result = Tns.build_android(self.app_name) assert "Gradle build..." in result.output, "Gradle build not called." assert result.output.count( "Gradle build...") == 1, "Only one gradle build is triggered." assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.plist')) assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.android.js')) assert not File.exists( os.path.join(TnsPaths.get_platforms_android_folder(self.app_name), '*.ios.js')) # Verify apk does not contain aar files apk_path = TnsPaths.get_apk_path(app_name=self.app_name, release=False) File.unzip(apk_path, self.temp_folder) # Clean META-INF folder. It contains com.android.support.... files which are expected to be there due to # https://github.com/NativeScript/nativescript-cli/pull/3923 Folder.clean(os.path.join(self.temp_folder, 'META-INF')) assert not File.pattern_exists(self.temp_folder, '*.aar') assert not File.pattern_exists(self.temp_folder, '*.plist') assert not File.pattern_exists(self.temp_folder, '*.android.*') assert not File.pattern_exists(self.temp_folder, '*.ios.*') # Verify app is built with android sdk 29 by default TnsAssert.string_in_android_manifest(apk_path, 'compileSdkVersion="29"') Folder.clean(self.temp_folder) # Verify incremental native build result = Tns.exec_command(command='build --clean', path=self.app_name, platform=Platform.ANDROID) assert "Gradle clean..." in result.output, "Gradle clean is not called." assert "Gradle build..." in result.output, "Gradle build is not called." assert result.output.count( "Gradle build...") == 1, "More than 1 gradle build is triggered."