当前位置: 首页>>代码示例>>Python>>正文


Python Tns.run_android方法代码示例

本文整理汇总了Python中core.tns.tns.Tns.run_android方法的典型用法代码示例。如果您正苦于以下问题:Python Tns.run_android方法的具体用法?Python Tns.run_android怎么用?Python Tns.run_android使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.tns.tns.Tns的用法示例。


在下文中一共展示了Tns.run_android方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_280_tns_run_android_console_time

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_280_tns_run_android_console_time(self):
        # Copy the app folder (app is modified in order to get some console logs on loaded)
        source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src')
        target = os.path.join(self.app_name, 'src')
        Folder.cleanup(target)
        Folder.copy(src=source, dst=target)

        # Replace app.component.ts to use console.time() and console.timeEnd()
        source = os.path.join('data', 'issues', 'ios-runtime-843', 'app.component.ts')
        target = os.path.join(self.app_name, 'src', 'app', 'app.component.ts')
        File.copy(src=source, dest=target)

        # `tns run android` and wait until app is deployed
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)

        # Verify the app is running
        strings = ['Successfully synced application',
                   'Application loaded!',
                   'Home page loaded!']

        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)

        # Verify initial state of the app
        Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
                            expected_image='ng-hello-world-home-white', tolerance=5.0)

        # Verify console.time() works
        console_time = ['JS: startup:']
        Tns.wait_for_log(log_file=log, string_list=console_time)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:32,代码来源:run_android_ng_tests.py

示例2: test_003_android_run_hmr_wrong_xml

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_003_android_run_hmr_wrong_xml(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,
                         not_existing_string_list=HelpersHMR.errors_hmr, timeout=240)

        # Verify app looks correct inside emulator
        Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
                            expected_image=HelpersHMR.image_original)

        # Break the app with invalid xml changes
        ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML_INVALID_SYNTAX)

        # Verify console notify user for broken xml
        # strings = ['for activity org.nativescript.TestApp / com.tns.ErrorReportActivity']
        strings = ['com.tns.NativeScriptException', 'Parsing XML at', 'Successfully synced application', EMULATOR_ID]
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)
        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)
        strings = ['JS: HMR: Hot Module Replacement Enabled. Waiting for signal.',
                   '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=HelpersHMR.image_original)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:30,代码来源:hello_world_js_hmr_android.py

示例3: test_200_tns_run_android_extending_class_inside_file_containing_dots

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_200_tns_run_android_extending_class_inside_file_containing_dots(self):
        """Test for https://github.com/NativeScript/android-runtime/issues/761"""

        # Copy the app folder (app is modified in order to get some console logs on loaded)
        source = os.path.join('data', 'apps', 'livesync-hello-world-ng', 'src')
        target = os.path.join(self.app_name, 'src')
        Folder.cleanup(target)
        Folder.copy(src=source, dst=target)
        
        source_html = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.html')
        target_html = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.html')
        File.copy(src=source_html, dest=target_html)

        source_ts = os.path.join('data', 'issues', 'android-runtime-761', 'items.component.ts')
        target_ts = os.path.join(self.app_name, 'src', 'app', 'item', 'items.component.ts')
        File.copy(src=source_ts, dest=target_ts)

        source_xml = os.path.join('data', 'issues', 'android-runtime-761', 'AndroidManifest.xml')
        target_xml = os.path.join(self.app_name, 'App_Resources', 'Android', 'src', 'main', 'AndroidManifest.xml')
        File.copy(src=source_xml, dest=target_xml)

        # Verify the app is running
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)
        strings = ['Project successfully built',
                   'Successfully installed on device with identifier', EMULATOR_ID,
                   'Successfully synced application']
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:30,代码来源:run_android_ng_tests.py

示例4: test_370_tns_run_android_with_jar_and_aar_files_in_app_res

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_370_tns_run_android_with_jar_and_aar_files_in_app_res(self):
        """
        App should not crash when reference .jar or/and .aar file in App_Resources/Android/libs
        https://github.com/NativeScript/android-runtime/issues/899
        """

        # Create libs/ in app/App_resources/, add .jar and .aar files in it and modify the app to reference them
        curr_folder = os.getcwd()
        Folder.navigate_to(os.path.join(self.app_name, 'app', 'App_Resources', 'Android'))
        Folder.create("libs")
        app_res_libs = os.path.join(self.app_name, 'app', 'App_Resources', 'Android', 'libs')
        Folder.navigate_to(curr_folder)

        custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
        custom_aar_file = os.path.join('data', 'issues', 'android-runtime-899', 'mylibrary.aar')

        File.copy(src=custom_jar_file, dest=app_res_libs)
        File.copy(src=custom_aar_file, dest=app_res_libs)

        source = os.path.join('data', 'issues', 'android-runtime-899', 'app.js')
        target = os.path.join(self.app_name, 'app', 'app.js')
        File.copy(src=source, dest=target)

        # `tns run android` and wait until app is deployed
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)
        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='livesync-hello-world_home')
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:36,代码来源:run_android_tests.py

示例5: test_360_tns_run_android_with_jar_file_in_plugin

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_360_tns_run_android_with_jar_file_in_plugin(self):
        """
        App should not crash when reference .jar file in some plugin
        https://github.com/NativeScript/android-runtime/pull/905
        """

        # Add .jar file in plugin and modify the app to reference it
        custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
        modules_widgets = os.path.join(self.app_name, 'node_modules', 'tns-core-modules-widgets', 'platforms',
                                       'android')
        File.copy(src=custom_jar_file, dest=modules_widgets)

        source = os.path.join('data', 'issues', 'android-runtime-pr-905', 'app.js')
        target = os.path.join(self.app_name, 'app', 'app.js')
        File.copy(src=source, dest=target)

        # `tns run android` and wait until app is deployed
        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
                              assert_success=False)
        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='livesync-hello-world_home')
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:29,代码来源:run_android_tests.py

示例6: test_181_tns_run_android_console_dir

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_181_tns_run_android_console_dir(self):
        """
         Test console.dir() of different objects.
        """

        # Change main-page.js so it contains console logging
        source_js = os.path.join('data', 'console-dir', 'main-page.js')
        target_js = os.path.join(self.app_name, 'app', 'main-page.js')
        File.copy(src=source_js, dest=target_js)

        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',
                   "true",
                   "false",
                   "null",
                   "undefined",
                   "-1",
                   "text",
                   "==== object dump start ====",
                   "name: \"John\"",
                   "age: \"34\"",
                   "==== object dump end ====",
                   self.max_long_string
                   ]

        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
        assert self.very_long_string not in log
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:32,代码来源:run_android_tests.py

示例7: test_210_tns_run_android_add_remove_files_and_folders

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_210_tns_run_android_add_remove_files_and_folders(self):
        """
        New files and folders should be synced properly.
        """

        log = Tns.run_android(attributes={'--path': self.app_name, '--device': self.DEVICE_ID}, wait=False,
                              assert_success=False)
        strings = ['Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10)

        # Add new files
        new_file_name = 'main-page2.xml'
        source_file = os.path.join(self.app_name, 'app', 'main-page.xml')
        destination_file = os.path.join(self.app_name, 'app', new_file_name)
        File.copy(source_file, destination_file)
        strings = ['Successfully transferred main-page2.xml', 'Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new file is synced and available on device.
        error_message = 'Newly created file {0} not found on {1}'.format(new_file_name, self.DEVICE_ID)
        app_id = Tns.get_app_id(app_name=self.app_name)
        path = 'app/{0}'.format(new_file_name)
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message

        # Revert changes(rename file and delete file)
        File.copy(destination_file, source_file)
        File.remove(destination_file)
        strings = ['Successfully transferred main-page.xml', 'Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new file is synced and available on device.
        error_message = '{0} was deleted, but still available on {1}'.format(new_file_name, self.DEVICE_ID)
        assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message

        # Add folder
        new_folder_name = 'feature2'
        source_file = os.path.join(self.app_name, 'app', 'feature1')
        destination_file = os.path.join(self.app_name, 'app', new_folder_name)
        Folder.copy(source_file, destination_file)
        strings = ['Successfully transferred', 'Successfully transferred', 'feature1.js', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new folder is synced and available on device.
        error_message = 'Newly created folder {0} not found on {1}'.format(new_folder_name, self.DEVICE_ID)
        path = 'app/{0}'.format(new_folder_name)
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message
        path = 'app/{0}/{1}'.format(new_folder_name, 'feature1.js')
        assert Adb.path_exists(device_id=self.DEVICE_ID, package_id=app_id, path=path, timeout=20), error_message

        # Delete folder
        Folder.cleanup(destination_file)
        strings = ['Successfully synced application', self.DEVICE_ID]
        Tns.wait_for_log(log_file=log, string_list=strings)

        # Verify new folder is deleted from device.
        error_message = 'Deleted folder {0} is still available on {1}'.format(new_folder_name, self.DEVICE_ID)
        assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:59,代码来源:run_android_device_tests.py

示例8: test_001_android_run_hmr

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_001_android_run_hmr(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, not_existing_string_list=HelpersHMR.errors_hmr,
                         timeout=240)
        Helpers.android_screen_match(image=HelpersHMR.image_original, timeout=120)

        HelpersHMR.apply_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
        HelpersHMR.revert_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:12,代码来源:hello_world_js_hmr_android.py

示例9: test_300_tns_run_android_emulator_should_start_emulator_even_if_device_is_connected

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
 def test_300_tns_run_android_emulator_should_start_emulator_even_if_device_is_connected(self):
     """
     `tns run android --emulator` should start emulator even if physical device is connected
     """
     Emulator.stop()
     output = Tns.run_android(
         attributes={'--path': self.app_name, '--timeout': '180', '--emulator': '', '--justlaunch': ''},
         assert_success=False)
     assert 'Starting Android emulator with image' in output
     assert Emulator.wait(device_id=EMULATOR_ID), 'Emulator not started by `tns run android`!'
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:12,代码来源:run_android_device_tests.py

示例10: test_009_android_run_hmr_delete_file

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_009_android_run_hmr_delete_file(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.wp_run, not_existing_string_list=HelpersHMR.wp_errors,
                         timeout=240)
        HelpersHMR.android_screen_match(image=self.image_original, timeout=120)
        File.remove(self.app_name + 'app', 'main-view-model.js')

        self.apply_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
        self.revert_changes(app_name=self.app_name, log=log, platform=Platform.ANDROID)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:13,代码来源:hello_world_js_hmr_android.py

示例11: test_310_tns_run_android_emulator_should_run_only_on_emulator

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
 def test_310_tns_run_android_emulator_should_run_only_on_emulator(self):
     """
     `tns run android --emulator` should start emulator even if physical device is connected
     """
     Emulator.stop()
     Emulator.ensure_available()
     output = Tns.run_android(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': ''},
                              assert_success=False)
     assert 'Starting Android emulator with image' not in output
     assert EMULATOR_ID in output
     for device_id in self.DEVICES:
         assert device_id not in output, 'Application is deployed on {0} device.'.format(device_id)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:14,代码来源:run_android_device_tests.py

示例12: test_008_android_run_hmr_console_log

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_008_android_run_hmr_console_log(self):
        source_js = os.path.join('data', "issues", 'console-log-hmr', 'main-view-model.js')
        target_js = os.path.join(self.app_name, 'app', 'main-view-model.js')
        File.copy(src=source_js, dest=target_js)

        log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--hmr': ''}, wait=False,
                              assert_success=False)

        strings = ['LOG Hello']
        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=HelpersHMR.image_original)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:16,代码来源:hello_world_js_hmr_android.py

示例13: test_180_tns_run_android_console_logging

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    def test_180_tns_run_android_console_logging(self):
        """
         Test console info, warn, error, assert, trace, time and logging of different objects.
        """

        # Change main-page.js so it contains console logging
        source_js = os.path.join('data', 'console-log', 'main-page.js')
        target_js = os.path.join(self.app_name, 'app', 'main-page.js')
        File.copy(src=source_js, dest=target_js)

        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',
                   "true",
                   "false",
                   "null",
                   "undefined",
                   "-1",
                   "text",
                   "\"name\": \"John\",",
                   "\"age\": 34",
                   "number: -1",
                   "string: text",
                   "text -1",
                   "info",
                   "warn",
                   "error",
                   "Assertion failed:  false == true",
                   "Assertion failed:  empty string evaluates to 'false'",
                   "Trace: console.trace() called",
                   "at pageLoaded",
                   "Button(8)",
                   "-1 text {",
                   "[1, 5, 12.5, {", "\"name\": \"John\",",
                   "\"age\": 34",
                   "}, text, 42]",
                   "Time:",
                   self.max_long_string,
                   "### TEST END ###"
                   ]

        Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
        assert "1 equals 1" not in log
        assert self.very_long_string not in log
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:48,代码来源:run_android_tests.py

示例14: test_002_android_run_hmr_uninstall_app

# 需要导入模块: from core.tns.tns import Tns [as 别名]
# 或者: from core.tns.tns.Tns import run_android [as 别名]
    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)
开发者ID:NativeScript,项目名称:nativescript-cli-tests,代码行数:20,代码来源:hello_world_js_hmr_android.py


注:本文中的core.tns.tns.Tns.run_android方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。