From d998ef74bfc4b1f205c96b7c416f8584ed22e102 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Fri, 11 Jan 2019 13:43:31 +0200 Subject: [PATCH 01/15] Add tests for android app bundle. Add setup for app.gradle and webpack.config.json --- data/abdoid-app-bundle/app.gradle | 23 ++ data/abdoid-app-bundle/webpack.config.js | 259 +++++++++++++++++++++ tests/build/android/build_android_tests.py | 39 ++++ 3 files changed, 321 insertions(+) create mode 100644 data/abdoid-app-bundle/app.gradle create mode 100644 data/abdoid-app-bundle/webpack.config.js diff --git a/data/abdoid-app-bundle/app.gradle b/data/abdoid-app-bundle/app.gradle new file mode 100644 index 00000000..5cfdda33 --- /dev/null +++ b/data/abdoid-app-bundle/app.gradle @@ -0,0 +1,23 @@ +// Add your native dependencies here: + +// Uncomment to add recyclerview-v7 dependency +//dependencies { +// implementation 'com.android.support:recyclerview-v7:+' +//} + +android { + defaultConfig { + generatedDensities = [] + ndk { + abiFilters.clear() + } + } + aaptOptions { + additionalParameters "--no-version-vectors" + } + sourceSets { + main { + jniLibs.srcDirs = ["$projectDir/libs/jni", "$projectDir/snapshot-build/build/ndk-build/libs"] + } + } +} diff --git a/data/abdoid-app-bundle/webpack.config.js b/data/abdoid-app-bundle/webpack.config.js new file mode 100644 index 00000000..d13248cb --- /dev/null +++ b/data/abdoid-app-bundle/webpack.config.js @@ -0,0 +1,259 @@ +const { join, relative, resolve, sep } = require("path"); + +const webpack = require("webpack"); +const nsWebpack = require("nativescript-dev-webpack"); +const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); +const CleanWebpackPlugin = require("clean-webpack-plugin"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); +const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); + +module.exports = env => { + // Add your custom Activities, Services and other android app components here. + const appComponents = [ + "tns-core-modules/ui/frame", + "tns-core-modules/ui/frame/activity", + ]; + + const platform = env && (env.android && "android" || env.ios && "ios"); + if (!platform) { + throw new Error("You need to provide a target platform!"); + } + + const platforms = ["ios", "android"]; + const projectRoot = __dirname; + + // Default destination inside platforms//... + const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); + const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; + + const { + // The 'appPath' and 'appResourcesPath' values are fetched from + // the nsconfig.json configuration file + // when bundling with `tns run android|ios --bundle`. + appPath = "app", + appResourcesPath = "app/App_Resources", + + // You can provide the following flags when running 'tns run android|ios' + snapshot, // --env.snapshot + uglify, // --env.uglify + report, // --env.report + sourceMap, // --env.sourceMap + hmr, // --env.hmr, + } = env; + const externals = (env.externals || []).map((e) => { // --env.externals + return new RegExp(e + ".*"); + }); + + const appFullPath = resolve(projectRoot, appPath); + const appResourcesFullPath = resolve(projectRoot, appResourcesPath); + + const entryModule = nsWebpack.getEntryModule(appFullPath); + const entryPath = `.${sep}${entryModule}.js`; + + const config = { + mode: uglify ? "production" : "development", + context: appFullPath, + externals, + watchOptions: { + ignored: [ + appResourcesFullPath, + // Don't watch hidden files + "**/.*", + ] + }, + target: nativescriptTarget, + entry: { + bundle: entryPath, + }, + output: { + pathinfo: false, + path: dist, + libraryTarget: "commonjs2", + filename: "[name].js", + globalObject: "global", + }, + resolve: { + extensions: [".js", ".scss", ".css"], + // Resolve {N} system modules from tns-core-modules + modules: [ + "node_modules/tns-core-modules", + "node_modules", + ], + alias: { + '~': appFullPath + }, + // don't resolve symlinks to symlinked modules + symlinks: false + }, + resolveLoader: { + // don't resolve symlinks to symlinked loaders + symlinks: false + }, + node: { + // Disable node shims that conflict with NativeScript + "http": false, + "timers": false, + "setImmediate": false, + "fs": "empty", + "__dirname": false, + }, + devtool: sourceMap ? "inline-source-map" : "none", + optimization: { + splitChunks: { + cacheGroups: { + vendor: { + name: "vendor", + chunks: "all", + test: (module, chunks) => { + const moduleName = module.nameForCondition ? module.nameForCondition() : ''; + return /[\\/]node_modules[\\/]/.test(moduleName) || + appComponents.some(comp => comp === moduleName); + + }, + enforce: true, + }, + } + }, + minimize: !!uglify, + minimizer: [ + new UglifyJsPlugin({ + parallel: true, + cache: true, + uglifyOptions: { + output: { + comments: false, + }, + compress: { + // The Android SBG has problems parsing the output + // when these options are enabled + 'collapse_vars': platform !== "android", + sequences: platform !== "android", + } + } + }) + ], + }, + module: { + rules: [ + { + test: new RegExp(entryPath), + use: [ + // Require all Android app components + platform === "android" && { + loader: "nativescript-dev-webpack/android-app-components-loader", + options: { modules: appComponents } + }, + + { + loader: "nativescript-dev-webpack/bundle-config-loader", + options: { + loadCss: !snapshot, // load the application css if in debug mode + } + }, + ].filter(loader => !!loader) + }, + + { + test: /-page\.js$/, + use: "nativescript-dev-webpack/script-hot-loader" + }, + + { + test: /\.(css|scss)$/, + use: "nativescript-dev-webpack/style-hot-loader" + }, + + { + test: /\.(html|xml)$/, + use: "nativescript-dev-webpack/markup-hot-loader" + }, + + { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"}, + + { + test: /\.css$/, + use: { loader: "css-loader", options: { minimize: false, url: false } } + }, + + { + test: /\.scss$/, + use: [ + { loader: "css-loader", options: { minimize: false, url: false } }, + "sass-loader" + ] + }, + ] + }, + plugins: [ + // Define useful constants like TNS_WEBPACK + new webpack.DefinePlugin({ + "global.TNS_WEBPACK": "true", + "process": undefined, + }), + // Remove all files from the out dir. + new CleanWebpackPlugin([ `${dist}/**/*` ]), + // Copy native app resources to out dir. + new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + }, + ]), + // Copy assets to out dir. Add your own globs as needed. + new CopyWebpackPlugin([ + { from: { glob: "fonts/**" } }, + { from: { glob: "**/*.jpg" } }, + { from: { glob: "**/*.png" } }, + ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), + // Generate a bundle starter script and activate it in package.json + new nsWebpack.GenerateBundleStarterPlugin([ + "./vendor", + "./bundle", + ]), + // For instructions on how to set up workers with webpack + // check out https://github.com/nativescript/worker-loader + new NativeScriptWorkerPlugin(), + new nsWebpack.PlatformFSPlugin({ + platform, + platforms, + }), + // Does IPC communication with the {N} CLI to notify events when running in watch mode. + new nsWebpack.WatchStateLoggerPlugin(), + ], + }; + + if (report) { + // Generate report files for bundles content + config.plugins.push(new BundleAnalyzerPlugin({ + analyzerMode: "static", + openAnalyzer: false, + generateStatsFile: true, + reportFilename: resolve(projectRoot, "report", `report.html`), + statsFilename: resolve(projectRoot, "report", `stats.json`), + })); + } + + if (snapshot) { + config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ + chunk: "vendor", + requireModules: [ + "tns-core-modules/bundle-entry-points", + ], + projectRoot, + webpackConfig: config, + targetArchs: ["arm", "arm64", "ia32"], + useLibs: true, + androidNdkPath: "$ANDROID_NDK_HOME" + })); + } + + if (hmr) { + config.plugins.push(new webpack.HotModuleReplacementPlugin()); + } + + + return config; +}; diff --git a/tests/build/android/build_android_tests.py b/tests/build/android/build_android_tests.py index c440c4bf..c4c0cf87 100644 --- a/tests/build/android/build_android_tests.py +++ b/tests/build/android/build_android_tests.py @@ -367,3 +367,42 @@ def test_451_resources_update(self): assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/java") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/res/values") Tns.build_android(attributes={"--path": self.app_name}) + + def test_455_build_android_app_bundle(self): + """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" + # This is required to ensure the app is in initial state + Folder.cleanup(self.app_name) + Tns.create_app(self.app_name) + path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") + + Tns.build_android(attributes={"--path": self.app_name, "--aab":""}) + assert "The build result is located at:" in output + assert path_to_aab in output + assert File.exists(path_to_aab) + + @unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.") + def test_456_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.""" + #The test will run only on mac because we need to set path to android ndk in webpack.config.js + # This is required to ensure the app is in initial state + Folder.cleanup(self.app_name) + Tns.create_app(self.app_name) + path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") + + #env.snapshot is applicable only in release build + Tns.build_android(attributes={"--path": self.app_name, + "--keyStorePath": ANDROID_KEYSTORE_PATH, + "--keyStorePassword": ANDROID_KEYSTORE_PASS, + "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, + "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, + "--release": "", + "--aab": "", + "--env.uglify": "", + "--env.snapshot": "", + "--bundle": "" + }) + assert "The build result is located at:" in output + assert path_to_aab in output + assert File.exists(path_to_aab) + From 913424c31530135d0e18b0baf666199a16b8c0af Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 15 Jan 2019 13:10:18 +0200 Subject: [PATCH 02/15] set configurations for snapshot --- tests/build/android/build_android_tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/build/android/build_android_tests.py b/tests/build/android/build_android_tests.py index c4c0cf87..da3979fc 100644 --- a/tests/build/android/build_android_tests.py +++ b/tests/build/android/build_android_tests.py @@ -390,6 +390,15 @@ def test_456_build_android_app_bundle_env_snapshot(self): Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") + #Configure app with snapshot optimisations + source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle') + target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' ) + File.copy(src=source, dest=target) + + source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js') + target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'webpack.config.js' ) + File.copy(src=source, dest=target) + #env.snapshot is applicable only in release build Tns.build_android(attributes={"--path": self.app_name, "--keyStorePath": ANDROID_KEYSTORE_PATH, From 8f4d0017cd040c1cd88a67adc0042083c389db6e Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Wed, 16 Jan 2019 15:21:19 +0200 Subject: [PATCH 03/15] extract app bundle tests to separate file --- .../build/android/android_app_bundle_tests.py | 84 +++++++++++++++++++ tests/build/android/build_android_tests.py | 50 +---------- 2 files changed, 85 insertions(+), 49 deletions(-) create mode 100644 tests/build/android/android_app_bundle_tests.py diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py new file mode 100644 index 00000000..6741de23 --- /dev/null +++ b/tests/build/android/android_app_bundle_tests.py @@ -0,0 +1,84 @@ +import urllib.request + +from core.settings.settings import SUT_FOLDER + +from core.base_class.BaseClass import BaseClass + + +class BuildAndroidTests(BaseClass): + + bundletool_path = os.path.join(SUT_FOLDER,"bundletool-all-0.8.0.jar") + + @classmethod + def setUpClass(cls): + BaseClass.setUpClass(cls.__name__) + + Tns.create_app(cls.app_name) + Tns.platform_add_android(attributes={"--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE}) + + #Download bundletool + url = 'https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar' + urllib.request.urlretrieve(url, SUT_FOLDER) + + @classmethod + def tearDownClass(cls): + BaseClass.tearDownClass() + + def setUp(self): + BaseClass.setUp(self) + + def tearDown(self): + BaseClass.tearDown(self) + Tns.kill() + + def test_001_build_android_app_bundle(self): + """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" + # This is required to ensure the app is in initial state + Folder.cleanup(self.app_name) + Tns.create_app(self.app_name) + path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") + + Tns.build_android(attributes={"--path": self.app_name, "--aab":""}) + assert "The build result is located at:" in output + assert path_to_aab in output + assert File.exists(path_to_aab) + + @unittest.skipIf(CURRENT_OS == OSType.WINDOWS, "Skip on Windows") + def test_002_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 is required to ensure the app is in initial state + Folder.cleanup(self.app_name) + Tns.create_app(self.app_name) + path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") + + #Configure app with snapshot optimisations + source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle') + target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' ) + File.copy(src=source, dest=target) + + source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js') + target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'webpack.config.js' ) + File.copy(src=source, dest=target) + + #env.snapshot is applicable only in release build + Tns.build_android(attributes={"--path": self.app_name, + "--keyStorePath": ANDROID_KEYSTORE_PATH, + "--keyStorePassword": ANDROID_KEYSTORE_PASS, + "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, + "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, + "--release": "", + "--aab": "", + "--env.uglify": "", + "--env.snapshot": "", + "--bundle": "" + }) + assert "The build result is located at:" in output + assert path_to_aab in output + assert File.exists(path_to_aab) + + #Verify app can be deployed on emulator via bundletool + + + diff --git a/tests/build/android/build_android_tests.py b/tests/build/android/build_android_tests.py index da3979fc..14c691d7 100644 --- a/tests/build/android/build_android_tests.py +++ b/tests/build/android/build_android_tests.py @@ -366,52 +366,4 @@ def test_451_resources_update(self): assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/assets") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/java") assert File.exists(self.app_name + "/app/App_Resources/Android/src/main/res/values") - Tns.build_android(attributes={"--path": self.app_name}) - - def test_455_build_android_app_bundle(self): - """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" - # This is required to ensure the app is in initial state - Folder.cleanup(self.app_name) - Tns.create_app(self.app_name) - path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") - - Tns.build_android(attributes={"--path": self.app_name, "--aab":""}) - assert "The build result is located at:" in output - assert path_to_aab in output - assert File.exists(path_to_aab) - - @unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.") - def test_456_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.""" - #The test will run only on mac because we need to set path to android ndk in webpack.config.js - # This is required to ensure the app is in initial state - Folder.cleanup(self.app_name) - Tns.create_app(self.app_name) - path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") - - #Configure app with snapshot optimisations - source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle') - target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' ) - File.copy(src=source, dest=target) - - source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js') - target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'webpack.config.js' ) - File.copy(src=source, dest=target) - - #env.snapshot is applicable only in release build - Tns.build_android(attributes={"--path": self.app_name, - "--keyStorePath": ANDROID_KEYSTORE_PATH, - "--keyStorePassword": ANDROID_KEYSTORE_PASS, - "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, - "--keyStoreAliasPassword": ANDROID_KEYSTORE_ALIAS_PASS, - "--release": "", - "--aab": "", - "--env.uglify": "", - "--env.snapshot": "", - "--bundle": "" - }) - assert "The build result is located at:" in output - assert path_to_aab in output - assert File.exists(path_to_aab) - + Tns.build_android(attributes={"--path": self.app_name}) \ No newline at end of file From f77f425906b407fbfc29cadda395101ae10459bc Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Fri, 18 Jan 2019 08:37:03 +0200 Subject: [PATCH 04/15] start emulator. Add bundletool commands --- .../build/android/android_app_bundle_tests.py | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 6741de23..ad7fa5b5 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -1,17 +1,23 @@ import urllib.request -from core.settings.settings import SUT_FOLDER +from core.settings.settings import SUT_FOLDER, EMULATOR_NAME, EMULATOR_ID from core.base_class.BaseClass import BaseClass +from core.osutils.command import run -class BuildAndroidTests(BaseClass): +from core.osutils.command_log_level import CommandLogLevel + + +class AndroidAppBundleTests(BaseClass): bundletool_path = os.path.join(SUT_FOLDER,"bundletool-all-0.8.0.jar") @classmethod def setUpClass(cls): BaseClass.setUpClass(cls.__name__) + Emulator.stop() + Emulator.ensure_available() Tns.create_app(cls.app_name) Tns.platform_add_android(attributes={"--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE}) @@ -62,6 +68,8 @@ def test_002_build_android_app_bundle_env_snapshot(self): target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'webpack.config.js' ) File.copy(src=source, dest=target) + + #env.snapshot is applicable only in release build Tns.build_android(attributes={"--path": self.app_name, "--keyStorePath": ANDROID_KEYSTORE_PATH, @@ -79,6 +87,27 @@ def test_002_build_android_app_bundle_env_snapshot(self): assert File.exists(path_to_aab) #Verify app can be deployed on emulator via bundletool + # Use bundletool to create the .apks file + path_to_apks = os.path.join(self.app_name,'app.apks') + build_command = 'java -jar ' + bundletool_path + ' build-apks --bundle=' + path_to_aab + / + ' --output=' path_to_apks + ' --ks=' + ANDROID_KEYSTORE_PATH + / + ' --ks-pass=' + keyStorePassword + ' --ks-key-alias=' + keyStoreAlias + keyStoreAlias + / + ' --key-pass=' + keyStoreAliasPassword + log = run(build_command, timeout=timeout, wait=False, log_level=CommandLogLevel.FULL) + assert not "error" in output, "create of .apks file failed" + + # deploy on device + deploy_command = 'java -jar ' + bundletool_path + ' install-apks --apks=' + path_to_apks + command = 'java -jar ' + bundletool_path + ' build-apks --bundle=' + path_to_aab + / + ' --output=' path_to_apks + ' --ks=' + ANDROID_KEYSTORE_PATH + / + ' --ks-pass=' + keyStorePassword + ' --ks-key-alias=' + keyStoreAlias + keyStoreAlias + / + ' --key-pass=' + keyStoreAliasPassword + log = run(deploy_command, timeout=timeout, wait=False, log_level=CommandLogLevel.FULL) + assert not "error" in output, "deploy of app failed" + + # Verify app looks correct inside emulator + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') From 99ef65d4b489dedd13a3160b7b4f338ecd653fdc Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Fri, 18 Jan 2019 15:29:00 +0200 Subject: [PATCH 05/15] extract bundletool build and deploy to methods. Verify app is started on device --- runNose.py | 62 ++++++------ .../build/android/android_app_bundle_tests.py | 98 +++++++++++++------ 2 files changed, 100 insertions(+), 60 deletions(-) diff --git a/runNose.py b/runNose.py index 7ce2096e..a4cc7b6e 100644 --- a/runNose.py +++ b/runNose.py @@ -63,40 +63,40 @@ def get_repos(): if __name__ == '__main__': - # Cleanup files and folders created by the test execution - Folder.cleanup(OUTPUT_FOLDER) - Folder.create(OUTPUT_FOLDER) - Folder.cleanup(SUT_FOLDER) - Folder.cleanup("node_modules") - Npm.cache_clean() - Gradle.kill() - Gradle.cache_clean() - get_repos() - Emulator.stop() # Stop running emulators - - # Copy test packages and cleanup - if CURRENT_OS == OSType.OSX: - Simulator.stop() - disable_crash_report() - get_test_packages(platform=Platform.BOTH) - Simulator.reset() - - if Xcode.get_version() < 10: - SIMULATOR_SDK = '11.0' - if Xcode.get_version() < 9: - SIMULATOR_SDK = '10.0' + # # Cleanup files and folders created by the test execution + # Folder.cleanup(OUTPUT_FOLDER) + # Folder.create(OUTPUT_FOLDER) + # Folder.cleanup(SUT_FOLDER) + # Folder.cleanup("node_modules") + # Npm.cache_clean() + # Gradle.kill() + # Gradle.cache_clean() + # get_repos() + # Emulator.stop() # Stop running emulators + + # # Copy test packages and cleanup + # if CURRENT_OS == OSType.OSX: + # Simulator.stop() + # disable_crash_report() + # get_test_packages(platform=Platform.BOTH) + # Simulator.reset() + + # if Xcode.get_version() < 10: + # SIMULATOR_SDK = '11.0' + # if Xcode.get_version() < 9: + # SIMULATOR_SDK = '10.0' - Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK) - Xcode.cleanup_cache() # Clean Xcode cache folders - Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) - Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS) - else: - get_test_packages(platform=Platform.ANDROID) + # Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK) + # Xcode.cleanup_cache() # Clean Xcode cache folders + # Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) + # Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS) + # else: + # get_test_packages(platform=Platform.ANDROID) - # Install CLI - Cli.install() - Tns.disable_reporting() + # # Install CLI + # Cli.install() + # Tns.disable_reporting() # Add local CLI to PATH if CURRENT_OS != OSType.WINDOWS: diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index ad7fa5b5..6240cd04 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -1,17 +1,34 @@ -import urllib.request +import os -from core.settings.settings import SUT_FOLDER, EMULATOR_NAME, EMULATOR_ID +import urllib + +import unittest + +from core.settings.settings import SUT_FOLDER, EMULATOR_NAME, EMULATOR_ID, \ + ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_PATH,\ + ANDROID_KEYSTORE_ALIAS_PASS, CURRENT_OS, OSType, ANDROID_PACKAGE + +from core.device.helpers.adb import Adb from core.base_class.BaseClass import BaseClass +from core.osutils.file import File + +from core.device.device import Device + +from core.osutils.folder import Folder + from core.osutils.command import run from core.osutils.command_log_level import CommandLogLevel +from core.device.emulator import Emulator, EMULATOR_ID, EMULATOR_NAME +from core.tns.tns import Tns class AndroidAppBundleTests(BaseClass): - bundletool_path = os.path.join(SUT_FOLDER,"bundletool-all-0.8.0.jar") + bundletool_path = os.path.join(SUT_FOLDER,"bundletool.jar") + path_to_apks = os.path.join(BaseClass.app_name,'app.apks') @classmethod def setUpClass(cls): @@ -19,12 +36,12 @@ def setUpClass(cls): Emulator.stop() Emulator.ensure_available() - Tns.create_app(cls.app_name) - Tns.platform_add_android(attributes={"--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE}) + Tns.create_app(BaseClass.app_name) + Tns.platform_add_android(attributes={"--path": BaseClass.app_name, "--frameworkPath": ANDROID_PACKAGE}) #Download bundletool url = 'https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar' - urllib.request.urlretrieve(url, SUT_FOLDER) + urllib.urlretrieve(url, os.path.join(SUT_FOLDER, 'bundletool.jar')) @classmethod def tearDownClass(cls): @@ -37,6 +54,20 @@ def tearDown(self): BaseClass.tearDown(self) Tns.kill() + @staticmethod + def bundletool_build(bundletool_path, path_to_aab, path_to_apks): + build_command = ('java -jar {0} build-apks --bundle="{1}" --output="{2}" --ks="{3}" --ks-pass=pass:"{4}" --ks-key-alias="{5}"' \ + ' --key-pass=pass:"{6}"').format(bundletool_path, path_to_aab, path_to_apks, ANDROID_KEYSTORE_PATH, + ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS) + output = run(build_command, log_level=CommandLogLevel.FULL) + assert not "Error" in output, "create of .apks file failed" + + @staticmethod + def bundletool_deploy(bundletool_path, path_to_apks): + deploy_command = ('java -jar {0} install-apks --apks="{1}"').format(bundletool_path, path_to_apks) + output = run(deploy_command, log_level=CommandLogLevel.FULL) + assert not "Error" in output, "deploy of app failed" + def test_001_build_android_app_bundle(self): """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" # This is required to ensure the app is in initial state @@ -44,11 +75,26 @@ def test_001_build_android_app_bundle(self): Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") - Tns.build_android(attributes={"--path": self.app_name, "--aab":""}) + output = Tns.build_android(attributes={"--path": self.app_name, "--aab":""}, assert_success=False) assert "The build result is located at:" in output assert path_to_aab in 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) + + # Start the ap on device + Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") + + # Verify app looks correct inside emulator + app_started = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP') + assert app_started, 'App is not started on device' + @unittest.skipIf(CURRENT_OS == OSType.WINDOWS, "Skip on Windows") def test_002_build_android_app_bundle_env_snapshot(self): """Build app with android app bundle option with --bundle and optimisations for snapshot. @@ -58,20 +104,20 @@ def test_002_build_android_app_bundle_env_snapshot(self): Folder.cleanup(self.app_name) Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") - + #Configure app with snapshot optimisations source = os.path.join('data', 'abdoid-app-bundle', 'app.gradle') target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'app.gradle' ) File.copy(src=source, dest=target) source = os.path.join('data', 'abdoid-app-bundle', 'webpack.config.js') - target = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'webpack.config.js' ) + target = os.path.join(self.app_name, 'webpack.config.js' ) File.copy(src=source, dest=target) #env.snapshot is applicable only in release build - Tns.build_android(attributes={"--path": self.app_name, + output = Tns.build_android(attributes={"--path": self.app_name, "--keyStorePath": ANDROID_KEYSTORE_PATH, "--keyStorePassword": ANDROID_KEYSTORE_PASS, "--keyStoreAlias": ANDROID_KEYSTORE_ALIAS, @@ -81,33 +127,27 @@ def test_002_build_android_app_bundle_env_snapshot(self): "--env.uglify": "", "--env.snapshot": "", "--bundle": "" - }) + }, assert_success=False) assert "The build result is located at:" in output assert path_to_aab in output assert File.exists(path_to_aab) #Verify app can be deployed on emulator via bundletool # Use bundletool to create the .apks file - path_to_apks = os.path.join(self.app_name,'app.apks') - build_command = 'java -jar ' + bundletool_path + ' build-apks --bundle=' + path_to_aab + / - ' --output=' path_to_apks + ' --ks=' + ANDROID_KEYSTORE_PATH + / - ' --ks-pass=' + keyStorePassword + ' --ks-key-alias=' + keyStoreAlias + keyStoreAlias + / - ' --key-pass=' + keyStoreAliasPassword - log = run(build_command, timeout=timeout, wait=False, log_level=CommandLogLevel.FULL) - assert not "error" in output, "create of .apks file failed" - - # deploy on device - deploy_command = 'java -jar ' + bundletool_path + ' install-apks --apks=' + path_to_apks - command = 'java -jar ' + bundletool_path + ' build-apks --bundle=' + path_to_aab + / - ' --output=' path_to_apks + ' --ks=' + ANDROID_KEYSTORE_PATH + / - ' --ks-pass=' + keyStorePassword + ' --ks-key-alias=' + keyStoreAlias + keyStoreAlias + / - ' --key-pass=' + keyStoreAliasPassword - log = run(deploy_command, timeout=timeout, wait=False, log_level=CommandLogLevel.FULL) - assert not "error" in output, "deploy of app failed" + + 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) + + # Start the ap on device + Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') + app_started = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP') + assert app_started, 'App is not started on device' From 0b48bdae3c90016308975d5b5b8a4d33b1ecf50e Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Fri, 18 Jan 2019 15:33:28 +0200 Subject: [PATCH 06/15] Edit help --- tests/build/android/android_app_bundle_tests.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 6240cd04..0ce4300c 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -70,7 +70,7 @@ def bundletool_deploy(bundletool_path, path_to_apks): def test_001_build_android_app_bundle(self): """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" - # This is required to ensure the app is in initial state + # Ensure the app is in initial state Folder.cleanup(self.app_name) Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") @@ -88,7 +88,7 @@ def test_001_build_android_app_bundle(self): # Deploy on device self.bundletool_deploy(self.bundletool_path, self.path_to_apks) - # Start the ap on device + # Start the app on device Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") # Verify app looks correct inside emulator @@ -99,8 +99,9 @@ def test_001_build_android_app_bundle(self): def test_002_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 wil not run on windows because env.snapshot option is not available on that OS - # This is required to ensure the app is in initial state + # Ensure the app is in initial state Folder.cleanup(self.app_name) Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") @@ -114,8 +115,6 @@ def test_002_build_android_app_bundle_env_snapshot(self): target = os.path.join(self.app_name, 'webpack.config.js' ) File.copy(src=source, dest=target) - - #env.snapshot is applicable only in release build output = Tns.build_android(attributes={"--path": self.app_name, "--keyStorePath": ANDROID_KEYSTORE_PATH, @@ -134,15 +133,13 @@ def test_002_build_android_app_bundle_env_snapshot(self): #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) - # Start the ap on device + # Start the app on device Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") # Verify app looks correct inside emulator From 2961085b1673447e2791cd364c501ac1f2b59539 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Fri, 18 Jan 2019 17:05:15 +0200 Subject: [PATCH 07/15] ensure app is in initial state on every run --- tests/build/android/android_app_bundle_tests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 0ce4300c..7991b347 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -6,7 +6,7 @@ from core.settings.settings import SUT_FOLDER, EMULATOR_NAME, EMULATOR_ID, \ ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_PATH,\ - ANDROID_KEYSTORE_ALIAS_PASS, CURRENT_OS, OSType, ANDROID_PACKAGE + ANDROID_KEYSTORE_ALIAS_PASS, CURRENT_OS, OSType, ANDROID_PACKAGE, TEST_RUN_HOME from core.device.helpers.adb import Adb @@ -38,6 +38,7 @@ def setUpClass(cls): Tns.create_app(BaseClass.app_name) Tns.platform_add_android(attributes={"--path": BaseClass.app_name, "--frameworkPath": ANDROID_PACKAGE}) + Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp") #Download bundletool url = 'https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar' @@ -46,9 +47,14 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): BaseClass.tearDownClass() + Folder.cleanup(TEST_RUN_HOME + "/data/TestApp") def setUp(self): BaseClass.setUp(self) + # Ensure app is in initial state + Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) + Folder.cleanup(self.app_name) + Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp") def tearDown(self): BaseClass.tearDown(self) @@ -70,9 +76,6 @@ def bundletool_deploy(bundletool_path, path_to_apks): def test_001_build_android_app_bundle(self): """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" - # Ensure the app is in initial state - Folder.cleanup(self.app_name) - Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "debug", "app.aab") output = Tns.build_android(attributes={"--path": self.app_name, "--aab":""}, assert_success=False) @@ -99,11 +102,8 @@ def test_001_build_android_app_bundle(self): def test_002_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 wil not run on windows because env.snapshot option is not available on that OS + # This test will not run on windows because env.snapshot option is not available on that OS - # Ensure the app is in initial state - Folder.cleanup(self.app_name) - Tns.create_app(self.app_name) path_to_aab = os.path.join(self.app_name, "platforms", "android", "app", "build", "outputs", "bundle", "release", "app.aab") #Configure app with snapshot optimisations From 1591d86606e25136ed99b3123c8d8e866f4532d7 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Mon, 21 Jan 2019 15:22:30 +0200 Subject: [PATCH 08/15] fix commented lines --- runNose.py | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/runNose.py b/runNose.py index a4cc7b6e..7ce2096e 100644 --- a/runNose.py +++ b/runNose.py @@ -63,40 +63,40 @@ def get_repos(): if __name__ == '__main__': - # # Cleanup files and folders created by the test execution - # Folder.cleanup(OUTPUT_FOLDER) - # Folder.create(OUTPUT_FOLDER) - # Folder.cleanup(SUT_FOLDER) - # Folder.cleanup("node_modules") - # Npm.cache_clean() - # Gradle.kill() - # Gradle.cache_clean() - # get_repos() - # Emulator.stop() # Stop running emulators - - # # Copy test packages and cleanup - # if CURRENT_OS == OSType.OSX: - # Simulator.stop() - # disable_crash_report() - # get_test_packages(platform=Platform.BOTH) - # Simulator.reset() - - # if Xcode.get_version() < 10: - # SIMULATOR_SDK = '11.0' - # if Xcode.get_version() < 9: - # SIMULATOR_SDK = '10.0' + # Cleanup files and folders created by the test execution + Folder.cleanup(OUTPUT_FOLDER) + Folder.create(OUTPUT_FOLDER) + Folder.cleanup(SUT_FOLDER) + Folder.cleanup("node_modules") + Npm.cache_clean() + Gradle.kill() + Gradle.cache_clean() + get_repos() + Emulator.stop() # Stop running emulators + + # Copy test packages and cleanup + if CURRENT_OS == OSType.OSX: + Simulator.stop() + disable_crash_report() + get_test_packages(platform=Platform.BOTH) + Simulator.reset() + + if Xcode.get_version() < 10: + SIMULATOR_SDK = '11.0' + if Xcode.get_version() < 9: + SIMULATOR_SDK = '10.0' - # Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK) - # Xcode.cleanup_cache() # Clean Xcode cache folders - # Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) - # Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS) - # else: - # get_test_packages(platform=Platform.ANDROID) + Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK) + Xcode.cleanup_cache() # Clean Xcode cache folders + Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) + Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS) + else: + get_test_packages(platform=Platform.ANDROID) - # # Install CLI - # Cli.install() - # Tns.disable_reporting() + # Install CLI + Cli.install() + Tns.disable_reporting() # Add local CLI to PATH if CURRENT_OS != OSType.WINDOWS: From d8650697f126aef9f62c9e797cdd307679da6d00 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 10:20:44 +0200 Subject: [PATCH 09/15] META --- core/osutils/file.py | 10 ++++++++++ tests/build/android/android_app_bundle_tests.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/osutils/file.py b/core/osutils/file.py index ba2e23e8..50a5dcef 100644 --- a/core/osutils/file.py +++ b/core/osutils/file.py @@ -7,6 +7,7 @@ import shutil import time import tarfile +import zipfile from core.osutils.os_type import OSType from core.osutils.process import Process @@ -193,3 +194,12 @@ def unpack_tar(file_path, dest_dir): tarFile.extractall(dest_dir) except: print "Failed to unpack .tar file {0}".format(file_path) + + @staticmethod + def unzip(file_path, dest_dir): + try: + zipFile = zipfile.ZipFile(file_path, 'r') + zipFile.extractall(dest_dir) + zipfile.close() + except: + print "Failed to unzip file {0}".format(file_path) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 7991b347..10537e15 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -69,10 +69,11 @@ def bundletool_build(bundletool_path, path_to_aab, path_to_apks): assert not "Error" in output, "create of .apks file failed" @staticmethod - def bundletool_deploy(bundletool_path, path_to_apks): - deploy_command = ('java -jar {0} install-apks --apks="{1}"').format(bundletool_path, path_to_apks) + def bundletool_deploy(bundletool_path, path_to_apks, device_id): + deploy_command = ('java -jar {0} install-apks --apks="{1}" --device-id={2}').format(bundletool_path, path_to_apks, EMULATOR_ID) output = run(deploy_command, log_level=CommandLogLevel.FULL) assert not "Error" in output, "deploy of app failed" + assert "The APKs have been extracted in the directory:" in output, "deploy of app failed" def test_001_build_android_app_bundle(self): """Build app with android app bundle option. Verify the output(app.aab) and use bundletool to deploy on device""" @@ -136,6 +137,11 @@ def test_002_build_android_app_bundle_env_snapshot(self): 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, 'apks') + File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), '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) From 6cf1799d641d12291132ddc0182140568bb9fdce Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 10:25:23 +0200 Subject: [PATCH 10/15] Add verification for .so file. Add device id on deploy. --- tests/build/android/android_app_bundle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 10537e15..87b9d415 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -143,7 +143,7 @@ def test_002_build_android_app_bundle_env_snapshot(self): 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) + self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=EMULATOR_ID) # Start the app on device Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") From 0dfcd9cfc95fd8c0a9735e5d9e6b070c708fb3e4 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 10:30:51 +0200 Subject: [PATCH 11/15] fix error --- tests/build/android/android_app_bundle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 87b9d415..c29c04d9 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -140,7 +140,7 @@ def test_002_build_android_app_bundle_env_snapshot(self): # Verify that the correct .so file is included in the package File.unzip(self.path_to_apks, 'apks') File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), 'base_apk') - assert File.exists(os.path.join(self.app_name, ,'base_apk', 'lib', 'x86'), 'libNativeScript.so') + 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=EMULATOR_ID) From da53a6ba395a4e079e174fe8207b9224a2edc93c Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 11:13:50 +0200 Subject: [PATCH 12/15] fix deploy --- tests/build/android/android_app_bundle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index c29c04d9..5a9a6e59 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -90,7 +90,7 @@ def test_001_build_android_app_bundle(self): assert File.exists(self.path_to_apks) # Deploy on device - self.bundletool_deploy(self.bundletool_path, self.path_to_apks) + self.bundletool_deploy(self.bundletool_path, self.path_to_apks, device_id=EMULATOR_ID) # Start the app on device Adb.start_app(EMULATOR_ID, "org.nativescript.TestApp") From 4f5bad5cf7afe08c4aff77aa2603a7537ba904c0 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 11:22:16 +0200 Subject: [PATCH 13/15] fix file exists assert --- tests/build/android/android_app_bundle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index 5a9a6e59..b5e0948d 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -140,7 +140,7 @@ def test_002_build_android_app_bundle_env_snapshot(self): # Verify that the correct .so file is included in the package File.unzip(self.path_to_apks, 'apks') File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), 'base_apk') - assert File.exists(os.path.join(self.app_name, 'base_apk', 'lib', 'x86'), 'libNativeScript.so') + 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=EMULATOR_ID) From cee652cc9b63c4669ef5814ca77bccc46ab096e8 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 13:26:47 +0200 Subject: [PATCH 14/15] fix unzip file method --- core/osutils/file.py | 2 +- tests/build/android/android_app_bundle_tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/osutils/file.py b/core/osutils/file.py index 50a5dcef..01aa75e8 100644 --- a/core/osutils/file.py +++ b/core/osutils/file.py @@ -200,6 +200,6 @@ def unzip(file_path, dest_dir): try: zipFile = zipfile.ZipFile(file_path, 'r') zipFile.extractall(dest_dir) - zipfile.close() + zipFile.close() except: print "Failed to unzip file {0}".format(file_path) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index b5e0948d..a894a7ee 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -138,8 +138,8 @@ def test_002_build_android_app_bundle_env_snapshot(self): assert File.exists(self.path_to_apks) # Verify that the correct .so file is included in the package - File.unzip(self.path_to_apks, 'apks') - File.unzip(os.path.join(self.app_name, 'apks', 'splits', 'base-x86.apk'), 'base_apk') + 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 From ec1f19b74f3585625f177776f52c8e51e0803ec4 Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 22 Jan 2019 13:38:07 +0200 Subject: [PATCH 15/15] fix error --- tests/build/android/android_app_bundle_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build/android/android_app_bundle_tests.py b/tests/build/android/android_app_bundle_tests.py index a894a7ee..8949d6c7 100644 --- a/tests/build/android/android_app_bundle_tests.py +++ b/tests/build/android/android_app_bundle_tests.py @@ -138,7 +138,7 @@ def test_002_build_android_app_bundle_env_snapshot(self): 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(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'))