|
14 | 14 | from core.osutils.folder import Folder
|
15 | 15 | from core.osutils.process import Process
|
16 | 16 | from core.settings.settings import IOS_RUNTIME_PATH, IOS_INSPECTOR_PACKAGE, SIMULATOR_NAME
|
| 17 | +from core.tns.replace_helper import ReplaceHelper |
17 | 18 | from core.tns.tns import Tns
|
18 | 19 | from core.tns.tns_platform_type import Platform
|
19 | 20 | from core.tns.tns_prepare_type import Prepare
|
@@ -56,39 +57,6 @@ def tearDownClass(cls):
|
56 | 57 | BaseClass.tearDownClass()
|
57 | 58 | Folder.cleanup(cls.app_name)
|
58 | 59 |
|
59 |
| - """ |
60 |
| - Spec: |
61 |
| -
|
62 |
| - | Usage | Synopsis | |
63 |
| - | Deploy on device, run the app, start Safari Web Inspector and attach the debugger | $ tns debug ios | |
64 |
| - | Deploy on device, run the app and stop at the first code statement | $ tns debug ios --debug-brk [--device <Device ID>] [--no-client] | |
65 |
| - | Deploy in the iOS Simulator, run the app and stop at the first code statement | $ tns debug ios --debug-brk --emulator [<Emulator Options>] [--no-client] | |
66 |
| - | Attach the debug tools to a running app on device | $ tns debug ios --start [--device <Device ID>] [--no-client] | |
67 |
| - | Attach the debug tools to a running app in the iOS Simulator | $ tns debug ios --start --emulator [<Emulator Options>] [--no-client] | |
68 |
| -
|
69 |
| - Prepares, builds and deploys the project when necessary. Debugs your project on a connected device or in the iOS Simulator. |
70 |
| - While debugging, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application. |
71 |
| -
|
72 |
| - IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system. |
73 |
| -
|
74 |
| - ### Options |
75 |
| -
|
76 |
| - * --device - Specifies a connected device on which to run the app. |
77 |
| - * --emulator - Indicates that you want to debug your app in the iOS simulator. |
78 |
| - * --debug-brk - Prepares, builds and deploys the application package on a device or in an emulator, runs the app, launches the developer tools of your Safari browser and stops at the first code statement. |
79 |
| - * --start - Attaches the debug tools to a deployed and running app and launches the developer tools of your Safari browser. |
80 |
| - * --no-client - If set, the NativeScript CLI attaches the debug tools but does not launch the developer tools in Safari. |
81 |
| - * --timeout - Sets the number of seconds that NativeScript CLI will wait for the debugger to boot. If not set, the default timeout is 90 seconds. |
82 |
| - * --no-watch - If set, changes in your code will not be reflected during the execution of this command. |
83 |
| - * --clean - If set, forces rebuilding the native application. |
84 |
| -
|
85 |
| - ### Attributes |
86 |
| -
|
87 |
| - * <Device ID> is the index or name of the target device as listed by $ tns device |
88 |
| - * <Emulator Options> is any valid combination of options as listed by $ tns help emulate ios |
89 |
| -
|
90 |
| - """ |
91 |
| - |
92 | 60 | def __verify_debugger_start(self, log):
|
93 | 61 | strings = [self.SIMULATOR_ID, "Frontend client connected", "Backend socket created",
|
94 | 62 | "NativeScript debugger attached"]
|
@@ -149,3 +117,39 @@ def test_003_debug_ios_simulator_start(self):
|
149 | 117 | # Attach debugger
|
150 | 118 | log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--start': ''})
|
151 | 119 | self.__verify_debugger_attach(log=log)
|
| 120 | + |
| 121 | + def test_100_debug_ios_simulator_with_livesync(self): |
| 122 | + """ |
| 123 | + `tns debug ios` should be able to run with livesync |
| 124 | + """ |
| 125 | + log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': ''}) |
| 126 | + self.__verify_debugger_start(log) |
| 127 | + |
| 128 | + # Verify app starts and do not stop on first line of code |
| 129 | + Device.screen_match(device_type=DeviceType.SIMULATOR, device_name=SIMULATOR_NAME, |
| 130 | + device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_home') |
| 131 | + |
| 132 | + # Change JS and wait until app is synced |
| 133 | + ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_JS, sleep=10) |
| 134 | + strings = ['Successfully transferred', 'main-view-model.js', 'Successfully synced application', 'CONSOLE LOG', |
| 135 | + 'Backend socket closed', 'Frontend socket closed', 'NativeScript debugger detached', |
| 136 | + 'Frontend client connected', 'Backend socket created', 'NativeScript debugger attached'] |
| 137 | + Tns.wait_for_log(log_file=log, string_list=strings) |
| 138 | + |
| 139 | + # Change XML and wait until app is synced |
| 140 | + ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_XML, sleep=3) |
| 141 | + strings = ['Successfully transferred', 'main-page.xml', 'Successfully synced application', |
| 142 | + 'Backend socket created', 'NativeScript debugger attached', 'CONSOLE LOG'] |
| 143 | + Tns.wait_for_log(log_file=log, string_list=strings) |
| 144 | + |
| 145 | + # Change CSS and wait until app is synced |
| 146 | + ReplaceHelper.replace(self.app_name, ReplaceHelper.CHANGE_CSS, sleep=3) |
| 147 | + strings = ['Successfully transferred', 'app.css', 'Successfully synced application', 'Backend socket created', |
| 148 | + 'NativeScript debugger attached', 'CONSOLE LOG'] |
| 149 | + Tns.wait_for_log(log_file=log, string_list=strings) |
| 150 | + |
| 151 | + # Verify application looks correct |
| 152 | + Device.screen_match(device_type=DeviceType.SIMULATOR, device_name=SIMULATOR_NAME, |
| 153 | + device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_js_css_xml') |
| 154 | + |
| 155 | + assert Process.is_running('NativeScript Inspector') |
0 commit comments