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_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_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_210_tns_run_ios_add_remove_files_and_folders(self): """ New files and folders should be synced properly. """ log = Tns.run_ios(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False, assert_success=False) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Add new files new_file_name = 'app2.css' source_file = os.path.join(self.app_name, 'app', 'app.css') destination_file = os.path.join(self.app_name, 'app', new_file_name) File.copy(source_file, destination_file) strings = ['Successfully transferred', new_file_name, 'Refreshing application'] Tns.wait_for_log(log_file=log, string_list=strings) # Revert changes(rename file and delete file) # File.copy(destination_file, source_file) # File.remove(destination_file) # strings = ['Successfully transferred', new_file_name] # Tns.wait_for_log(log_file=log, string_list=strings) # Add folder new_folder_name = 'test2' source_file = os.path.join(self.app_name, 'app', 'test') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = ['Successfully transferred test.txt', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings)
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 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 setUp(self): BaseClass.setUp(self) # Ensure app is in initial state Folder.navigate_to(folder=TEST_RUN_HOME, relative_from_current_folder=False) Folder.cleanup(self.app_name) Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp")
def ensure_app_resources(path): app_resources_path = os.path.join(path, "app", "App_Resources") if File.exists(app_resources_path): pass else: print "AppResources not found. Will copy from default template..." src = os.path.join(TEST_RUN_HOME, "sut", "template-hello-world", "app", "App_Resources") dest = os.path.join(TEST_RUN_HOME, path, "app", "App_Resources") Folder.copy(src, dest)
def test_210_tns_run_android_add_remove_files_and_folders(self): """ New files and folders should be synced properly. """ log = Tns.run_android(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False, assert_success=False) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Add new files new_file_name = 'main-page2.xml' source_file = os.path.join(self.app_name, 'app', 'main-page.xml') destination_file = os.path.join(self.app_name, 'app', new_file_name) File.copy(source_file, destination_file) strings = ['Successfully transferred main-page2.xml', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new file is synced and available on device. error_message = 'Newly created file {0} not found on {1}'.format(new_file_name, self.DEVICE_ID) app_id = Tns.get_app_id(app_name=self.app_name) path = 'app/{0}'.format(new_file_name) assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message # Revert changes(rename file and delete file) File.copy(destination_file, source_file) File.remove(destination_file) strings = ['Successfully transferred main-page.xml', 'Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new file is synced and available on device. error_message = '{0} was deleted, but still available on {1}'.format(new_file_name, self.DEVICE_ID) assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message # Add folder new_folder_name = 'feature2' source_file = os.path.join(self.app_name, 'app', 'feature1') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = ['Successfully transferred', 'Successfully transferred', 'feature1.js', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new folder is synced and available on device. error_message = 'Newly created folder {0} not found on {1}'.format(new_folder_name, self.DEVICE_ID) path = 'app/{0}'.format(new_folder_name) assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message path = 'app/{0}/{1}'.format(new_folder_name, 'feature1.js') assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message # Delete folder Folder.cleanup(destination_file) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings) # Verify new folder is deleted from device. error_message = 'Deleted folder {0} is still available on {1}'.format(new_folder_name, self.DEVICE_ID) assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message
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_450_resources_update_ios(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-34') Folder.cleanup(target_app) Folder.copy(source_app, target_app) output = Tns.run_tns_command("resources update ios", attributes={"--path": self.app_name}) assert "The ios does not need to have its resources updated." 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 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 setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Simulator.stop() cls.SIMULATOR_ID = Simulator.ensure_available(simulator_name=SIMULATOR_NAME) Folder.cleanup(cls.app_name) Tns.create_app(cls.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE}) Folder.cleanup(TEST_RUN_HOME + "/data/TestApp") Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Simulator.stop() Device.ensure_available(platform=Platform.IOS) Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.IOS) Folder.cleanup(cls.app_name) Tns.create_app(cls.app_name, attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')}, update_modules=True) Folder.copy(src=os.path.join(cls.app_name, 'app'), dst=cls.TEMP_FOLDER) Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE})
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Emulator.ensure_available() Tns.create_app(BaseClass.app_name) Tns.platform_add_android(attributes={"--path": BaseClass.app_name, "--frameworkPath": ANDROID_PACKAGE}) Tns.update_webpack(BaseClass.app_name) Folder.copy(os.path.join(TEST_RUN_HOME, BaseClass.app_name), os.path.join(TEST_RUN_HOME, "data", "TestApp")) #Download bundletool url = 'https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar' urllib.urlretrieve(url, os.path.join(SUT_FOLDER, 'bundletool.jar'))
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.kill() Emulator.stop() Emulator.ensure_available() Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) if CURRENT_OS != OSType.WINDOWS: 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}) Folder.cleanup(cls.temp_app) Folder.copy(cls.source_app, cls.temp_app)
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_003_tns_resources_generate_icons_apetools(self): #https://github.com/NativeScript/nativescript-cli/issues/3666 Folder.cleanup(os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Assets.xcassets', 'AppIcon.appiconset')) folder = os.path.join(TEST_RUN_HOME, "data", "images", "resources_generate", "apetool", "AppIcon.appiconset") destination = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Assets.xcassets', 'AppIcon.appiconset') Folder.copy(folder, destination) icon_path = os.path.join(self.app_name, "app", "App_Resources", "iOS", "Assets.xcassets", "AppIcon.appiconset", "*****@*****.**") output = run("tns resources generate icons \"" + icon_path + "\"" + " --path " + self.app_name) assert "Generating icons" in output assert "Icons generation completed" in output assert "Invalid settings specified for the resizer." not 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 setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Emulator.ensure_available() Tns.create_app(BaseClass.app_name) Tns.platform_add_android(attributes={ "--path": BaseClass.app_name, "--frameworkPath": ANDROID_PACKAGE }) Tns.update_webpack(BaseClass.app_name) Folder.copy(os.path.join(TEST_RUN_HOME, BaseClass.app_name), os.path.join(TEST_RUN_HOME, "data", "TestApp")) #Download bundletool url = 'https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar' urllib.urlretrieve(url, os.path.join(SUT_FOLDER, 'bundletool.jar'))
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 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_tns_run_ios_add_remove_files_and_folders(self): """ New files and folders should be synced properly. """ log = Tns.run_ios(attributes={ '--path': self.app_name, '--device': self.DEVICE_ID }, wait=False, assert_success=False) strings = ['Successfully synced application', self.DEVICE_ID] Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10) # Add new files new_file_name = 'app2.css' source_file = os.path.join(self.app_name, 'app', 'app.css') destination_file = os.path.join(self.app_name, 'app', new_file_name) File.copy(source_file, destination_file) strings = [ 'Successfully transferred', new_file_name, 'Refreshing application' ] Tns.wait_for_log(log_file=log, string_list=strings) # Revert changes(rename file and delete file) # File.copy(destination_file, source_file) # File.remove(destination_file) # strings = ['Successfully transferred', new_file_name] # Tns.wait_for_log(log_file=log, string_list=strings) # Add folder new_folder_name = 'test2' source_file = os.path.join(self.app_name, 'app', 'test') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = [ 'Successfully transferred test.txt', 'Successfully synced application' ] Tns.wait_for_log(log_file=log, string_list=strings)
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Emulator.stop() Simulator.stop() Device.ensure_available(platform=Platform.IOS) Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.IOS) Folder.cleanup(cls.app_name) Tns.create_app(cls.app_name, attributes={ '--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz') }, update_modules=True) Folder.copy(src=os.path.join(cls.app_name, 'app'), dst=cls.TEMP_FOLDER) Tns.platform_add_ios(attributes={ '--path': cls.app_name, '--frameworkPath': IOS_PACKAGE })
def test_200_plugin(self, plugin, verification, comment): print "Test case: " + comment Folder.cleanup(self.app_name) Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp") plugin_path = os.path.join(TEST_RUN_HOME, 'data', 'plugins', 'android', plugin) plugin_name = plugin.replace(".tgz", "") Tns.plugin_add(plugin_path, attributes={"--path": self.app_name}) output = Tns.prepare_android(attributes={"--path": self.app_name}) assert "Successfully prepared plugin {0} for android".format( plugin_name) in output if "no-aar-build" in verification: assert "Built aar for" not in output else: assert "Built aar for" in output plugin_folder = plugin_name.replace("-", "_") aar_file = os.path.join(self.app_name, 'platforms', 'tempPlugin', plugin_folder, 'build', 'outputs', 'aar', '{0}-release.aar'.format(plugin_folder)) assert File.exists(aar_file)
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.kill() Emulator.stop() Emulator.ensure_available() Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID) if CURRENT_OS != OSType.WINDOWS: 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 }) Folder.cleanup(cls.temp_app) Folder.copy(cls.source_app, cls.temp_app)
def test_003_tns_resources_generate_icons_apetools(self): #https://github.com/NativeScript/nativescript-cli/issues/3666 Folder.cleanup( os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Assets.xcassets', 'AppIcon.appiconset')) folder = os.path.join(TEST_RUN_HOME, "data", "images", "resources_generate", "apetool", "AppIcon.appiconset") destination = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Assets.xcassets', 'AppIcon.appiconset') Folder.copy(folder, destination) icon_path = os.path.join(self.app_name, "app", "App_Resources", "iOS", "Assets.xcassets", "AppIcon.appiconset", "*****@*****.**") output = run("tns resources generate icons \"" + icon_path + "\"" + " --path " + self.app_name) assert "Generating icons" in output assert "Icons generation completed" in output assert "Invalid settings specified for the resizer." not in output
def check_splashes(app_resources_android, app_resources_ios): for folder in ResourcesGenerateTests.drawable_folders: actual_logo = os.path.join(app_resources_android, folder, "logo.png") expected_logo = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "logo.png") result = ImageUtils.image_match(actual_logo, expected_logo, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_logo, expected_logo, str(result[1])) actual_background = os.path.join(app_resources_android, folder, "background.png") expected_background = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "background.png") result = ImageUtils.image_match(actual_background, expected_background, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_background, expected_background, str(result[1])) # iOS if CURRENT_OS == OSType.OSX: # Get all images to compare in one folder src_1 = os.path.join(app_resources_ios, "LaunchImage.launchimage") src_2 = os.path.join(app_resources_ios, "LaunchScreen.AspectFill.imageset") src_3 = os.path.join(app_resources_ios, "LaunchScreen.Center.imageset") Folder.create("temp_ios_resources") dist = os.path.join(os.getcwd(), "temp_ios_resources") Folder.copy(src_1, dist, only_files=True) Folder.copy(src_2, dist, only_files=True) Folder.copy(src_3, dist, only_files=True) ios_images = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "Default-1125h.png", "Default-Landscape-X.png", "Default-Landscape.png", "*****@*****.**", "*****@*****.**", "Default-Portrait.png", "*****@*****.**", "Default.png", "*****@*****.**", "LaunchScreen-AspectFill.png", "*****@*****.**", "LaunchScreen-Center.png", "*****@*****.**"] for image in ios_images: actual_image = os.path.join(os.getcwd(), "temp_ios_resources", image) expected_image = os.path.join(ResourcesGenerateTests.expected_images_ios, image) result = ImageUtils.image_match(actual_image, expected_image, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_image, expected_image, str(result[1]))
def setUp(self): BaseClass.setUp(self) Folder.cleanup(self.app_name) Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp")
def check_splashes(app_resources_android, app_resources_ios): for folder in ResourcesGenerateTests.drawable_folders: actual_logo = os.path.join(app_resources_android, folder, "logo.png") expected_logo = os.path.join( ResourcesGenerateTests.expected_images_android, folder, "logo.png") result = ImageUtils.image_match(actual_logo, expected_logo, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format( actual_logo, expected_logo, str(result[1])) actual_background = os.path.join(app_resources_android, folder, "background.png") expected_background = os.path.join( ResourcesGenerateTests.expected_images_android, folder, "background.png") result = ImageUtils.image_match(actual_background, expected_background, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format( actual_background, expected_background, str(result[1])) # iOS if CURRENT_OS == OSType.OSX: # Get all images to compare in one folder src_1 = os.path.join(app_resources_ios, "LaunchImage.launchimage") src_2 = os.path.join(app_resources_ios, "LaunchScreen.AspectFill.imageset") src_3 = os.path.join(app_resources_ios, "LaunchScreen.Center.imageset") Folder.create("temp_ios_resources") dist = os.path.join(os.getcwd(), "temp_ios_resources") Folder.copy(src_1, dist, only_files=True) Folder.copy(src_2, dist, only_files=True) Folder.copy(src_3, dist, only_files=True) ios_images = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "Default-1125h.png", "Default-Landscape-X.png", "Default-Landscape.png", "*****@*****.**", "*****@*****.**", "Default-Portrait.png", "*****@*****.**", "Default.png", "*****@*****.**", "LaunchScreen-AspectFill.png", "*****@*****.**", "LaunchScreen-Center.png", "*****@*****.**" ] for image in ios_images: actual_image = os.path.join(os.getcwd(), "temp_ios_resources", image) expected_image = os.path.join( ResourcesGenerateTests.expected_images_ios, image) result = ImageUtils.image_match(actual_image, expected_image, 0.1) if str(result[0]) is "False": assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format( actual_image, expected_image, str(result[1]))
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.create_app(cls.app_name) Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def setUpClass(cls): BaseClass.setUpClass(cls.__name__) Tns.create_app(cls.app_name, update_modules=False) Tns.platform_add_android(attributes={"--path": cls.app_name, "--frameworkPath": ANDROID_PACKAGE}) Folder.copy(TEST_RUN_HOME + "/" + cls.app_name, TEST_RUN_HOME + "/data/TestApp")
def setUp(self): BaseClass.setUp(self) self.SIMULATOR_ID = Simulator.ensure_available(simulator_name=SIMULATOR_NAME) Folder.cleanup(self.app_name) Folder.copy(TEST_RUN_HOME + "/data/TestApp", TEST_RUN_HOME + "/TestApp")