def setUpClass(cls): TnsRunTest.setUpClass() # Create app Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_JS.local_package, update=True) src = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'logs', 'hello-world-js', 'app.js') target = os.path.join(cls.app_path, 'app') File.copy(source=src, target=target) # Create app with space in name Tns.create(app_name=cls.app_name_space, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_android(app_name=cls.app_name, framework_path=Settings.Android.FRAMEWORK_PATH) Tns.platform_add_android(app_name=cls.normalized_app_name_space, verify=False, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) Tns.platform_add_ios(app_name=cls.normalized_app_name_space, verify=False, framework_path=Settings.IOS.FRAMEWORK_PATH) # Copy TestApp to data folder. Folder.copy(source=cls.source_project_dir, target=cls.target_project_dir)
def test_400_invalid_framework_name(self): result = Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=False, verify=False) TnsAssert.created(app_name=APP_NAME, output=result.output, theme=False, webpack=False) result = Tns.test_init(app_name=APP_NAME, framework='jasmin', verify=False) assert 'Unknown or unsupported unit testing framework: jasmin' in result.output
def test_391_tns_run_ios_console_time(self): Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME)) Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_NG.local_package, update=True) Tns.platform_add_ios(APP_NAME, framework_path=IOS.FRAMEWORK_PATH) # Replace app.component.ts to use console.time() and console.timeEnd() File.copy( os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'ios', 'files', 'ios-runtime-843', 'app.component.ts'), os.path.join(APP_PATH, 'src', 'app', 'app.component.ts'), True) # `tns run ios` and wait until app is deployed result = Tns.run_ios(app_name=APP_NAME, emulator=True, wait=False, verify=False) # Verify initial state of the app strings = [ 'Project successfully built', 'Successfully installed on device with identifier', self.sim.id ] assert_result = Wait.until(lambda: all(st in File.read(result.log_file) for st in strings), timeout=200, period=5) assert assert_result, 'App not build correctly! Logs: ' + File.read( result.log_file) Device.wait_for_text(self.sim, text="Ter Stegen", timeout=30) # Verify console.time() works - issue https://github.com/NativeScript/ios-runtime/issues/843 console_time = ['CONSOLE INFO startup:'] TnsLogs.wait_for_log(log_file=result.log_file, string_list=console_time)
def test_365_tns_run_android_should_respect_adb_errors(self): """ If device memory is full and error is thrown during deploy cli should respect it https://github.com/NativeScript/nativescript-cli/issues/2170 """ # Deploy the app to make sure we have something at /data/data/org.nativescript.TestApp result = run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu, just_launch=True) # Use all the disk space on emulator dest_file = '/data/data/' + TnsPaths.get_bundle_id(self.app_name) for index in range(1, 3000): command = "shell 'su 0 cp -r {0} {0}{1}'".format(dest_file, str(index)) result = Adb.run_adb_command(device_id=self.emu.id, command=command) Log.info(result.output) if "No space left on device" in result.output: break # Create new app Tns.create(app_name='TestApp2', template=Template.HELLO_WORLD_JS.local_package, update=True) # Run the app and verify there is appropriate error result = Tns.run_android('TestApp2', verify=True, device=self.emu.id, just_launch=True) strings = ['No space left on device'] TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)
def test_300_tns_resources_update(self): # Create nativescript@3 app result = Tns.create(app_name=APP_NAME, template='[email protected]', verify=False, update=False) TnsAssert.created(app_name=APP_NAME, output=result.output, webpack=False) # Update resources out = Tns.exec_command(command='resources update', path=APP_NAME).output assert "Successfully updated your project's application resources '/Android' directory structure." in out assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in out
def test_100(self, title, framework, template, platform): # Create app Tns.create(app_name=APP_NAME, template=template.local_package) # Add platforms if platform == Platform.ANDROID: Tns.platform_add_android( app_name=APP_NAME, framework_path=Settings.Android.FRAMEWORK_PATH) elif platform == Platform.IOS: Tns.platform_add_ios(app_name=APP_NAME, framework_path=Settings.IOS.FRAMEWORK_PATH) else: raise Exception('Unknown platform: ' + str(platform)) # Init tests and run tests if Settings.HOST_OS == OSType.WINDOWS and framework == FrameworkType.QUNIT: # Hack for qunit on windows (see https://github.com/NativeScript/nativescript-cli/issues/4333) Npm.install(package='qunit@2', option='--save-dev', folder=os.path.join(Settings.TEST_RUN_HOME, APP_NAME)) # Tns test init will still fail with exit code 1, so we use `verify=False` and then assert logs. result = Tns.test_init(app_name=APP_NAME, framework=framework, verify=False) TnsAssert.test_initialized(app_name=APP_NAME, framework=framework, output=result.output) else: Tns.test_init(app_name=APP_NAME, framework=framework) # Run Tests Tns.test(app_name=APP_NAME, platform=platform, emulator=True, just_launch=True)
def setUpClass(cls): TnsRunTest.setUpClass() # Create JS app and copy to temp data folder Tns.create(app_name=cls.js_app, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_android( app_name=cls.js_app, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.js_app, framework_path=Settings.IOS.FRAMEWORK_PATH) # Create NG app and copy to temp data folder Tns.create(app_name=cls.ng_app, template=Template.HELLO_WORLD_NG.local_package, update=True) Tns.platform_add_android( app_name=cls.ng_app, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.ng_app, framework_path=Settings.IOS.FRAMEWORK_PATH)
def setUpClass(cls): TnsDeviceTest.setUpClass() cls.emu = DeviceManager.Emulator.ensure_available( Settings.Emulators.DEFAULT) if Settings.HOST_OS is OSType.OSX: cls.sim = DeviceManager.Simulator.ensure_available( Settings.Simulators.DEFAULT) Simctl.uninstall_all(cls.sim) # Create app Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_android( app_name=cls.app_name, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=cls.app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) # Copy TestApp to data folder. Folder.copy(source=cls.source_project_dir, target=cls.target_project_dir)
def test_200_doctor_show_warning_when_new_components_are_available(self): result = Tns.create(app_name=self.APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=False, verify=False) TnsAssert.created(app_name=self.APP_NAME, output=result.output, theme=False, webpack=False) Tns.platform_add_android(app_name=self.APP_NAME, version='4') App.install_dependency(app_name=self.APP_NAME, dependency='tns-core-modules', version='4') doctor_result = Tns.doctor(app_name=self.APP_NAME) doctor_output = doctor_result.output info_result = Tns.info(app_name=self.APP_NAME) info_output = info_result.output for output in (doctor_output, info_output): assert 'Update available for component tns-core-modules' in output assert 'Update available for component tns-android' in output
def setUpClass(cls): TnsRunAndroidTest.setUpClass() Docker.start() # Create app result = Tns.create(app_name=cls.app_name, template='[email protected]', verify=False) TnsAssert.created(app_name=cls.app_name, output=result.output, path=Settings.TEST_RUN_HOME, theme=False) # Copy TestApp to data folder. Folder.copy(source=cls.source_project_dir, target=cls.target_project_dir)
def setUpClass(cls): TnsTest.setUpClass() cls.emulator = DeviceManager.Emulator.ensure_available(Emulators.DEFAULT) Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME)) Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_android(APP_NAME, framework_path=Android.FRAMEWORK_PATH)
def setUpClass(cls): TnsTest.setUpClass() Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=True)
def test_006_create_project_with_space(self): """ Create project with space is possible, but packageId will skip the dash symbol""" Tns.create(app_name=Settings.AppName.WITH_SPACE, template=Template.HELLO_WORLD_JS.local_package, app_data=Apps.HELLO_WORLD_JS, update=False)
def test_204_install_defaults(self): Tns.create(app_name=self.app_name, template=Template.HELLO_WORLD_JS.local_package, update=True) result = Tns.exec_command(command='install', path=self.APP_PATH) self.verify_installed(output=result.output)
def test_003_create_app_template_ts(self): """Create app with --template ts project""" Tns.create(app_name=Settings.AppName.DEFAULT, template=Template.HELLO_WORLD_TS.local_package, app_data=Apps.HELLO_WORLD_TS, update=False)
def test_200_create_project_with_template(self, template_source): """Create app should be possible with --template and npm packages, git repos and aliases""" Tns.create(app_name=Settings.AppName.DEFAULT, template=template_source, update=False)
def test_011_create_app_scoped_packages(self): result = Tns.create(app_name=Settings.AppName.DEFAULT, template="@angular/core", verify=False) assert "Command npm install" not in result.output
def test_scoped_package_only(self, app_name, template_info): TnsRunTest.setUp(self) # Create app app_path = os.path.join(Settings.TEST_RUN_HOME, app_name) Tns.create(app_name=app_name, template=template_info.local_package, update=True) Npm.uninstall(package='tns-core-modules', option='--save', folder=app_path) Npm.install(package=Settings.Packages.NATIVESCRIPT_CORE, option='--save --save-exact', folder=app_path) # Replace imports if template_info == Template.HELLO_WORLD_TS: files = File.find_by_extension(folder=os.path.join( app_path, 'app'), extension='ts') for file in files: File.replace(path=file, old_string='tns-core-modules', new_string='@nativescript/core', fail_safe=True) if template_info == Template.MASTER_DETAIL_NG: files = File.find_by_extension(folder=os.path.join( app_path, 'src'), extension='ts') for file in files: File.replace(path=file, old_string='tns-core-modules', new_string='@nativescript/core', fail_safe=True) Tns.platform_add_android( app_name=app_name, framework_path=Settings.Android.FRAMEWORK_PATH) if Settings.HOST_OS is OSType.OSX: Tns.platform_add_ios(app_name=app_name, framework_path=Settings.IOS.FRAMEWORK_PATH) # Run Android result = Tns.run_android(app_name=app_name, device=self.emu.id, aot=True, uglify=True) strings = TnsLogs.run_messages(app_name=app_name, run_type=RunType.UNKNOWN, platform=Platform.ANDROID) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300) for text in template_info.texts: self.emu.wait_for_text(text=text, timeout=60) # Run iOS Tns.kill() if Settings.HOST_OS is OSType.OSX: Simctl.uninstall_all(simulator_info=self.sim) result = Tns.run_ios(app_name=app_name, device=self.sim.id, aot=True, uglify=True) strings = TnsLogs.run_messages(app_name=app_name, run_type=RunType.UNKNOWN, platform=Platform.IOS) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300) for text in template_info.texts: self.sim.wait_for_text(text=text, timeout=60) # Cleanup Folder.clean(os.path.join(Settings.TEST_RUN_HOME, app_name)) TnsRunTest.tearDown(self)
def test_001_create_app_like_real_user(self): """Create app with no any params""" Tns.create(app_name=Settings.AppName.DEFAULT, app_data=Apps.HELLO_WORLD_JS, update=False)