def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self): """ App should not crash when reference .jar or/and .aar file in App_Resources/Android/libs https://github.com/NativeScript/android-runtime/issues/899 """ # Create libs/ in app/App_resources/, add .jar and .aar files in it and modify the app to reference them curr_folder = os.getcwd() Folder.navigate_to(os.path.join(self.app_name, 'app', 'App_Resources', 'Android')) Folder.create("libs") app_res_libs = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'libs') Folder.navigate_to(curr_folder) custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar') custom_aar_file = os.path.join('data', 'issues', 'android-runtime-899', 'mylibrary.aar') File.copy(src=custom_jar_file, dest=app_res_libs) File.copy(src=custom_aar_file, dest=app_res_libs) source = os.path.join('data', 'issues', 'android-runtime-899', 'app.js') target = os.path.join(self.app_name, 'app', 'app.js') File.copy(src=source, dest=target) # `tns run android` and wait until app is deployed log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False, assert_success=False) strings = ['Project successfully built', 'Successfully installed on device with identifier', EMULATOR_ID, 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image='livesync-hello-world_home')
def __run_yarn_command(command, folder=None, log_level=CommandLogLevel.FULL): if folder is not None: Folder.navigate_to(folder=folder, relative_from_current_folder=True) output = run('yarn {0}'.format(command), log_level=log_level) if folder is not None: Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) return output
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 test_200_build_android_inside_project_folder(self): Folder.navigate_to(self.app_name) output = Tns.build_android(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name}, assert_success=False, log_trace=True) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) assert successfully_prepared in output assert build_successful in output assert successfully_built in output assert File.exists(os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk))
def pack(folder, output_file): try: Folder.navigate_to(folder) run('npm pack', log_level=CommandLogLevel.SILENT) src_file = File.find_by_extension('tgz')[0] File.copy(src=src_file, dest=output_file) File.remove(src_file) except: print 'Failed to pack {0}'.format(folder) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)
def test_120_platform_add_android_inside_project(self): """ Add platform inside project folder (not using --path)""" Folder.navigate_to(self.app_name) output = Tns.platform_add_android(tns_path=os.path.join( "..", TNS_PATH), assert_success=False) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) TnsAsserts.platform_added(self.app_name, platform=Platform.ANDROID, output=output)
def test_210_platform_not_need_remove_after_bitcode_error(self): # https://github.com/NativeScript/nativescript-cli/issues/3741 Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) Folder.navigate_to(self.app_name + "/app") path = os.path.join(self.app_name + "/app") run("touch a") run("ln -s a b") run("rm a") Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) output = Tns.prepare_android(attributes={"--path": self.app_name}) assert "Project successfully prepared" in output
def test_200_build_ios_inside_project(self): Folder.navigate_to(self.app_name) output = Tns.build_ios(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name}, assert_success=False, log_trace=True) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) assert "build/Debug-iphonesimulator/TestApp.app" in output assert File.exists( self.app_name + "/platforms/ios/build/Debug-iphonesimulator/TestApp.app")
def install_npm(package='', option='', folder=None, log_level=CommandLogLevel.FULL): cmd = UPDATE_WEBPACK_PATH + " --configs --deps" Npm.install(package=package, option=option, folder=folder, log_level=log_level) if folder is not None: Folder.navigate_to(folder=folder, relative_from_current_folder=True) print cmd output = run(command=cmd) if folder is not None: Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) return output
def test_200_build_android_inside_project_folder(self): Folder.navigate_to(self.app_name) output = Tns.build_android(tns_path=os.path.join("..", TNS_PATH), attributes={"--path": self.app_name}, assert_success=False, log_trace=True) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) assert successfully_prepared in output assert build_successful in output assert successfully_built in output assert File.exists( os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APK_DEBUG_PATH, self.debug_apk))
def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self): """ App should not crash when reference .jar or/and .aar file in App_Resources/Android/libs https://github.com/NativeScript/android-runtime/issues/899 """ # Create libs/ in app/App_resources/, add .jar and .aar files in it and modify the app to reference them curr_folder = os.getcwd() Folder.navigate_to( os.path.join(self.app_name, 'app', 'App_Resources', 'Android')) Folder.create("libs") app_res_libs = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'libs') Folder.navigate_to(curr_folder) custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar') custom_aar_file = os.path.join('data', 'issues', 'android-runtime-899', 'mylibrary.aar') File.copy(src=custom_jar_file, dest=app_res_libs) File.copy(src=custom_aar_file, dest=app_res_libs) source = os.path.join('data', 'issues', 'android-runtime-899', 'app.js') target = os.path.join(self.app_name, 'app', 'app.js') File.copy(src=source, dest=target) # `tns run android` and wait until app is deployed log = Tns.run_android(attributes={ '--path': self.app_name, '--device': EMULATOR_ID }, wait=False, assert_success=False) strings = [ 'Project successfully built', 'Successfully installed on device with identifier', EMULATOR_ID, 'Successfully synced application' ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image='livesync-hello-world_home')
def test_320_prepare_scoped_plugins(self): """ Test for https://github.com/NativeScript/nativescript-cli/pull/3080 Before this change we copied all NG components at following location (js demo of nativescript-facebook): platforms/android/src/main/assets/app/tns_modules/nativescript-facebook/node_modules/@angular Now folder above should be empty (or not existing at all). """ Folder.cleanup("nativescript-facebook") Git.clone_repo(repo_url='[email protected]:NativeScript/nativescript-facebook.git', local_folder="nativescript-facebook") Folder.navigate_to(folder="nativescript-facebook/src") output = run(command="npm run build") Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) assert "tsc" in output assert "ERR" not in output Tns.prepare_android(attributes={"--path": "nativescript-facebook/demo"}) output = run(command="find nativescript-facebook/demo/platforms/android/ | grep @") assert "@angular/core" not in output, "@angular/* should not be in platforms folder." assert "@angular/router" not in output, "@angular/* should not be in platforms folder."
def test_102_prepare_android_inside_project(self): Folder.navigate_to(self.app_name) output = Tns.prepare_android(tns_path=os.path.join("..", TNS_PATH), assert_success=False) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FULL)
def test_120_platform_add_android_inside_project(self): """ Add platform inside project folder (not using --path)""" Folder.navigate_to(self.app_name) output = Tns.platform_add_android(tns_path=os.path.join("..", TNS_PATH), assert_success=False) Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False) TnsAsserts.platform_added(self.app_name, platform=Platform.ANDROID, output=output)