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_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_401_plugin_add_sandbox_pod_can_not_write_outside_app_folder_if_use_pod_sandbox_is_true(self): File.replace("node_modules/nativescript/config/config.json", '"USE_POD_SANDBOX": false', '"USE_POD_SANDBOX": true') Tns.create_app(self.app_name) Tns.platform_add_ios(attributes={"--path": self.app_name, "--frameworkPath": IOS_PACKAGE}) plugin = os.path.join(TEST_RUN_HOME, "data", "CocoaPods", "nativescript-ios-fail-with-sandbox-plugin.tgz") output = Tns.plugin_add(plugin, attributes={"--path": self.app_name}, assert_success=False) assert "Successfully installed plugin nativescript-ios-fail-with-sandbox-plugin." in output assert "nativescript-ios-fail-with-sandbox-plugin" in File.read(self.app_name + "/package.json") output = Tns.prepare_ios(attributes={"--path": self.app_name}, assert_success=False) assert "Successfully prepared " + \ "plugin nativescript-ios-fail-with-sandbox-plugin for ios." in output assert "sh: ../I_MADE_THIS_FILE.txt: Operation not permitted" in output assert not File.exists(self.app_name + "/platforms/I_MADE_THIS_FILE.txt")
def rollback(app_name, file_change, sleep=1): File.replace(app_name + '/' + file_change[0], file_change[2], file_change[1]) time.sleep(sleep)
def tearDown(self): File.replace(TEST_RUN_HOME + "/node_modules/nativescript/config/config.json", '"USE_POD_SANDBOX": true', '"USE_POD_SANDBOX": false')
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 rollback(app_name, file_change, sleep=1): File.replace(app_name + '/' + file_change[0], file_change[2], file_change[1]) time.sleep(sleep)