From bfa096917eeea40cb5b71e072311ac2f4b5e660d Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Tue, 14 Aug 2018 14:40:09 +0300 Subject: [PATCH 1/8] change template --- data/console-dir/main-page.js | 42 +++++++++- data/console-log/main-page.js | 45 ++++++++-- data/folders/feature1/feature1.js | 1 + data/folders/main-page.js | 43 ++++++++++ tests/emulator/run_android_tests.py | 122 +++++++++++++--------------- tests/helpers/livesync_helper.py | 45 ++++++++++ tests/nsconfig/run_android_tests.py | 2 +- 7 files changed, 224 insertions(+), 76 deletions(-) create mode 100644 data/folders/feature1/feature1.js create mode 100644 data/folders/main-page.js create mode 100644 tests/helpers/livesync_helper.py diff --git a/data/console-dir/main-page.js b/data/console-dir/main-page.js index 6af071c5..e3eedb59 100644 --- a/data/console-dir/main-page.js +++ b/data/console-dir/main-page.js @@ -1,8 +1,35 @@ -var vmModule = require("./main-view-model"); +/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ -function pageLoaded(args) { +/* +NativeScript adheres to the CommonJS specification for dealing with +JavaScript modules. The CommonJS require() function is how you import +JavaScript modules defined in other files. +*/ +var createViewModel = require("./main-view-model").createViewModel; + +function onNavigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ var page = args.object; - page.bindingContext = vmModule.mainViewModel; + + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and JavaScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = createViewModel(); console.log("### TEST START ###"); var undef; @@ -30,4 +57,11 @@ function pageLoaded(args) { console.log("### TEST END ###"); } -exports.pageLoaded = pageLoaded; + +/* +Exporting a function in a NativeScript code-behind file makes it accessible +to the file’s corresponding XML file. In this case, exporting the onNavigatingTo +function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML +file work. +*/ +exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file diff --git a/data/console-log/main-page.js b/data/console-log/main-page.js index 9537fa72..ed8962c6 100644 --- a/data/console-log/main-page.js +++ b/data/console-log/main-page.js @@ -1,9 +1,36 @@ -var vmModule = require("./main-view-model"); +/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ + +/* +NativeScript adheres to the CommonJS specification for dealing with +JavaScript modules. The CommonJS require() function is how you import +JavaScript modules defined in other files. +*/ +var createViewModel = require("./main-view-model").createViewModel; var buttonModule = require("tns-core-modules/ui/button"); -function pageLoaded(args) { +function onNavigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ var page = args.object; - page.bindingContext = vmModule.mainViewModel; + + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and JavaScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = createViewModel(); console.log("### TEST START ###"); console.time("Time"); @@ -21,7 +48,6 @@ function pageLoaded(args) { } console.log(very_long_string); - console.log(true); console.log(false); console.log(null); @@ -34,7 +60,6 @@ function pageLoaded(args) { console.log(`number: ${num}`); console.log(`string: ${str}`); console.log(`${str} ${num}`); - console.info("info"); console.warn("warn"); console.error("error"); @@ -45,7 +70,6 @@ function pageLoaded(args) { console.assert("", "empty string evaluates to 'false'"); console.trace("console.trace() called"); - console.log(`${button}`); console.log(num, str, obj); @@ -56,4 +80,11 @@ function pageLoaded(args) { console.timeEnd("Time"); console.log("### TEST END ###"); } -exports.pageLoaded = pageLoaded; + +/* +Exporting a function in a NativeScript code-behind file makes it accessible +to the file’s corresponding XML file. In this case, exporting the onNavigatingTo +function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML +file work. +*/ +exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file diff --git a/data/folders/feature1/feature1.js b/data/folders/feature1/feature1.js new file mode 100644 index 00000000..62cd56a6 --- /dev/null +++ b/data/folders/feature1/feature1.js @@ -0,0 +1 @@ +console.log("I was here") \ No newline at end of file diff --git a/data/folders/main-page.js b/data/folders/main-page.js new file mode 100644 index 00000000..570376d0 --- /dev/null +++ b/data/folders/main-page.js @@ -0,0 +1,43 @@ +/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ + +/* +NativeScript adheres to the CommonJS specification for dealing with +JavaScript modules. The CommonJS require() function is how you import +JavaScript modules defined in other files. +*/ +var createViewModel = require("./main-view-model").createViewModel; +var count = 0; + +function onNavigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ + var page = args.object; + + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and JavaScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = createViewModel(); + console.log("Page loaded " + ++count + " times."); +} + +/* +Exporting a function in a NativeScript code-behind file makes it accessible +to the file’s corresponding XML file. In this case, exporting the onNavigatingTo +function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML +file work. +*/ +exports.onNavigatingTo = onNavigatingTo; \ No newline at end of file diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index ef12a03a..fbc88603 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -31,7 +31,7 @@ from core.osutils.os_type import OSType from core.settings.settings import ANDROID_PACKAGE, ANDROID_KEYSTORE_PATH, ANDROID_KEYSTORE_PASS, \ ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS, EMULATOR_ID, EMULATOR_NAME, CURRENT_OS, TEST_RUN_HOME -from core.tns.replace_helper import ReplaceHelper +from tests.helpers.livesync_helper import LivesyncHelper from core.tns.tns import Tns from core.tns.tns_platform_type import Platform from core.tns.tns_prepare_type import Prepare @@ -59,31 +59,16 @@ def setUpClass(cls): 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 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() + Tns.create_app(self.app_name) + Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_PACKAGE}) def tearDown(self): Tns.kill() - if CURRENT_OS == OSType.WINDOWS: - Emulator.stop() BaseClass.tearDown(self) + Folder.cleanup('TestApp') Folder.cleanup('TestApp2') @classmethod @@ -92,7 +77,6 @@ def tearDownClass(cls): Emulator.stop() # We need this because of test_400_tns_run_android_respect_adb_errors Folder.cleanup(cls.temp_app) - @unittest.skip('temp') def test_001_tns_run_android_js_css_xml_manifest(self): """Make valid changes in JS,CSS and XML""" @@ -106,63 +90,66 @@ def test_001_tns_run_android_js_css_xml_manifest(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Change JS and wait until app is synced - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) 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).' # Change XML and wait until app is synced - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=3) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) 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).' # Change CSS and wait until app is synced - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS, sleep=3) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) strings = ['Successfully transferred app.css', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) # Verify application looks correct Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_js_css_xml') + expected_image='hello-world-js-js-css-xml') # Rollback all the changes - ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) - ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_CSS, sleep=3) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) strings = ['Successfully transferred app.css', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) - ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_XML, sleep=3) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Changes in App_Resources should rebuild native project - res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'AndroidManifest.xml') + res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') File.replace(res_path, '17', '19') strings = ['Preparing project', 'Building project', 'Gradle build', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') def test_100_tns_run_android_release(self): """Make valid changes in JS,CSS and HTML""" # `tns run android --release` and wait until app is deployed # IMPORTANT NOTE: `tns run android --release` Do NOT livesync by design! + copy = os.path.join(TEST_RUN_HOME,'data', 'folders', 'main-page.js') + paste = os.path.join(self.app_name, 'app') + Folder.copy(copy, paste) Device.uninstall_app(app_prefix="org.nativescript", platform=Platform.ANDROID) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, @@ -178,15 +165,15 @@ def test_100_tns_run_android_release(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, - device_id=EMULATOR_ID, expected_image='livesync-hello-world_home') + device_id=EMULATOR_ID, expected_image='hello-world-js') # Kills `tns run android --release` Tns.kill() # Replace files - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS) - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML) # Run `tns run android --release` again and make sure changes above are applied log = Tns.run_android(attributes={'--path': self.app_name, @@ -208,7 +195,7 @@ def test_100_tns_run_android_release(self): # Verify app looks is update after changes in js, css and xml Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_js_css_xml') + expected_image='hello-world-js-js-css-xml') def test_180_tns_run_android_console_logging(self): """ @@ -242,8 +229,7 @@ def test_180_tns_run_android_console_logging(self): "Assertion failed: false == true", "Assertion failed: empty string evaluates to 'false'", "Trace: console.trace() called", - "at pageLoaded", - "Button(8)", + "Button(", "-1 text {", "[1, 5, 12.5, {", "\"name\": \"John\",", "\"age\": 34", @@ -384,7 +370,9 @@ def test_200_tns_run_android_break_and_fix_app(self): Make changes in xml that break the app and then changes that fix the app. Add/remove js files that break the app and then fix it. """ - + copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') + paste = os.path.join(self.app_name, 'app') + Folder.copy(copy, paste) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False, assert_success=False) strings = ['Project successfully prepared', 'Project successfully built', @@ -393,10 +381,10 @@ def test_200_tns_run_android_break_and_fix_app(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Break the app with invalid xml changes - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML_INVALID_SYNTAX) # Verify console notify user for broken xml strings = ['main-page.xml has syntax errors', 'unclosed xml attribute', @@ -405,13 +393,13 @@ def test_200_tns_run_android_break_and_fix_app(self): 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) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML_INVALID_SYNTAX) strings = ['Successfully transferred main-page.xml', '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='livesync-hello-world_home') + expected_image='hello-world-js') # Delete app.js and verify app crash with error activiry dialog app_js_original_path = os.path.join(self.app_name, 'app', 'app.js') @@ -430,7 +418,7 @@ def test_200_tns_run_android_break_and_fix_app(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') def test_210_run_android_add_remove_files_and_folders(self): """ @@ -445,7 +433,7 @@ def test_210_run_android_add_remove_files_and_folders(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Add new files new_file_name = 'main-page2.xml' @@ -473,7 +461,7 @@ def test_210_run_android_add_remove_files_and_folders(self): # Add folder new_folder_name = 'test2' - source_file = os.path.join(self.app_name, 'app', 'test') + source_file = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'test') destination_file = os.path.join(self.app_name, 'app', new_folder_name) Folder.copy(source_file, destination_file) strings = ['Successfully transferred test.txt', EMULATOR_ID] @@ -498,7 +486,7 @@ def test_210_run_android_add_remove_files_and_folders(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') @unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.") def test_290_tns_run_android_should_refresh_images(self): @@ -538,7 +526,7 @@ def test_300_tns_run_android_just_launch_and_incremental_builds(self): # Execute `tns run android --path TNS_App --justlaunch` and verify app looks correct on emulator Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--justlaunch': ''}) Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Execute `tns run android --path TNS_App --justlaunch` again # without any changes on app under test and verify incremental prepare works @@ -548,12 +536,12 @@ def test_300_tns_run_android_just_launch_and_incremental_builds(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Replace JS, XML and CSS files - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS) - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML) # Run `tns run android` after file changes (this should trigger incremental prepare). output = Tns.run_android(attributes={'--path': self.app_name, '--justlaunch': ''}, assert_success=False) @@ -562,7 +550,7 @@ def test_300_tns_run_android_just_launch_and_incremental_builds(self): # Verify app looks is update after changes in js, css and xml Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_js_css_xml') + expected_image='hello-world-js-js-css-xml') def test_310_tns_run_android_clean_builds(self): """ @@ -581,7 +569,7 @@ def test_310_tns_run_android_clean_builds(self): Device.wait_for_text(device_id=EMULATOR_ID, text='42 taps left') # Verify if changes are applied and then build with `--clean` it will apply changes on attached device - ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS) + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--justlaunch': '', '--clean': ''}) assert 'Skipping prepare' not in log, "Prepare skipped when change files and run `tns run android --clean`" @@ -590,7 +578,7 @@ def test_310_tns_run_android_clean_builds(self): Device.wait_for_text(device_id=EMULATOR_ID, text='52 taps left') # Verify if changes are applied and then build with `--clean` it will apply changes on attached device - ReplaceHelper.rollback(self.app_name, ReplaceHelper.CHANGE_JS) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--justlaunch': '', '--clean': ''}) assert 'Skipping prepare' not in log @@ -618,6 +606,9 @@ def test_320_tns_run_android_no_watch(self): """ # `tns run android --no-watch` and wait until app is deployed + copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') + paste = os.path.join(self.app_name, 'app') + Folder.copy(copy, paste) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--no-watch': ''}, wait=False, assert_success=False) strings = ['Successfully installed on device with identifier', @@ -647,20 +638,23 @@ def test_330_tns_run_android_sync_all_files(self): """ Verify '--syncAllFiles' option will sync all files, including node modules. """ + copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') + paste = os.path.join(self.app_name, 'app') + Folder.copy(copy, paste) Tns.build_android(attributes={'--path': self.app_name}) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--syncAllFiles': ''}, wait=False, assert_success=False) strings = ['Successfully synced application', EMULATOR_ID, 'JS:'] Tns.wait_for_log(log_file=log, string_list=strings, timeout=60, check_interval=10) - ReplaceHelper.replace(app_name=self.app_name, file_change=ReplaceHelper.CHANGE_TNS_MODULES) + LivesyncHelper.replace(app_name=self.app_name, file_change=LivesyncHelper.CHANGE_TNS_MODULES) strings = ['Successfully transferred application-common.js', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') @unittest.skipIf(CURRENT_OS == OSType.WINDOWS, "Delete log during livesync not possible on Windows.") def test_340_tns_run_should_not_sync_hidden_files(self): @@ -676,7 +670,7 @@ def test_340_tns_run_should_not_sync_hidden_files(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') # Clean log (this will not work on windows since file is locked) File.write(file_path=log, text="") @@ -709,7 +703,7 @@ def test_340_tns_run_should_not_sync_hidden_files(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') def test_350_tns_run_android_should_start_emulator(self): """ @@ -726,7 +720,7 @@ def test_350_tns_run_android_should_start_emulator(self): Emulator.ensure_available() else: raise nose.SkipTest('This test is not valid when devices are connected.') - + # def test_355_tns_run_android_changes_in_app_resources_rebuild_app(self): """ https://github.com/NativeScript/nativescript-cli/issues/3658 @@ -788,7 +782,7 @@ def test_360_tns_run_android_with_jar_file_in_plugin(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self): """ @@ -823,7 +817,7 @@ def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') def test_380_tns_run_android_livesync_aar_file_changes(self): """ @@ -842,7 +836,7 @@ def test_380_tns_run_android_livesync_aar_file_changes(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') copy_aar = os.path.join(TEST_RUN_HOME, 'data', 'plugins', 'TNSListView-release.aar') paste_aar = os.path.join(self.app_name, 'node_modules', 'nativescript-camera', 'platforms', 'android') @@ -855,7 +849,7 @@ def test_380_tns_run_android_livesync_aar_file_changes(self): # Verify app looks correct inside emulator Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='livesync-hello-world_home') + expected_image='hello-world-js') @unittest.skip("Skip because of https://github.com/NativeScript/nativescript-cli/issues/2825") def test_390_tns_run_android_should_warn_if_package_ids_do_not_match(self): diff --git a/tests/helpers/livesync_helper.py b/tests/helpers/livesync_helper.py new file mode 100644 index 00000000..f869338d --- /dev/null +++ b/tests/helpers/livesync_helper.py @@ -0,0 +1,45 @@ +import time + +from core.osutils.file import File + + +class LivesyncHelper(object): + CHANGE_XML = ['app/main-page.xml', 'TAP', 'TEST'] + CHANGE_JS = ['app/main-view-model.js', 'taps', 'clicks'] + CHANGE_CSS = ['app/app.css', '18', '32'] + CHANGE_LICENSE = ['node_modules/tns-core-modules/LICENSE', 'Copyright', 'MyCopyright'] + CHANGE_TNS_MODULES = ['node_modules/tns-core-modules/application/application-common.js', + '(\"globals\");', + '(\"globals\"); // test'] + + CHANGE_XML_INVALID_SYNTAX = ['app/main-page.xml', '', ' Date: Mon, 27 Aug 2018 15:57:57 +0300 Subject: [PATCH 2/8] windows rewrite --- tests/emulator/run_android_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index fbc88603..0d1adb07 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -120,11 +120,11 @@ def test_001_tns_run_android_js_css_xml_manifest(self): strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) - LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) strings = ['Successfully transferred app.css', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) + Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) - LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] Tns.wait_for_log(log_file=log, string_list=strings) From af611568a5246586f3a301f72cfdf2f79ae2f8e0 Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Mon, 27 Aug 2018 16:54:23 +0300 Subject: [PATCH 3/8] windows test --- tests/emulator/run_android_tests.py | 128 ++++++++++++++-------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index 0d1adb07..4d9b5609 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -77,70 +77,70 @@ def tearDownClass(cls): Emulator.stop() # We need this because of test_400_tns_run_android_respect_adb_errors Folder.cleanup(cls.temp_app) - def test_001_tns_run_android_js_css_xml_manifest(self): - """Make valid changes in JS,CSS and XML""" - - # `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) - 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) - - # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') - - # Change JS and wait until app is synced - LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) - 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).' - - # Change XML and wait until app is synced - LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) - strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) - 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).' - - # Change CSS and wait until app is synced - LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) - strings = ['Successfully transferred app.css', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) - - # Verify application looks correct - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js-js-css-xml') - - # Rollback all the changes - LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) - - LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) - strings = ['Successfully transferred app.css', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) - - LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) - strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings) - - # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') - - # Changes in App_Resources should rebuild native project - res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') - File.replace(res_path, '17', '19') - strings = ['Preparing project', 'Building project', 'Gradle build', 'Successfully synced application'] - Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) - - # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') + # def test_001_tns_run_android_js_css_xml_manifest(self): + # """Make valid changes in JS,CSS and XML""" + # + # # `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) + # 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) + # + # # Verify app looks correct inside emulator + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') + # + # # Change JS and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # 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).' + # + # # Change XML and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) + # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # 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).' + # + # # Change CSS and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) + # strings = ['Successfully transferred app.css', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # # Verify application looks correct + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js-js-css-xml') + # + # # Rollback all the changes + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) + # strings = ['Successfully transferred app.css', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) + # + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) + # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # # Verify app looks correct inside emulator + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') + # + # # Changes in App_Resources should rebuild native project + # res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') + # File.replace(res_path, '17', '19') + # strings = ['Preparing project', 'Building project', 'Gradle build', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) + # + # # Verify app looks correct inside emulator + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') def test_100_tns_run_android_release(self): """Make valid changes in JS,CSS and HTML""" From c36f2d5865b345765fe67894afc83df792adc3ac Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Tue, 28 Aug 2018 09:26:14 +0300 Subject: [PATCH 4/8] windows tests --- tests/emulator/run_android_tests.py | 128 ++++++++++++++-------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index 4d9b5609..f58433b7 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -77,70 +77,70 @@ def tearDownClass(cls): Emulator.stop() # We need this because of test_400_tns_run_android_respect_adb_errors Folder.cleanup(cls.temp_app) - # def test_001_tns_run_android_js_css_xml_manifest(self): - # """Make valid changes in JS,CSS and XML""" - # - # # `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) - # 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) - # - # # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') - # - # # Change JS and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # 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).' - # - # # Change XML and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) - # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # 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).' - # - # # Change CSS and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) - # strings = ['Successfully transferred app.css', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # # Verify application looks correct - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js-js-css-xml') - # - # # Rollback all the changes - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) - # strings = ['Successfully transferred app.css', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) - # - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) - # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') - # - # # Changes in App_Resources should rebuild native project - # res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') - # File.replace(res_path, '17', '19') - # strings = ['Preparing project', 'Building project', 'Gradle build', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) - # - # # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') + def test_001_tns_run_android_js_css_xml_manifest(self): + """Make valid changes in JS,CSS and XML""" + + # `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) + 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) + + # Verify app looks correct inside emulator + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') + + # # Change JS and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # 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).' + # + # # Change XML and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) + # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # 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).' + # + # # Change CSS and wait until app is synced + # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) + # strings = ['Successfully transferred app.css', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # # Verify application looks correct + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js-js-css-xml') + # + # # Rollback all the changes + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) + # strings = ['Successfully transferred app.css', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) + # + # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) + # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + # Tns.wait_for_log(log_file=log, string_list=strings) + # + # # Verify app looks correct inside emulator + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') + + # Changes in App_Resources should rebuild native project + res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') + File.replace(res_path, '17', '19') + strings = ['Preparing project', 'Building project', 'Gradle build', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) + + # Verify app looks correct inside emulator + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') def test_100_tns_run_android_release(self): """Make valid changes in JS,CSS and HTML""" From 5cab0ee6d71bbd874d038ac5fb87d97e3fe9fa34 Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Wed, 29 Aug 2018 16:44:13 +0300 Subject: [PATCH 5/8] windows tests --- tests/emulator/run_android_tests.py | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index f58433b7..a28e80bb 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -89,46 +89,46 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') + + # Change JS and wait until app is synced + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings) + 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).' - # # Change JS and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # 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).' - # - # # Change XML and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) - # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # 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).' - # - # # Change CSS and wait until app is synced - # LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) - # strings = ['Successfully transferred app.css', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # # Verify application looks correct + # Change XML and wait until app is synced + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_XML, sleep=3) + strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings) + 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).' + + # Change CSS and wait until app is synced + LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=3) + strings = ['Successfully transferred app.css', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings) + + # Verify application looks correct # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, # expected_image='hello-world-js-js-css-xml') - # - # # Rollback all the changes - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) - # strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) - # strings = ['Successfully transferred app.css', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) - # - # LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) - # strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] - # Tns.wait_for_log(log_file=log, string_list=strings) - # - # # Verify app looks correct inside emulator + + # Rollback all the changes + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) + strings = ['Successfully transferred main-view-model.js', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings) + + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_CSS, sleep=10) + strings = ['Successfully transferred app.css', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings, timeout=180) + + LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_XML, sleep=10) + strings = ['Successfully transferred main-page.xml', 'Successfully synced application'] + Tns.wait_for_log(log_file=log, string_list=strings) + + # Verify app looks correct inside emulator # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, # expected_image='hello-world-js') @@ -139,8 +139,8 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) # Verify app looks correct inside emulator - Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - expected_image='hello-world-js') + # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + # expected_image='hello-world-js') def test_100_tns_run_android_release(self): """Make valid changes in JS,CSS and HTML""" From e68cb33eee42def4322ada1b4ff77ac4936738dd Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Wed, 29 Aug 2018 16:54:35 +0300 Subject: [PATCH 6/8] windows tests --- tests/emulator/run_android_tests.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index a28e80bb..17af0812 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -77,6 +77,7 @@ def tearDownClass(cls): Emulator.stop() # We need this because of test_400_tns_run_android_respect_adb_errors Folder.cleanup(cls.temp_app) + @unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.") def test_001_tns_run_android_js_css_xml_manifest(self): """Make valid changes in JS,CSS and XML""" @@ -89,8 +90,8 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10) # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') # Change JS and wait until app is synced LivesyncHelper.replace(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) @@ -112,8 +113,8 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings) # Verify application looks correct - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js-js-css-xml') + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js-js-css-xml') # Rollback all the changes LivesyncHelper.rollback(self.app_name, LivesyncHelper.CHANGE_JS, sleep=10) @@ -129,8 +130,8 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings) # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') # Changes in App_Resources should rebuild native project res_path = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml') @@ -139,8 +140,8 @@ def test_001_tns_run_android_js_css_xml_manifest(self): Tns.wait_for_log(log_file=log, string_list=strings, timeout=60) # Verify app looks correct inside emulator - # Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, - # expected_image='hello-world-js') + Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID, + expected_image='hello-world-js') def test_100_tns_run_android_release(self): """Make valid changes in JS,CSS and HTML""" From bad587de005d2eb9570bed8651fb3ad07302d011 Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Thu, 13 Sep 2018 17:32:02 +0300 Subject: [PATCH 7/8] windows --- tests/emulator/run_android_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index 17af0812..f5172037 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -150,7 +150,7 @@ def test_100_tns_run_android_release(self): # IMPORTANT NOTE: `tns run android --release` Do NOT livesync by design! copy = os.path.join(TEST_RUN_HOME,'data', 'folders', 'main-page.js') paste = os.path.join(self.app_name, 'app') - Folder.copy(copy, paste) + File.copy(copy, paste) Device.uninstall_app(app_prefix="org.nativescript", platform=Platform.ANDROID) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, From c026b1d74860ba22cce3449ac1690ee9b16c7c61 Mon Sep 17 00:00:00 2001 From: Miroslava Ivanova Date: Fri, 14 Sep 2018 16:25:39 +0300 Subject: [PATCH 8/8] change file --- tests/emulator/run_android_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/emulator/run_android_tests.py b/tests/emulator/run_android_tests.py index f5172037..148d72d4 100644 --- a/tests/emulator/run_android_tests.py +++ b/tests/emulator/run_android_tests.py @@ -373,7 +373,7 @@ def test_200_tns_run_android_break_and_fix_app(self): """ copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') paste = os.path.join(self.app_name, 'app') - Folder.copy(copy, paste) + File.copy(copy, paste) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False, assert_success=False) strings = ['Project successfully prepared', 'Project successfully built', @@ -609,7 +609,7 @@ def test_320_tns_run_android_no_watch(self): # `tns run android --no-watch` and wait until app is deployed copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') paste = os.path.join(self.app_name, 'app') - Folder.copy(copy, paste) + File.copy(copy, paste) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--no-watch': ''}, wait=False, assert_success=False) strings = ['Successfully installed on device with identifier', @@ -641,7 +641,7 @@ def test_330_tns_run_android_sync_all_files(self): """ copy = os.path.join(TEST_RUN_HOME, 'data', 'folders', 'main-page.js') paste = os.path.join(self.app_name, 'app') - Folder.copy(copy, paste) + File.copy(copy, paste) Tns.build_android(attributes={'--path': self.app_name}) log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--syncAllFiles': ''}, wait=False, assert_success=False)