def test_301_prepare_android_platform_specific_files(self): Tns.prepare_android(attributes={"--path": self.app_name}) # Add set of platform specific files File.copy(self.app_name + "/app/app.js", self.app_name + "/app/app.ios.js") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/app.android.js") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appios.js") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appandroid.js") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/ios.js") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/android.js") File.copy(self.app_name + "/app/app.css", self.app_name + "/app/app.ios.css") File.copy(self.app_name + "/app/app.css", self.app_name + "/app/app.android.css") File.copy(self.app_name + "/app/app.js", self.app_name + "/app/appNew.js") File.copy(self.app_name + "/app/app.css", self.app_name + "/app/appNew.css") File.remove(self.app_name + "/app/app.js") File.remove(self.app_name + "/app/app.css") Tns.prepare_android(attributes={"--path": self.app_name}) # Verify new files are in available in platforms folder app_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH) assert File.exists(os.path.join(app_path, 'app.css')) assert File.exists(os.path.join(app_path, 'app.js')) assert File.exists(os.path.join(app_path, 'appandroid.js')) assert File.exists(os.path.join(app_path, 'appios.js')) assert File.exists(os.path.join(app_path, 'android.js')) assert File.exists(os.path.join(app_path, 'ios.js')) assert not File.exists(os.path.join(app_path, 'app.ios.css')) assert not File.exists(os.path.join(app_path, 'app.android.css'))
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.create_app_ng(cls.app_name) Tns.platform_add_android(attributes={ "--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE })
def test_300_tns_run_ios_emulator_should_start_emulator_even_if_device_is_connected(self): """ `tns run ios --emulator` should start emulator even if physical device is connected """ Simulator.stop() Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': ''}, assert_success=False) assert Simulator.wait_for_simulator()[0], 'iOS Simulator not started by `tns run ios`!'
def setUpClass(cls, class_name): print "" print "_________________________________CLASS START_______________________________________" print "Class Name: {0}".format(class_name) print "Start Time: {0}".format(time.strftime("%X")) print "" Tns.kill() Gradle.kill() Process.kill('node') Process.kill('adb') if CURRENT_OS == OSType.OSX: Process.kill('NativeScript Inspector') Process.kill('Safari') Process.kill('Xcode') if class_name is not None: logfile = os.path.join('out', class_name + '.txt') else: logfile = os.path.join(OUTPUT_FOLDER, cls.__name__ + ".txt") File.remove(logfile) sys.stdout = sys.stderr = Logger.Logger(logfile) Folder.cleanup(cls.app_name)
def test_181_tns_run_android_console_dir(self): """ Test console.dir() of different objects. """ # Change main-page.js so it contains console logging source_js = os.path.join('data', 'console-dir', 'main-page.js') target_js = os.path.join(self.app_name, 'app', 'main-page.js') File.copy(src=source_js, dest=target_js) 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', "true", "false", "null", "undefined", "-1", "text", "==== object dump start ====", "name: \"John\"", "age: \"34\"", "==== object dump end ====", self.max_long_string ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) assert self.very_long_string not in log
def test_200_tns_run_android_extending_class_inside_file_containing_dots(self): """Test for https://github.com/NativeScript/android-runtime/issues/761""" # Copy the app folder (app is modified in order to get some console logs on loaded) source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src') target = os.path.join(self.app_name, 'src') Folder.cleanup(target) Folder.copy(src=source, dst=target) source_html = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.html') target_html = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.html') File.copy(src=source_html, dest=target_html) source_ts = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.ts') target_ts = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.ts') File.copy(src=source_ts, dest=target_ts) source_xml = os.path.join('data', 'issues', 'android-runtime-761', 'AndroidManifest.xml') target_xml = os.path.join(self.app_name, 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') File.copy(src=source_xml, dest=target_xml) # Verify the app is running 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)
def test_280_tns_run_android_console_time(self): # Copy the app folder (app is modified in order to get some console logs on loaded) source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src') target = os.path.join(self.app_name, 'src') Folder.cleanup(target) Folder.copy(src=source, dst=target) # Replace app.component.ts to use console.time() and console.timeEnd() source = os.path.join('data', 'issues', 'ios-runtime-843', 'app.component.ts') target = os.path.join(self.app_name, 'src', 'app', 'app.component.ts') 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) # Verify the app is running strings = ['Successfully synced application', 'Application loaded!', 'Home page loaded!'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False) # Verify initial state of the app Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image='ng-hello-world-home-white', tolerance=5.0) # Verify console.time() works console_time = ['JS: startup:'] Tns.wait_for_log(log_file=log, string_list=console_time)
def test_200_prepare_additional_appresources(self): # prepare project output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.FULL) # Create new files in AppResources File.copy( self.app_name + "/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png", self.app_name + "/app/App_Resources/iOS/newDefault.png") # prepare project output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.INCREMENTAL) # Verify XCode Project include files from App Resources folder output = run( "cat " + self.app_name + "/platforms/ios/TestApp.xcodeproj/project.pbxproj | grep newDefault.png" ) assert "newDefault.png" in output
def test_400_prepare_missing_or_missing_platform(self): Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) output = Tns.run_tns_command("prepare", attributes={"--path": self.app_name}) assert "No platform specified." in output output = Tns.run_tns_command("prepare windows", attributes={"--path": self.app_name}) assert "Invalid platform windows. Valid platforms are ios or android." in output
def test_451_resources_update(self): target_app = os.path.join(TEST_RUN_HOME, BaseClass.app_name) source_app = os.path.join(TEST_RUN_HOME, 'data', 'apps', 'test-app-js-41') Folder.cleanup(target_app) Folder.copy(source_app, target_app) output = Tns.run_tns_command("resources update", attributes={"--path": self.app_name}) assert "Successfully updated your project's application resources '/Android' directory structure" in output assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in output assert File.exists(self.app_name + "/app/App_Resources/Android-Pre-v4/app.gradle") assert File.exists(self.app_name + "/app/App_Resources/Android/app.gradle") assert File.exists( self.app_name + "/app/App_Resources/Android/src/main/AndroidManifest.xml") 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_181_tns_run_android_console_dir(self): """ Test console.dir() of different objects. """ # Change main-page.js so it contains console logging source_js = os.path.join('data', 'console-dir', 'main-page.js') target_js = os.path.join(self.app_name, 'app', 'main-page.js') File.copy(src=source_js, dest=target_js) 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', "true", "false", "null", "undefined", "-1", "text", "==== object dump start ====", "name: \"John\"", "age: \"34\"", "==== object dump end ====", self.max_long_string ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) assert self.very_long_string not in log
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_360_tns_run_android_with_jar_file_in_plugin(self): """ App should not crash when reference .jar file in some plugin https://github.com/NativeScript/android-runtime/pull/905 """ # Add .jar file in plugin and modify the app to reference it custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar') modules_widgets = os.path.join(self.app_name, 'node_modules', 'tns-core-modules-widgets', 'platforms', 'android') File.copy(src=custom_jar_file, dest=modules_widgets) source = os.path.join('data', 'issues', 'android-runtime-pr-905', '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_002_android_run_hmr_uninstall_app(self): log = Tns.run_android(attributes={ '--path': self.app_name, '--device': EMULATOR_ID, '--hmr': '' }, wait=False, assert_success=False) Tns.wait_for_log(log_file=log, string_list=HelpersHMR.run_hmr_with_platforms, not_existing_string_list=HelpersHMR.errors_hmr, timeout=240) Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120) HelpersHMR.apply_changes_js(app_name=self.app_name, log=log, platform=Platform.ANDROID) # Uninstall app while `tns run` is running Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.ANDROID) ReplaceHelper.rollback(self.app_name, HelpersHMR.js_change, sleep=10) strings = [ 'Restarting application on device', 'HMR: Hot Module Replacement Enabled. Waiting for signal.' ] Tns.wait_for_log(log_file=log, string_list=strings) Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120)
def test_003_debug_ios_simulator_start(self): """ Attach the debug tools to a running app in the iOS Simulator """ # Run the app and ensure it works log = Tns.run_ios(attributes={ '--path': self.app_name, '--emulator': '', '--justlaunch': '' }, assert_success=False, timeout=30) TnsAsserts.prepared(app_name=self.app_name, platform=Platform.IOS, output=log, prepare=Prepare.SKIP) Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_home') # Attach debugger log = Tns.debug_ios( attributes={ '--path': self.app_name, '--emulator': '', '--start': '', '--inspector': '' }) DebugiOSInspectorSimulatorTests.__verify_debugger_attach( log, app_started=False)
def test_390_LSApplicationQueriesSchemes_merged(self): # https: // github.com / NativeScript / nativescript - cli / issues / 3108 Folder.cleanup( os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Info.plist')) info_c = os.path.join('data', 'issues', 'info-plist', 'app', 'Info.plist') info_p = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS') Folder.copy(info_c, info_p) Tns.plugin_add("nativescript-geolocation", attributes={"--path": self.app_name}) Folder.cleanup( os.path.join(self.app_name, 'node_modules', 'nativescript-geolocation', 'platforms', 'ios', 'Info.plist')) info_plugin_c = os.path.join('data', 'issues', 'info-plist', 'plugin', 'Info.plist') info_plugin_p = os.path.join(self.app_name, 'node_modules', 'nativescript-geolocation', 'platforms', 'ios') Folder.copy(info_plugin_c, info_plugin_p) Tns.build_ios(attributes={"--path": self.app_name}) output = File.read( os.path.join(self.app_name, 'platforms', 'ios', 'TestApp', 'TestApp-Info.plist')) assert 'itms' in output assert "itms-apps" in output assert "LSApplicationQueriesSchemes" in output
def test_001_usage_reporting_enable(self): output = Tns.run_tns_command("usage-reporting enable") assert enabled.format(usage_reporting, "now ") in output assert "GA_TRACKING_ID" in File.read(self.config) assert "UA-111455-44" in File.read(self.config) # Check there is message for tracking in Google Analytics output = Tns.run_tns_command("doctor", timeout=180, log_trace=True) assert "Will send the following information to Google Analytics" in output output = Tns.run_tns_command("usage-reporting status") assert enabled.format(usage_reporting, "") in output # https://github.com/NativeScript/nativescript-cli/issues/3595 output = Tns.create_app(self.app_name, attributes={ '--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz') }, log_trace=True, force_clean=False, update_modules=True) assert "label: 'data/apps/livesync-hello-world.tgz'" not in output assert "label: 'localTemplate_tns-template-hello-world'" in output
def test_181_tns_run_ios_console_dir(self): """ Test console.dir() of different objects. """ # Change main-page.js so it contains console logging source_js = os.path.join('data', 'console-dir', 'main-page.js') target_js = os.path.join(self.app_name, 'app', 'main-page.js') File.copy(src=source_js, dest=target_js) john_obj = "==== object dump start ====\n" \ "name: John\n" \ "age: 34\n" \ "==== object dump end ====" log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': ''}, wait=False, assert_success=False) strings = ['Project successfully built', 'Successfully installed on device with identifier', self.SIMULATOR_ID, "true", "false", "null", "undefined", "-1", "text", self.max_long_string, john_obj ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=150, check_interval=10) assert self.very_long_string not in log
def test_301_prepare_android_does_not_prepare_ios(self): Tns.plugin_add("nativescript-social-share", attributes={"--path": self.app_name}) Tns.plugin_add("[email protected]", attributes={"--path": self.app_name}) output = Tns.prepare_android(attributes={"--path": self.app_name}) assert "nativescript-iqkeyboardmanager is not supported for android" in output assert "Successfully prepared plugin nativescript-social-share for android" in output
def tearDownClass(cls): Tns.kill() Emulator.stop() Gradle.kill() if CURRENT_OS == OSType.OSX: Process.kill('NativeScript Inspector') Process.kill('Safari') Simulator.stop()
def test_202_build_android_with_log_trace_and_platform_not_added_or_empty(self): """'tns build android' with log trace options should output more logs.""" Tns.create_app(self.app_no_platform) output = Tns.build_android(attributes={"--path": self.app_no_platform}, log_trace=True) # Assert log trace show gradle logs assert "[DEBUG]" in output assert "FAILURE" not in output
def revert_changes_xml(app_name, log, platform): # Change XML after uninstall app from device ReplaceHelper.rollback(app_name, HelpersHMR.xml_change, sleep=10) strings = ['Refreshing application on device', 'HMR: Checking for updates to the bundle with hmr hash'] Tns.wait_for_log(log_file=log, string_list=strings) if platform == Platform.ANDROID: text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP') assert text_changed, 'Changes in XML file not applied (UI is not refreshed).'
def setUp(self): BaseClass.setUp(self) Tns.kill() # Replace app folder between tests. app_folder = os.path.join(self.app_name, 'app') Folder.cleanup(app_folder) Folder.copy(src=self.TEMP_FOLDER, dst=app_folder)
def test_400_platform_list_wrong_path(self): output = Tns.run_tns_command("platform list") assert "No project found at or above" in output assert "and neither was a --path specified." in output output = Tns.run_tns_command("platform list", attributes={"--path": "invalidPath"}) assert "No project found at or above" in output assert "and neither was a --path specified." in output
def test_330_platform_update_ios_platform_not_added(self): Tns.create_app(self.app_name) output = Tns.platform_update(platform="ios", attributes={"--path": self.app_name}, assert_success=False) assert "Platform ios successfully added" in output assert not Folder.is_empty( self.app_name + "/platforms/ios/internal/metadata-generator")
def apply_changes_xml(app_name, log, platform): # Change XML after uninstall app from device ReplaceHelper.replace(app_name, HelpersHMR.xml_change, sleep=10) strings = ['Refreshing application on device', 'JS: HMR: Hot Module Replacement Enabled. Waiting for signal.'] Tns.wait_for_log(log_file=log, string_list=strings) if platform == Platform.ANDROID: text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='TEST') assert text_changed, 'Changes in XML file not applied (UI is not refreshed).'
def revert_changes_js(app_name, log, platform): # Change JS ReplaceHelper.rollback(app_name, HelpersHMR.js_change, sleep=10) strings = ['Refreshing application on device', 'HMR: Hot Module Replacement Enabled. Waiting for signal.'] Tns.wait_for_log(log_file=log, string_list=strings) if platform == Platform.ANDROID: text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='42 taps left', timeout=20) assert text_changed, 'Changes in JS file not applied (UI is not refreshed)'
def test_102_platform_add_log_trace(self): Tns.create_app(self.app_name, update_modules=False) output = Tns.platform_add_android(attributes={"--path": self.app_name}, log_trace=True) assert "Looking for project in" in output assert "Project directory is" in output assert "Package: " + self.app_id in output assert "Installed Android Targets" in output assert "Using Android SDK" in output assert "Platform android successfully added" in output
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) if CURRENT_OS != OSType.OSX: raise NameError("Can not run iOS tests on non OSX OS.") else: Simulator.stop() Tns.create_app(cls.app_name) Tns.platform_add_ios(attributes={"--path": cls.app_name, "--frameworkPath": IOS_PACKAGE}) Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def test_313_build_android_with_invalid_compile_sdk(self): # This is required when build with different SDK Folder.cleanup(self.app_name) Tns.create_app(self.app_name) Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) output = Tns.build_android(attributes={"--compileSdk": "99", "--path": self.app_name}, assert_success=False) assert "You have specified '99' for compile sdk, but it is not installed on your system." in output
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Device.ensure_available(platform=Platform.ANDROID) Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) Tns.create_app(cls.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE})
def test_201_prepare_ios_platform_not_added(self): Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name}, assert_success=False) output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.FIRST_TIME)
def test_400_build_ios_with_wrong_param(self): Tns.create_app(self.app_name_no_platform) output = Tns.build_ios(attributes={ "--path": self.app_name_no_platform, "--" + invalid: "" }, assert_success=False) assert invalid_option.format(invalid) in output assert error not in output.lower()
def test_330_prepare_android_next(self): Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) Tns.platform_add_android(attributes={"--path": self.app_name}, version="next") Folder.cleanup(os.path.join(self.app_name, "node_modules")) Folder.cleanup(os.path.join(self.app_name, "platforms")) android_version = Npm.get_version("tns-android@next") File.replace(file_path=os.path.join(self.app_name, "package.json"), str1=android_version, str2="next") output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FIRST_TIME)
def test_220_platform_clean_android(self): """Prepare after `platform clean` should add the same version that was before clean""" # Create project with [email protected] Tns.platform_add_android(version="5.0.0", attributes={"--path": self.app_name}) TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"5.0.0\""]) # Clean platform and verify platform is 5.0.0 Tns.platform_clean(platform=Platform.ANDROID, attributes={"--path": self.app_name}) TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"5.0.0\""])
def test_202_build_android_with_log_trace_and_platform_not_added_or_empty( self): """'tns build android' with log trace options should output more logs.""" Tns.create_app(self.app_no_platform) output = Tns.build_android(attributes={"--path": self.app_no_platform}, log_trace=True) # Assert log trace show gradle logs assert "[DEBUG]" in output assert "FAILURE" not in output
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 }) Folder.cleanup(TEST_RUN_HOME + "/data/TestApp") Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def test_001_android_run_hmr(self): log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False, assert_success=False) Tns.wait_for_log(log_file=log, string_list=HelpersHMR.run_hmr, not_existing_string_list=HelpersHMR.errors_hmr, timeout=240) Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120) HelpersHMR.apply_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID) HelpersHMR.revert_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
def test_200_platform_update_android(self): """Update platform""" # Create project with tns-android@4 Tns.platform_add_android(version="4.0.0", attributes={"--path": self.app_name}) TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"4.0.0\""]) # Update platform to 5 Tns.platform_update(platform=Platform.ANDROID, version="5.0.0", attributes={"--path": self.app_name}) TnsAsserts.package_json_contains(self.app_name, ["\"version\": \"5.0.0\""])
def test_200_platform_add_ios_framework_path(self): Tns.platform_add_ios(attributes={ "--path": self.app_name, "--frameworkPath": IOS_PACKAGE }) # If project.xcworkspace is there Xcode project name is wrong assert not File.exists( self.app_name + "/platforms/ios/TestApp.xcodeproj/project.xcworkspace")
def test_201_platform_remove_ios(self): Tns.platform_add_ios(attributes={ "--path": self.app_name, "--frameworkPath": IOS_PACKAGE }) Tns.platform_remove(platform="ios", attributes={"--path": self.app_name}) assert Folder.is_empty(self.app_name + '/platforms') output = File.read(self.app_name + os.sep + "package.json") assert "tns-ios" not in output
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) Emulator.ensure_available() Folder.cleanup(cls.app_name) # Create default NG app (to get right dependencies from package.json) Tns.create_app_ng(cls.app_name) Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE})
def test_400_tns_run_ios_should_not_crash_when_uninstall_app(self): """ `tns run ios` should work properly even if I manually uninstall the app (test for issue #3007) """ # `tns run ios` and wait until app is deployed log = Tns.run_ios(attributes={'--path': self.app_name, "--device": self.DEVICE_ID}, wait=False, assert_success=False) strings = [self.DEVICE_ID, 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) # Verify app is running assert Device.wait_for_text(device_id=self.DEVICE_ID, text="taps left"), "App failed to load!" assert Device.wait_for_text(device_id=self.DEVICE_ID, text="TAP"), "App failed to load!" # Change JS and wait until app is synced ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=3) strings = ['Successfully transferred', 'main-view-model.js', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) assert Device.wait_for_text(device_id=self.DEVICE_ID, text="clicks"), "JS changes not synced on device!" # Uninstall app while `tns run` is running Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.IOS) sleep(10) # Change XML and wait until app is synced Tns.wait_for_log(log_file=log, string_list=[], timeout=30) # Just to cleanup log file ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=10) strings = ['Successfully installed', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) assert Device.wait_for_text(device_id=self.DEVICE_ID, text="TEST"), "XML changes not synced on device!"
def test_330_tns_run_ios_after_rebuild_of_native_project(self): """ `tns run ios` should work properly after rebuild of native project (test for issue #2860) """ # `tns run ios` and wait until app is deployed log = Tns.run_ios(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False, assert_success=False, log_trace=True) strings = [self.DEVICE_ID, 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Verify app is running assert Device.wait_for_text(device_id=self.DEVICE_ID, text="Tap the button"), "App failed to load!" # Update native project config_path = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'build.xcconfig') File.replace(file_path=config_path, str1='More info', str2='If you need more info') strings = ['ARCHIVE SUCCEEDED', 'Successfully synced application', self.DEVICE_ID, 'CONSOLE LOG'] not_existing_strings = ['Unable to sync files', 'Multiple errors were thrown'] Tns.wait_for_log(log_file=log, string_list=strings, not_existing_string_list=not_existing_strings, timeout=120) # Verify app is running assert Device.wait_for_text(device_id=self.DEVICE_ID, text="Tap the button"), "App failed to load!" # Change JS and wait until app is synced ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10) strings = ['Successfully transferred', 'main-view-model.js', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) assert Device.wait_for_text(device_id=self.DEVICE_ID, text="clicks"), "JS changes not synced on device!" # Rollback all the changes and verify files are synced ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10) strings = ['Successfully transferred', 'main-view-model.js', 'Restarting application'] Tns.wait_for_log(log_file=log, string_list=strings) assert Device.wait_for_text(device_id=self.DEVICE_ID, text="taps left"), "JS changes not synced on device!"
def test_008_ios_run_hmr_console_log(self): source_js = os.path.join('data', "issues", 'console-log-hmr', 'main-view-model.js') target_js = os.path.join(self.app_name, 'app', 'main-view-model.js') File.copy(src=source_js, dest=target_js) log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--hmr': ''}, wait=False, assert_success=False) strings = ['LOG Hello'] Tns.wait_for_log(log_file=log, string_list=strings) Helpers.ios_screen_match(sim_id=self.SIMULATOR_ID, image=HelpersHMR.image_original, timeout=120)
def setUp(self): BaseClass.setUp(self) Folder.cleanup(self.source_app) if CURRENT_OS != OSType.WINDOWS: Folder.copy(self.temp_app, self.source_app) else: Tns.create_app(self.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_PACKAGE}) Emulator.ensure_available()
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_009_android_run_hmr_delete_file(self): log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False, assert_success=False) Tns.wait_for_log(log_file=log, string_list=HelpersHMR.wp_run, not_existing_string_list=HelpersHMR.wp_errors, timeout=240) HelpersHMR.android_screen_match(image=self.image_original, timeout=120) File.remove(self.app_name + 'app', 'main-view-model.js') self.apply_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID) self.revert_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)