Example #1
0
    def test_310_tns_run_ios_sync_changes_in_node_modules(self):
        """
        Verify changes in node_modules are synced during run command
        """
        # Run the project
        result = run_hello_world_js_ts(self.app_name, Platform.IOS, self.sim, sync_all_files=True)

        # Make code changes in tns-core-modules verify livesync is triggered
        Sync.replace(self.app_name, Changes.NodeModules.TNS_MODULES)
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.INCREMENTAL, device=self.emu, file_name='application-common.js')
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
Example #2
0
    def test_365_tns_run_android_should_respect_adb_errors(self):
        """
        If device memory is full and error is thrown during deploy cli should respect it
        https://github.com/NativeScript/nativescript-cli/issues/2170
        """
        # Deploy the app to make sure we have something at /data/data/org.nativescript.TestApp
        run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu, just_launch=True)

        # Use all the disk space on emulator
        dest_file = '/data/data/' + TnsPaths.get_bundle_id(self.app_name)
        for index in range(1, 3000):
            command = "shell 'su 0 cp -r {0} {0}{1}'".format(dest_file, str(index))
            result = Adb.run_adb_command(device_id=self.emu.id, command=command)
            Log.info(result.output)
            if "No space left on device" in result.output:
                break

        # Create new app
        Tns.create(app_name='TestApp2', template=Template.HELLO_WORLD_JS.local_package, update=True)

        # Run the app and verify there is appropriate error
        result = Tns.run_android('TestApp2', verify=True, device=self.emu.id, just_launch=True)
        strings = ['No space left on device']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)
Example #3
0
    def test_315_tns_run_android_sync_changes_in_aar_files(self):
        """
        Livesync should sync aar file changes inside a plugin
        https://github.com/NativeScript/nativescript-cli/issues/3610
        """
        # Add plugin and run the project
        Tns.plugin_add('nativescript-camera', self.app_name)
        result = run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu)

        # Make  changes in nativescript-camera .aar file and  verify livesync is triggered
        new_aar = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'issues', 'nativescript-cli-3932',
                               'nativescript-ui-listview', 'platforms', 'android', 'TNSListView-release.aar')
        target_aar = os.path.join(self.app_name, 'node_modules', 'nativescript-camera', 'platforms', 'android')
        File.copy(new_aar, target_aar)
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.UNKNOWN, device=self.emu)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
Example #4
0
    def test_105_tns_run_android_changes_in_app_resounces(self):
        """
            Make changes in AndroidManifest.xml in App_Resources and verify this triggers rebuild of the app.
            Verify that when run on android changes in AppResources/iOS do not trigger rebuild
        """
        # Run app and verify on device
        result = run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu)

        # Make changes in AndroidManifest.xml
        manifest_path = os.path.join(self.app_resources_android, 'src', 'main', 'AndroidManifest.xml')
        File.replace(manifest_path, 'largeScreens="true"', 'largeScreens="false"')

        # Verify rebuild is triggered and app is synced
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.UNKNOWN, device=self.emu)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)

        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
        self.emu.wait_for_text(text=Changes.JSHelloWord.XML.old_text)

        # Make changes in AppResources/Android
        File.copy(os.path.join(Settings.TEST_RUN_HOME, 'assets', 'resources', 'android', 'drawable-hdpi', 'icon.png'),
                  os.path.join(self.app_resources_android, 'src', 'main', 'res', 'drawable-hdpi', 'icon.png'))
        # Verify only build for android is triggered
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.UNKNOWN, device=self.emu)
        not_existing_strings = ['Xcode build']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
                             not_existing_string_list=not_existing_strings, timeout=120)

        # https://github.com/NativeScript/nativescript-cli/issues/3658
        Tns.kill()
        # Make changes in AppResources/iOS
        File.copy(os.path.join('assets', 'resources', 'ios', 'Default.png'),
                  os.path.join(self.app_resources_ios, 'Assets.xcassets', 'LaunchScreen.Center.imageset',
                               'Default.png'))
        result = Tns.run_android(app_name=self.app_name, device=self.emu.id)
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.UNKNOWN, device=self.emu)
        # Verify no build is triggered
        not_existing_strings = ['Xcode build', 'Gradle build']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
                             not_existing_string_list=not_existing_strings)
Example #5
0
    def test_100_run_ios_break_and_fix_app(self):
        """
            Make changes in xml that break the app and then changes thet fix the app.
            Add/remove js files thst break the app and then fix it. Verify recovery.
        """
        # Run app and verify on device
        result = run_hello_world_js_ts(self.app_name, Platform.IOS, self.sim)

        # Make changes in xml that will break the app
        Sync.replace(self.app_name, Changes.JSHelloWord.XML_INVALID)
        strings = ['main-page.xml', 'Error: Building UI from XML']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)

        # Revert changes
        Sync.revert(self.app_name, Changes.JSHelloWord.XML_INVALID)

        # Verify app is synced and recovered
        strings = ['Successfully synced application']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.sim.wait_for_text(text=Changes.JSHelloWord.XML.old_text)
Example #6
0
    def test_100_run_android_break_and_fix_app(self):
        """
            Make changes in xml that break the app and then changes thet fix the app.
            Add/remove js files thst break the app and then fix it. Verify recovery.
        """
        # Run app and verify on device
        result = run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu)

        # Make changes in xml that will break the app
        Sync.replace(self.app_name, Changes.JSHelloWord.XML_INVALID)
        strings = ['main-page.xml', 'Error: Building UI from XML']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text='Exception')

        # Revert changes
        Sync.revert(self.app_name, Changes.JSHelloWord.XML_INVALID)

        # Verify app is synced and recovered
        strings = ['Successfully synced application']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
        assert not self.emu.is_text_visible(text='Exception')

        # Delete app.js and verify app crash with error activity dialog
        app_js_origin_path = os.path.join(self.source_project_dir, 'app', 'app.js')
        app_js_backup_path = os.path.join(self.target_project_dir, 'app', 'app.js')
        File.delete(app_js_origin_path)

        # Verify app is synced
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       device=self.emu, run_type=RunType.UNKNOWN)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text='Exception')

        # Restore app.js and verify app is synced and recovered
        File.copy(app_js_backup_path, app_js_origin_path)
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.ANDROID,
                                       run_type=RunType.UNKNOWN, device=self.emu)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
        assert not self.emu.is_text_visible(text='Exception')
Example #7
0
    def test_105_tns_run_ios_changes_in_app_resounces(self):
        """
            Make changes in AndroidManifest.xml in App_Resources and verify this triggers rebuild of the app.
            Verify that when run on android changes in AppResources/iOS do not trigger rebuild
        """
        # Run app and verify on device
        result = run_hello_world_js_ts(self.app_name, Platform.IOS, self.sim)

        # Make changes in app resources, add aditional icon
        File.copy(os.path.join(Settings.TEST_RUN_HOME, 'assets', 'resources', 'ios', 'Default.png'),
                  os.path.join(self.app_resources_ios, 'Assets.xcassets', 'icon.png'))

        # Verify rebuild is triggered and app is synced
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.IOS,
                                       run_type=RunType.UNKNOWN, device=self.sim)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
        self.sim.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
        self.sim.wait_for_text(text=Changes.JSHelloWord.XML.old_text)

        # Make changes in AppResources/IOS
        File.copy(os.path.join(os.path.join(Settings.TEST_RUN_HOME, 'assets', 'resources', 'ios', 'Default.png')),
                  os.path.join(self.app_resources_ios, 'Assets.xcassets', 'AppIcon.appiconset', 'icon-20.png'))
        # Verify only build for ios is triggered
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.IOS,
                                       run_type=RunType.UNKNOWN, device=self.sim)
        not_existing_strings = ['Gradle build']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
                             not_existing_string_list=not_existing_strings)

        # https://github.com/NativeScript/nativescript-cli/issues/3658
        Tns.kill()
        # Make changes in AppResources/Android
        File.copy(os.path.join(Settings.TEST_RUN_HOME, 'assets', 'resources', 'android', 'drawable-hdpi', 'icon.png'),
                  os.path.join(self.app_resources_android, 'src', 'main', 'res', 'drawable-hdpi', 'icon.png'))
        result = Tns.run_ios(app_name=self.app_name, emulator=True, provision=False)
        strings = TnsLogs.run_messages(app_name=self.app_name, platform=Platform.IOS,
                                       run_type=RunType.UNKNOWN, device=self.sim)
        # Verify no build is triggered
        not_existing_strings = ['Xcode build', 'Gradle build']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
                             not_existing_string_list=not_existing_strings)
Example #8
0
 def test_315_run_android_release_snapshot_uglify(self):
     run_hello_world_js_ts(self.app_name, Platform.ANDROID, self.emu, uglify=True, snapshot=True,
                           release=True)
Example #9
0
 def test_361_tns_run_ios_on_folder_with_spaces(self):
     """
     `tns run ios` for apps with spaces
     """
     run_hello_world_js_ts(self.normalized_app_name_space, Platform.IOS, self.sim, just_launch=True)
Example #10
0
 def test_360_tns_run_android_on_folder_with_spaces(self):
     """
     `tns run android` for apps with spaces
     """
     run_hello_world_js_ts(self.normalized_app_name_space, Platform.ANDROID, self.emu, just_launch=True)