3
3
"""
4
4
5
5
import os
6
+ import time
6
7
7
8
from core .enums .app_type import AppType
8
9
from core .enums .os_type import OSType
@@ -151,10 +152,10 @@ def __sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=True,
151
152
device .screen_match (expected_image = initial_state , tolerance = 1.0 , timeout = 30 )
152
153
153
154
154
- def preview_hello_world_js_ts (app_name , platform , device , bundle = True , hmr = True , instrumented = False ,
155
+ def preview_hello_world_js_ts (app_name , device , bundle = True , hmr = True , instrumented = False ,
155
156
click_open_alert = False ):
156
- result = Preview .run_app (app_name = app_name , bundle = bundle , hmr = hmr , platform = platform ,
157
- device = device , instrumented = instrumented , click_open_alert = click_open_alert )
157
+ result = Preview .run_app (app_name = app_name , bundle = bundle , hmr = hmr , device = device ,
158
+ instrumented = instrumented , click_open_alert = click_open_alert )
158
159
159
160
# Verify app looks properly
160
161
device .wait_for_text (text = Changes .JSHelloWord .JS .old_text , timeout = 90 , retry_delay = 5 )
@@ -165,12 +166,17 @@ def preview_hello_world_js_ts(app_name, platform, device, bundle=True, hmr=True,
165
166
return result
166
167
167
168
168
- def preview_sync_hello_world_js_ts (app_type , app_name , platform , device , bundle = True , hmr = True , instrumented = False ,
169
+ def preview_sync_hello_world_js_ts (app_type , app_name , device , bundle = True , hmr = True , instrumented = False ,
169
170
click_open_alert = False ):
170
- result = preview_hello_world_js_ts (app_name = app_name , platform = platform , device = device , bundle = bundle , hmr = hmr ,
171
+ result = preview_hello_world_js_ts (app_name = app_name , device = device , bundle = bundle , hmr = hmr ,
171
172
instrumented = instrumented , click_open_alert = click_open_alert )
172
173
173
174
blue_count = device .get_pixels_by_color (color = Colors .LIGHT_BLUE )
175
+
176
+ # due to implementation when app restarts and if changes are made too quickly device is stated as
177
+ # not connected during the restart. Workaround is to wait some seconds before next change
178
+ time .sleep (5 )
179
+
174
180
# Set changes
175
181
js_file = os .path .basename (Changes .JSHelloWord .JS .file_path )
176
182
if app_type == AppType .JS :
@@ -191,30 +197,38 @@ def preview_sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=
191
197
192
198
# Edit CSS file and verify changes are applied
193
199
Sync .replace (app_name = app_name , change_set = css_change )
194
- strings = TnsLogs .preview_file_changed_messages (platform = platform , bundle = bundle ,
195
- hmr = hmr , file_name = 'app.css' , instrumented = instrumented )
200
+ strings = TnsLogs .preview_file_changed_messages (bundle = bundle , device = device , hmr = hmr ,
201
+ file_name = 'app.css' , instrumented = instrumented )
196
202
if hmr and instrumented and Settings .HOST_OS != OSType .WINDOWS :
197
203
TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings ,
198
204
not_existing_string_list = not_existing_string_list )
199
205
else :
200
206
TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings , timeout = 90 )
201
207
device .wait_for_color (color = css_change .new_color , pixel_count = blue_count , delta = 25 )
208
+ # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as
209
+ # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation
210
+ if not hmr :
211
+ time .sleep (5 )
202
212
203
213
# Edit JS file and verify changes are applied
204
214
Sync .replace (app_name = app_name , change_set = js_change )
205
- strings = TnsLogs .preview_file_changed_messages (platform = platform , bundle = bundle , hmr = hmr ,
206
- file_name = js_file , instrumented = instrumented )
215
+ strings = TnsLogs .preview_file_changed_messages (bundle = bundle , hmr = hmr , device = device , file_name = js_file ,
216
+ instrumented = instrumented )
207
217
if hmr and instrumented and Settings .HOST_OS != OSType .WINDOWS :
208
218
TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings ,
209
219
not_existing_string_list = not_existing_string_list )
210
220
else :
211
221
TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings , timeout = 90 )
212
222
device .wait_for_text (text = js_change .new_text )
223
+ # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as
224
+ # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation
225
+ if not hmr :
226
+ time .sleep (5 )
213
227
214
228
# Edit XML file and verify changes are applied
215
229
Sync .replace (app_name = app_name , change_set = xml_change )
216
- strings = TnsLogs .preview_file_changed_messages (platform = platform , bundle = bundle ,
217
- hmr = hmr , file_name = 'main-page.xml' , instrumented = instrumented )
230
+ strings = TnsLogs .preview_file_changed_messages (bundle = bundle , device = device , hmr = hmr ,
231
+ file_name = 'main-page.xml' , instrumented = instrumented )
218
232
if hmr and instrumented and Settings .HOST_OS != OSType .WINDOWS :
219
233
TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings ,
220
234
not_existing_string_list = not_existing_string_list )
0 commit comments