def test(self, template_name, template_info): TnsRunTest.setUp(self) # Create app app_name = template_info.name.replace('template-', '') Tns.create(app_name=app_name, template='tns-' + template_name, update=False) if Settings.ENV != EnvironmentType.LIVE and Settings.ENV != EnvironmentType.PR: App.update(app_name=app_name) # Run Android result = Tns.run_android(app_name=app_name, device=self.emu.id) 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) if template_info.texts is not None: for text in template_info.texts: self.emu.wait_for_text(text=text, timeout=60) else: self.emu.wait_for_main_color(color=Colors.WHITE, timeout=60) # Run iOS 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) 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) if template_info.texts is not None: for text in template_info.texts: self.sim.wait_for_text(text=text, timeout=60) else: self.sim.wait_for_main_color(color=Colors.WHITE, timeout=60) # Cleanup TnsRunTest.tearDown(self)
def setUpClass(cls): TnsTest.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)
def setUpClass(cls): TnsTest.setUpClass() cls.sim = DeviceManager.Simulator.ensure_available(Simulators.DEFAULT) Simctl.uninstall_all(cls.sim) Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=True) Tns.platform_add_ios(APP_NAME, framework_path=IOS.FRAMEWORK_PATH)
def setUpClass(cls): TnsTest.setUpClass() cls.emu = DeviceManager.Emulator.ensure_available( Settings.Emulators.DEFAULT) if Settings.HOST_OS is OSType.OSX: # Run regression tests on older iOS (since old modules might not be compatible with latest iOS). cls.sim = DeviceManager.Simulator.ensure_available( Settings.Simulators.SIM_IOS11) Simctl.uninstall_all(cls.sim) LegacyApp.create(app_name=cls.ng_app, app_type=AppType.NG)
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_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 setUpClass(cls): TnsTest.setUpClass() cls.sim = DeviceManager.Simulator.ensure_available( Settings.Simulators.DEFAULT) Simctl.uninstall_all(cls.sim)