def preview_sync_hello_world_ng(app_name, platform, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False): result = preview_hello_world_ng(app_name=app_name, platform=platform, device=device, bundle=bundle, hmr=hmr, instrumented=instrumented, click_open_alert=click_open_alert) # Edit TS file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.TS) strings = TnsLogs.preview_file_changed_messages(platform=platform, run_type=RunType.INCREMENTAL, bundle=bundle, file_name='item.service.ts', hmr=hmr, instrumented=instrumented) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180) device.wait_for_text(text=Changes.NGHelloWorld.TS.new_text) # Edit HTML file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.HTML) strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, file_name='items.component.html', hmr=hmr, instrumented=instrumented) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180) if platform == Platform.IOS: for number in ["10", "1"]: device.wait_for_text(text=number) else: for number in ["8", "9"]: device.wait_for_text(text=number) assert not device.is_text_visible(text=Changes.NGHelloWorld.TS.new_text) # Edit CSS file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.CSS) strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, file_name='app.css', hmr=hmr, instrumented=instrumented) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180) device.wait_for_main_color(color=Colors.DARK) if platform == Platform.IOS: for number in ["10", "1"]: device.wait_for_text(text=number) else: for number in ["8", "9"]: device.wait_for_text(text=number) assert not device.is_text_visible(text=Changes.NGHelloWorld.TS.new_text)
def preview_sync_hello_world_ng(app_name, platform, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False): result = preview_hello_world_ng(app_name=app_name, device=device, bundle=bundle, hmr=hmr, instrumented=instrumented, click_open_alert=click_open_alert) # Verify that application is not restarted on file changes when hmr=true if hmr and Settings.HOST_OS != OSType.WINDOWS: not_existing_string_list = ['Restarting application'] else: not_existing_string_list = None # due to implementation when app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change time.sleep(5) # Edit TS file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.TS) strings = TnsLogs.preview_file_changed_messages( run_type=RunType.INCREMENTAL, bundle=bundle, file_name='item.service.ts', hmr=hmr, instrumented=instrumented, device=device) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180, not_existing_string_list=not_existing_string_list) device.wait_for_text(text=Changes.NGHelloWorld.TS.new_text) # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation if not hmr: time.sleep(5) # Edit HTML file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.HTML) strings = TnsLogs.preview_file_changed_messages( bundle=bundle, file_name='items.component.html', hmr=hmr, instrumented=instrumented, device=device) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180, not_existing_string_list=not_existing_string_list) if platform == Platform.IOS: for number in ["10", "1"]: device.wait_for_text(text=number) else: for number in ["8", "9"]: device.wait_for_text(text=number) assert not device.is_text_visible(text=Changes.NGHelloWorld.TS.new_text) # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation if not hmr: time.sleep(5) # Edit CSS file and verify changes are applied Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.CSS) strings = TnsLogs.preview_file_changed_messages(bundle=bundle, file_name='app.css', hmr=hmr, instrumented=instrumented, device=device) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180, not_existing_string_list=not_existing_string_list) device.wait_for_main_color(color=Changes.NGHelloWorld.CSS.new_color) if platform == Platform.IOS: for number in ["10", "1"]: device.wait_for_text(text=number) else: for number in ["8", "9"]: device.wait_for_text(text=number) assert not device.is_text_visible(text=Changes.NGHelloWorld.TS.new_text)
def preview_sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False): result = preview_hello_world_js_ts(app_name=app_name, platform=platform, device=device, bundle=bundle, hmr=hmr, instrumented=instrumented, click_open_alert=click_open_alert) blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE) # Set changes js_file = os.path.basename(Changes.JSHelloWord.JS.file_path) if app_type == AppType.JS: js_change = Changes.JSHelloWord.JS xml_change = Changes.JSHelloWord.XML css_change = Changes.JSHelloWord.CSS elif app_type == AppType.TS: js_file = os.path.basename(Changes.TSHelloWord.TS.file_path) js_change = Changes.TSHelloWord.TS xml_change = Changes.TSHelloWord.XML css_change = Changes.TSHelloWord.CSS else: raise ValueError('Invalid app_type value.') if hmr and instrumented: not_existing_string_list = ['QA: Application started'] # Edit JS file and verify changes are applied Sync.replace(app_name=app_name, change_set=js_change) strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, hmr=hmr, file_name=js_file, instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_text(text=js_change.new_text) # Edit XML file and verify changes are applied Sync.replace(app_name=app_name, change_set=xml_change) strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, hmr=hmr, file_name='main-page.xml', instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_text(text=xml_change.new_text) device.wait_for_text(text=js_change.new_text) # Edit CSS file and verify changes are applied Sync.replace(app_name=app_name, change_set=css_change) strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, hmr=hmr, file_name='app.css', instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_color(color=Colors.LIGHT_BLUE, pixel_count=blue_count * 2, delta=25) device.wait_for_text(text=xml_change.new_text) device.wait_for_text(text=js_change.new_text)
def preview_sync_hello_world_js_ts(app_type, app_name, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False): result = preview_hello_world_js_ts(app_name=app_name, device=device, bundle=bundle, hmr=hmr, instrumented=instrumented, click_open_alert=click_open_alert) blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE) # due to implementation when app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change time.sleep(5) # Set changes js_file = os.path.basename(Changes.JSHelloWord.JS.file_path) if app_type == AppType.JS: js_change = Changes.JSHelloWord.JS xml_change = Changes.JSHelloWord.XML css_change = Changes.JSHelloWord.CSS elif app_type == AppType.TS: js_file = os.path.basename(Changes.TSHelloWord.TS.file_path) js_change = Changes.TSHelloWord.TS xml_change = Changes.TSHelloWord.XML css_change = Changes.TSHelloWord.CSS else: raise ValueError('Invalid app_type value.') not_existing_string_list = None if hmr and instrumented: not_existing_string_list = ['QA: Application started'] # Edit CSS file and verify changes are applied Sync.replace(app_name=app_name, change_set=css_change) strings = TnsLogs.preview_file_changed_messages(bundle=bundle, device=device, hmr=hmr, file_name='app.css', instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_color(color=css_change.new_color, pixel_count=blue_count, delta=25) # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation if not hmr: time.sleep(5) # Edit JS file and verify changes are applied Sync.replace(app_name=app_name, change_set=js_change) strings = TnsLogs.preview_file_changed_messages(bundle=bundle, hmr=hmr, device=device, file_name=js_file, instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_text(text=js_change.new_text) # due to implementation when no hmr app restarts and if changes are made too quickly device is stated as # not connected during the restart. Workaround is to wait some seconds before next change when in no hmr situation if not hmr: time.sleep(5) # Edit XML file and verify changes are applied Sync.replace(app_name=app_name, change_set=xml_change) strings = TnsLogs.preview_file_changed_messages(bundle=bundle, device=device, hmr=hmr, file_name='main-page.xml', instrumented=instrumented) if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) else: TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90) device.wait_for_text(text=xml_change.new_text) device.wait_for_text(text=js_change.new_text)