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..148d72d4 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,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.skip('temp') + @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""" @@ -106,63 +91,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=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) - ReplaceHelper.rollback(self.app_name, ReplaceHelper.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) # 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') + 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, @@ -178,15 +166,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 +196,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 +230,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 +371,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') + 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', @@ -393,10 +382,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 +394,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 +419,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 +434,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 +462,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 +487,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 +527,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 +537,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 +551,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 +570,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 +579,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 +607,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') + 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', @@ -647,20 +639,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') + 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) 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 +671,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 +704,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 +721,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 +783,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 +818,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 +837,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 +850,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', '', '