示例#1
0
    def test_002_android_run_hmr_uninstall_app(self):
        log = Tns.run_android(attributes={
            '--path': self.app_name,
            '--device': EMULATOR_ID,
            '--hmr': ''
        },
                              wait=False,
                              assert_success=False)

        Tns.wait_for_log(log_file=log,
                         string_list=HelpersHMR.run_hmr_with_platforms,
                         not_existing_string_list=HelpersHMR.errors_hmr,
                         timeout=240)
        Helpers.android_screen_match(image=HelpersHMR.image_original,
                                     timeout=120)

        HelpersHMR.apply_changes_js(app_name=self.app_name,
                                    log=log,
                                    platform=Platform.ANDROID)

        # Uninstall app while `tns run` is running
        Device.uninstall_app(app_prefix='org.nativescript.',
                             platform=Platform.ANDROID)

        ReplaceHelper.rollback(self.app_name, HelpersHMR.js_change, sleep=10)
        strings = [
            'Restarting application on device',
            'HMR: Hot Module Replacement Enabled. Waiting for signal.'
        ]
        Tns.wait_for_log(log_file=log, string_list=strings)

        Helpers.android_screen_match(image=HelpersHMR.image_original,
                                     timeout=120)
    def test_400_tns_run_ios_should_not_crash_when_uninstall_app(self):
        """
        `tns run ios` should work properly even if I manually uninstall the app (test for issue #3007)
        """

        # `tns run ios` and wait until app is deployed
        log = Tns.run_ios(attributes={'--path': self.app_name, "--device": self.DEVICE_ID}, wait=False,
                          assert_success=False)
        strings = [self.DEVICE_ID, 'Successfully synced application']
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)

        # Verify app is running
        assert Device.wait_for_text(device_id=self.DEVICE_ID, text="taps left"), "App failed to load!"
        assert Device.wait_for_text(device_id=self.DEVICE_ID, text="TAP"), "App failed to load!"

        # Change JS and wait until app is synced
        ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=3)
        strings = ['Successfully transferred', 'main-view-model.js', 'Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)
        assert Device.wait_for_text(device_id=self.DEVICE_ID, text="clicks"), "JS changes not synced on device!"

        # Uninstall app while `tns run` is running
        Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.IOS)
        sleep(10)

        # Change XML and wait until app is synced
        Tns.wait_for_log(log_file=log, string_list=[], timeout=30)  # Just to cleanup log file
        ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=10)
        strings = ['Successfully installed', 'Successfully synced application']
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
        assert Device.wait_for_text(device_id=self.DEVICE_ID, text="TEST"), "XML changes not synced on device!"
 def setUpClass(cls):
     BaseClass.setUpClass(cls.__name__)
     Emulator.stop()
     Device.ensure_available(platform=Platform.ANDROID)
     Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
     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})
示例#4
0
    def setUpClass(cls):
        BaseClass.setUpClass(cls.__name__)
        Emulator.stop()
        Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
        Emulator.ensure_available()
        Folder.cleanup(cls.app_name)

        # Create default NG app (to get right dependencies from package.json)
        Tns.create_app_ng(cls.app_name)
        Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE}) 
示例#5
0
    def test_400_tns_run_ios_should_not_crash_when_uninstall_app(self):
        """
        `tns run ios` should work properly even if I manually uninstall the app (test for issue #3007)
        """

        # `tns run ios` and wait until app is deployed
        log = Tns.run_ios(attributes={
            '--path': self.app_name,
            "--device": self.DEVICE_ID
        },
                          wait=False,
                          assert_success=False)
        strings = [self.DEVICE_ID, 'Successfully synced application']
        Tns.wait_for_log(log_file=log,
                         string_list=strings,
                         timeout=180,
                         check_interval=10)

        # Verify app is running
        assert Device.wait_for_text(device_id=self.DEVICE_ID,
                                    text="taps left"), "App failed to load!"
        assert Device.wait_for_text(device_id=self.DEVICE_ID,
                                    text="TAP"), "App failed to load!"

        # Change JS and wait until app is synced
        ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=3)
        strings = [
            'Successfully transferred', 'main-view-model.js',
            'Successfully synced application', self.DEVICE_ID
        ]
        Tns.wait_for_log(log_file=log, string_list=strings)
        assert Device.wait_for_text(
            device_id=self.DEVICE_ID,
            text="clicks"), "JS changes not synced on device!"

        # Uninstall app while `tns run` is running
        Device.uninstall_app(app_prefix='org.nativescript.',
                             platform=Platform.IOS)
        sleep(10)

        # Change XML and wait until app is synced
        Tns.wait_for_log(log_file=log, string_list=[],
                         timeout=30)  # Just to cleanup log file
        ReplaceHelper.replace(self.app_name,
                              ReplaceHelper.CHANGE_XML,
                              sleep=10)
        strings = ['Successfully installed', 'Successfully synced application']
        Tns.wait_for_log(log_file=log,
                         string_list=strings,
                         timeout=180,
                         check_interval=10)
        assert Device.wait_for_text(
            device_id=self.DEVICE_ID,
            text="TEST"), "XML changes not synced on device!"
    def setUpClass(cls):
        BaseClass.setUpClass(cls.__name__)
        Emulator.stop()
        Simulator.stop()
        Device.ensure_available(platform=Platform.IOS)
        Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.IOS)

        Folder.cleanup(cls.app_name)
        Tns.create_app(cls.app_name,
                       attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')},
                       update_modules=True)
        Folder.copy(src=os.path.join(cls.app_name, 'app'), dst=cls.TEMP_FOLDER)
        Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE})
 def setUpClass(cls):
     BaseClass.setUpClass(cls.__name__)
     Tns.kill()
     Emulator.stop()
     Emulator.ensure_available()
     Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
     if CURRENT_OS != OSType.WINDOWS:
         Tns.create_app(cls.app_name,
                        attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')},
                        update_modules=True)
         Tns.platform_add_android(attributes={'--path': cls.app_name, '--frameworkPath': ANDROID_PACKAGE})
         Folder.cleanup(cls.temp_app)
         Folder.copy(cls.source_app, cls.temp_app)
    def test_002_android_run_hmr_uninstall_app(self):
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False,
                        assert_success=False)

        Tns.wait_for_log(log_file=log, string_list=HelpersHMR.run_hmr_with_platforms, not_existing_string_list=HelpersHMR.errors_hmr,
                         timeout=240)
        Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120)

        HelpersHMR.apply_changes_js(app_name=self.app_name, log=log, platform=Platform.ANDROID)

        # Uninstall app while `tns run` is running
        Device.uninstall_app(app_prefix='org.nativescript.', platform=Platform.ANDROID)

        ReplaceHelper.rollback(self.app_name, HelpersHMR.js_change, sleep=10)
        strings = ['Restarting application on device', 'HMR: Hot Module Replacement Enabled. Waiting for signal.']
        Tns.wait_for_log(log_file=log, string_list=strings)

        Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120)
示例#9
0
 def setUpClass(cls):
     BaseClass.setUpClass(cls.__name__)
     Tns.kill()
     Emulator.stop()
     Emulator.ensure_available()
     Device.uninstall_app(app_prefix="org.nativescript.",
                          platform=Platform.ANDROID)
     if CURRENT_OS != OSType.WINDOWS:
         Tns.create_app(cls.app_name,
                        attributes={
                            '--template':
                            os.path.join('data', 'apps',
                                         'livesync-hello-world.tgz')
                        },
                        update_modules=True)
         Tns.platform_add_android(attributes={
             '--path': cls.app_name,
             '--frameworkPath': ANDROID_PACKAGE
         })
         Folder.cleanup(cls.temp_app)
         Folder.copy(cls.source_app, cls.temp_app)
示例#10
0
    def setUpClass(cls):
        BaseClass.setUpClass(cls.__name__)
        Emulator.stop()
        Simulator.stop()
        Device.ensure_available(platform=Platform.IOS)
        Device.uninstall_app(app_prefix='org.nativescript.',
                             platform=Platform.IOS)

        Folder.cleanup(cls.app_name)
        Tns.create_app(cls.app_name,
                       attributes={
                           '--template':
                           os.path.join('data', 'apps',
                                        'livesync-hello-world.tgz')
                       },
                       update_modules=True)
        Folder.copy(src=os.path.join(cls.app_name, 'app'), dst=cls.TEMP_FOLDER)
        Tns.platform_add_ios(attributes={
            '--path': cls.app_name,
            '--frameworkPath': IOS_PACKAGE
        })
示例#11
0
    # Copy test packages and cleanup
    if CURRENT_OS == OSType.OSX:
        Simulator.stop()
        disable_crash_report()
        get_test_packages(platform=Platform.BOTH)
        Simulator.reset()

        if Xcode.get_version() < 10:
            SIMULATOR_SDK = '11.0'
        if Xcode.get_version() < 9:
            SIMULATOR_SDK = '10.0'

        Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK)
        Xcode.cleanup_cache()  # Clean Xcode cache folders
        Device.uninstall_app(app_prefix="org.nativescript.",
                             platform=Platform.ANDROID)
        Device.uninstall_app(app_prefix="org.nativescript.",
                             platform=Platform.IOS)
    else:
        get_test_packages(platform=Platform.ANDROID)

    # Install CLI
    Cli.install()
    Tns.disable_reporting()

    # Add local CLI to PATH
    if CURRENT_OS != OSType.WINDOWS:
        base_path = os.path.join(TEST_RUN_HOME, 'node_modules', 'nativescript',
                                 'bin')
        where_command = 'which tns'
    else:
    # Copy test packages and cleanup
    if CURRENT_OS == OSType.OSX:
        Simulator.stop()
        disable_crash_report()
        get_test_packages(platform=Platform.BOTH)
        Simulator.reset()

        if Xcode.get_version() < 10:
            SIMULATOR_SDK = '11.0'
        if Xcode.get_version() < 9:
            SIMULATOR_SDK = '10.0'
        

        Simulator.create(SIMULATOR_NAME, SIMULATOR_TYPE, SIMULATOR_SDK)
        Xcode.cleanup_cache()  # Clean Xcode cache folders
        Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.ANDROID)
        Device.uninstall_app(app_prefix="org.nativescript.", platform=Platform.IOS)
    else:
        get_test_packages(platform=Platform.ANDROID)

    # Install CLI
    Cli.install()
    Tns.disable_reporting()

    # Add local CLI to PATH
    if CURRENT_OS != OSType.WINDOWS:
        base_path = os.path.join(TEST_RUN_HOME, 'node_modules', 'nativescript', 'bin')
        where_command = 'which tns'
    else:
        base_path = os.path.join(TEST_RUN_HOME, 'node_modules', '.bin')
        where_command = 'where tns'