def test_003_android_run_hmr_wrong_xml(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) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image=HelpersHMR.image_original) # Break the app with invalid xml changes ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) # Verify console notify user for broken xml # strings = ['for activity org.nativescript.TestApp / com.tns.ErrorReportActivity'] strings = ['com.tns.NativeScriptException', 'Parsing XML at', 'Successfully synced application', EMULATOR_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) assert Adb.wait_for_text(device_id=EMULATOR_ID, text="Exception", timeout=30), "Error activity not found!" # Revert changes ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) strings = ['JS: HMR: Hot Module Replacement Enabled. Waiting for signal.', 'Successfully synced application', EMULATOR_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image=HelpersHMR.image_original)
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_100_prepare_ios(self): Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE}) # Initial prepare should be full. output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.FULL) # If no file is touched next time prepare should be skipped at all. output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.SKIP) # If some JS/CSS/XML is changed incremental prepare should be done. ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.INCREMENTAL) # Verify Xcode Schemes output = run("xcodebuild -project " + self.app_name + "/platforms/ios/TestApp.xcodeproj/ -list") assert "This project contains no schemes." not in output result = re.search("Targets:\n\s*TestApp", output) assert result is not None result = re.search("Schemes:\n\s*TestApp", output) assert result is not None # Initial prepare for other platform (Android) should be full. output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FULL) # Prepare original platform (iOS) should be skipped. output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.SKIP) # Initial prepare for other platform (Android) should be skipped. output = Tns.prepare_android(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.SKIP)
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_100_prepare_ios(self): Tns.platform_add_android(attributes={ "--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE }) # Initial prepare should be full. output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.FULL) # If no file is touched next time prepare should be skipped at all. output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.SKIP) # If some JS/CSS/XML is changed incremental prepare should be done. ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) output = Tns.prepare_ios(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.INCREMENTAL) # Verify Xcode Schemes output = run("xcodebuild -project " + self.app_name + "/platforms/ios/TestApp.xcodeproj/ -list") assert "This project contains no schemes." not in output result = re.search("Targets:\n\s*TestApp", output) assert result is not None result = re.search("Schemes:\n\s*TestApp", output) assert result is not None # Initial prepare for other platform (Android) should be full. output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FULL) # Prepare original platform (iOS) should be skipped. output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.IOS, output=output, prepare=Prepare.SKIP) # Initial prepare for other platform (Android) should be skipped. output = Tns.prepare_android(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.SKIP)
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 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 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 apply_changes_js(app_name, log, platform): # Change JS ReplaceHelper.replace(app_name, HelpersHMR.js_change, sleep=10) strings = ['Refreshing application on device', 'HMR: The following modules were updated:', './main-view-model.js', './main-page.js', 'Successfully transferred bundle.', 'HMR: Successfully applied update 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='42 clicks left', timeout=20) assert text_changed, 'Changes in JS file not applied (UI is not refreshed).'
def test_201_build_android_with_additional_prepare(self): """Verify that manually running prepare does not break next build command.""" ReplaceHelper.replace(self.app_name, file_change=ReplaceHelper.CHANGE_JS) output = Tns.prepare_android(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.INCREMENTAL) Tns.build_android(attributes={"--path": self.app_name})
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_003_android_run_hmr_wrong_xml(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) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image=HelpersHMR.image_original) # Break the app with invalid xml changes ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) # Verify console notify user for broken xml # strings = ['for activity org.nativescript.TestApp / com.tns.ErrorReportActivity'] strings = [ 'com.tns.NativeScriptException', 'Parsing XML at', 'Successfully synced application', EMULATOR_ID ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) assert Adb.wait_for_text(device_id=EMULATOR_ID, text="Exception", timeout=30), "Error activity not found!" # Revert changes ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) strings = [ 'JS: HMR: Hot Module Replacement Enabled. Waiting for signal.', 'Successfully synced application', EMULATOR_ID ] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, expected_image=HelpersHMR.image_original)
def test_101_prepare_android(self): # Initial prepare should be full. output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.FULL) # If no file is touched next time prepare should be skipped at all. output = Tns.prepare_android(attributes={"--path": self.app_name}, assert_success=False) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.SKIP) # If some JS/CSS/XML is changed incremental prepare should be done. ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) output = Tns.prepare_android(attributes={"--path": self.app_name}) TnsAsserts.prepared(self.app_name, platform=Platform.ANDROID, output=output, prepare=Prepare.INCREMENTAL)
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_002_ios_run_hmr_uninstall_app(self): log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--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.ios_screen_match(sim_id=self.SIMULATOR_ID, image=HelpersHMR.image_original, timeout=120) Helpers.wait_webpack_watcher() HelpersHMR.apply_changes_js(app_name=self.app_name, log=log, platform=Platform.IOS) # Uninstall app while `tns run` is running Simulator.uninstall("org.nativescript." + self.app_name) 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.ios_screen_match(sim_id=self.SIMULATOR_ID, image=HelpersHMR.image_original, timeout=120) Helpers.wait_webpack_watcher()
def revert_changes(app_name, log, platform): # Clean old logs if CURRENT_OS is not OSType.WINDOWS: File.write(file_path=log, text="") # Revert XML changes ReplaceHelper.rollback(app_name, HelpersHMR.xml_change, sleep=10) strings = ['Refreshing application on device', './main-page.xml', '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).' # Revert JS changes ReplaceHelper.rollback(app_name, HelpersHMR.js_change, sleep=10) strings = ['Refreshing application on device', 'HMR: The following modules were updated:', './main-view-model.js', './main-page.js', 'Successfully transferred bundle.', 'HMR: Successfully applied update 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='42 taps left', timeout=20) assert text_changed, 'HMR: The following modules were updated:' # Revert CSS changes ReplaceHelper.rollback(app_name, HelpersHMR.css_change, sleep=10) Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False) # Verify application looks correct Tns.wait_for_log(log_file=log, string_list=HelpersHMR.wp_sync, not_existing_string_list=HelpersHMR.wp_errors, timeout=60) if platform == Platform.ANDROID: Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120)
def apply_changes(app_name, log, platform): not_found_list = [] # Change JS, XML and CSS ReplaceHelper.replace(app_name, HelpersHMR.js_change, sleep=10) strings = ['HMR: The following modules were updated:', './main-view-model.js', './main-page.js', 'Successfully transferred bundle.', 'HMR: Successfully applied update with hmr hash '] # strings = ['JS: HMR: The following modules were updated:', './main-view-model.js', './main-page.js', # 'Successfully transferred bundle.{0}.hot-update.js'.format(hash()), # 'JS: HMR: Successfully applied update with hmr hash {0}'.format(hashlib.sha1)] 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 clicks left', timeout=20) assert text_changed, 'Changes in JS file not applied (UI is not refreshed).' ReplaceHelper.replace(app_name, HelpersHMR.xml_change, sleep=10) strings = ['Refreshing application on device', 'HMR: Checking for updates to the bundle with hmr hash', './main-page.xml', 'HMR: Successfully applied update 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='TEST') assert text_changed, 'Changes in XML file not applied (UI is not refreshed).' ReplaceHelper.replace(app_name, HelpersHMR.css_change, sleep=10) if platform == Platform.ANDROID: Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False) Tns.wait_for_log(log_file=log, string_list=HelpersHMR.wp_sync, not_existing_string_list=HelpersHMR.wp_errors, timeout=120) # Verify application looks correct if platform == Platform.ANDROID: Helpers.android_screen_match(image=HelpersHMR.image_change, timeout=120)
def test_100_debug_ios_simulator_with_livesync(self): """ `tns debug ios` should be able to run with livesync """ log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--inspector': ''}) DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log) # Verify app starts and do not stop on first line of code Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_home') # 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', 'CONSOLE LOG', 'Backend socket closed', 'Frontend socket closed', 'Frontend client connected', 'Backend socket created', 'NativeScript debugger attached'] Tns.wait_for_log(log_file=log, string_list=strings) # Change XML and wait until app is synced. App doesn't restart from 5.1.0 version ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=3) strings = ['Successfully transferred', 'main-page.xml', 'CONSOLE LOG'] Tns.wait_for_log(log_file=log, string_list=strings) # Change CSS and wait until app is synced. App doesn't restart from 5.1.0 version ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS, sleep=3) strings = ['Successfully transferred', 'app.css', 'CONSOLE LOG'] Tns.wait_for_log(log_file=log, string_list=strings) # Verify application looks correct Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_js_css_xml', tolerance=0.26) assert Process.is_running('NativeScript Inspector')
def test_100_debug_ios_simulator_with_livesync(self): """ `tns debug ios` should be able to run with livesync """ log = Tns.debug_ios(attributes={ '--path': self.app_name, '--emulator': '', '--inspector': '' }) DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log) # Verify app starts and do not stop on first line of code Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_home') # 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', 'CONSOLE LOG', 'Backend socket closed', 'Frontend socket closed', 'Frontend client connected', 'Backend socket created', 'NativeScript debugger attached' ] Tns.wait_for_log(log_file=log, string_list=strings) # Change XML and wait until app is synced. App doesn't restart from 5.1.0 version ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=3) strings = ['Successfully transferred', 'main-page.xml', 'CONSOLE LOG'] Tns.wait_for_log(log_file=log, string_list=strings) # Change CSS and wait until app is synced. App doesn't restart from 5.1.0 version ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS, sleep=3) strings = ['Successfully transferred', 'app.css', 'CONSOLE LOG'] Tns.wait_for_log(log_file=log, string_list=strings) # Verify application looks correct Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_js_css_xml', tolerance=0.26) assert Process.is_running('NativeScript Inspector')
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_201_prepare_xml_error(self): Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False) ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) output = Tns.prepare_android(attributes={"--path": self.app_name}) assert "main-page.xml has syntax errors." in output assert "unclosed xml attribute" in output