Skip to content

Commit 0cf63c2

Browse files
latest changes
1 parent 3c14249 commit 0cf63c2

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

data/sync/hello_world_js.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=True,
153153

154154
def preview_hello_world_js_ts(app_name, platform, device, bundle=True, hmr=True, instrumented=False,
155155
click_open_alert=False):
156-
result = Preview.run_app(app_name=app_name, bundle=bundle, hmr=hmr,
156+
result = Preview.run_app(app_name=app_name, bundle=bundle, hmr=hmr, platform=platform,
157157
device=device, instrumented=instrumented, click_open_alert=click_open_alert)
158158

159159
# Verify app looks properly
@@ -191,8 +191,8 @@ def preview_sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=
191191

192192
# Edit CSS file and verify changes are applied
193193
Sync.replace(app_name=app_name, change_set=css_change)
194-
strings = TnsLogs.preview_file_changed_messages(bundle=bundle, device=device,
195-
hmr=hmr, file_name='app.css', instrumented=instrumented)
194+
strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, device=device, hmr=hmr,
195+
file_name='app.css', instrumented=instrumented)
196196
if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS:
197197
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
198198
not_existing_string_list=not_existing_string_list)
@@ -202,8 +202,8 @@ def preview_sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=
202202

203203
# Edit JS file and verify changes are applied
204204
Sync.replace(app_name=app_name, change_set=js_change)
205-
strings = TnsLogs.preview_file_changed_messages(bundle=bundle, hmr=hmr, device=device,
206-
file_name=js_file, instrumented=instrumented)
205+
strings = TnsLogs.preview_file_changed_messages(bundle=bundle, hmr=hmr, device=device, file_name=js_file,
206+
instrumented=instrumented, platform=platform)
207207
if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS:
208208
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
209209
not_existing_string_list=not_existing_string_list)
@@ -213,7 +213,7 @@ def preview_sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=
213213

214214
# Edit XML file and verify changes are applied
215215
Sync.replace(app_name=app_name, change_set=xml_change)
216-
strings = TnsLogs.preview_file_changed_messages(bundle=bundle, device=device,
216+
strings = TnsLogs.preview_file_changed_messages(bundle=bundle, device=device, platform=platform,
217217
hmr=hmr, file_name='main-page.xml', instrumented=instrumented)
218218
if hmr and instrumented and Settings.HOST_OS != OSType.WINDOWS:
219219
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,

data/sync/hello_world_ng.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,16 @@ def preview_sync_hello_world_ng(app_name, platform, device, bundle=True, hmr=Tru
156156
# Edit TS file and verify changes are applied
157157
Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.TS)
158158
strings = TnsLogs.preview_file_changed_messages(platform=platform, run_type=RunType.INCREMENTAL, bundle=bundle,
159-
file_name='item.service.ts', hmr=hmr, instrumented=instrumented)
159+
file_name='item.service.ts', hmr=hmr, instrumented=instrumented,
160+
device=device)
160161
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180,
161162
not_existing_string_list=not_existing_string_list)
162163
device.wait_for_text(text=Changes.NGHelloWorld.TS.new_text)
163164

164165
# Edit HTML file and verify changes are applied
165166
Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.HTML)
166167
strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, file_name='items.component.html',
167-
hmr=hmr, instrumented=instrumented)
168+
hmr=hmr, instrumented=instrumented, device=device)
168169
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180,
169170
not_existing_string_list=not_existing_string_list)
170171
if platform == Platform.IOS:
@@ -178,7 +179,7 @@ def preview_sync_hello_world_ng(app_name, platform, device, bundle=True, hmr=Tru
178179
# Edit CSS file and verify changes are applied
179180
Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.CSS)
180181
strings = TnsLogs.preview_file_changed_messages(platform=platform, bundle=bundle, file_name='app.css',
181-
hmr=hmr, instrumented=instrumented)
182+
hmr=hmr, instrumented=instrumented, device=device)
182183
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180,
183184
not_existing_string_list=not_existing_string_list)
184185
device.wait_for_main_color(color=Changes.NGHelloWorld.CSS.new_color)

products/nativescript/preview_helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def dismiss_simulator_alert():
128128
run(command)
129129

130130
@staticmethod
131-
def run_app(app_name, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False):
131+
def run_app(app_name, platform, device, bundle=True, hmr=True, instrumented=False, click_open_alert=False):
132132
result = Tns.preview(app_name=app_name, bundle=bundle, hmr=hmr)
133133

134134
# Read the log and extract the url to load the app on emulator
@@ -143,7 +143,7 @@ def run_app(app_name, device, bundle=True, hmr=True, instrumented=False, click_o
143143
device.click("Open")
144144

145145
# Verify logs
146-
strings = TnsLogs.preview_initial_messages(device=device, hmr=hmr, bundle=bundle,
146+
strings = TnsLogs.preview_initial_messages(platform=platform, device=device, hmr=hmr, bundle=bundle,
147147
instrumented=instrumented)
148148
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=200)
149149
return result

products/nativescript/tns_assert.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,17 @@ def test_initialized(app_name, framework, output):
181181
assert 'Run your tests using the' in output
182182

183183
@staticmethod
184-
def file_is_synced_once(log, platform, file_name):
184+
def file_is_synced_once(log, device, file_name):
185185
"""
186186
Assert file is synced once on livesync.
187187
:param log: log or part of log you want to check
188188
:param platform: The platform you are syncing on.
189189
:param file_name: name of the file you are syncing.
190190
"""
191-
if platform == Platform.ANDROID:
192-
assert log.count('Start syncing changes for platform android') == 1, "File is synced more than once!"
193-
assert log.count('hot-update.json for platform android') == 1, "File is synced more than once!"
194-
assert file_name in log
195-
else:
196-
assert log.count('Start syncing changes for platform ios') == 1, "File is synced more than once!"
197-
assert log.count('hot-update.json for platform ios') == 1, "File is synced more than once!"
198-
assert file_name in log
191+
assert log.count('Start syncing changes for device {0}'.format(str(device.model))) == 1, \
192+
"File is synced more than once!"
193+
# assert log.count('hot-update.json for device') == 1, "File is synced more than once!"
194+
assert file_name in log
199195

200196
@staticmethod
201197
def snapshot_skipped(snapshot, result, release):

products/nativescript/tns_logs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def __webpack_messages():
246246
'Webpack build done!']
247247

248248
@staticmethod
249-
def preview_initial_messages(device, bundle=True, hmr=False, instrumented=False):
249+
def preview_initial_messages(platform, device, bundle=True, hmr=False, instrumented=False):
250250
logs = ["Start sending initial files for device {0}".format(str(device.model)),
251251
"Successfully sent initial files for device {0}".format(str(device.model))]
252252
if bundle or hmr:
@@ -256,7 +256,7 @@ def preview_initial_messages(device, bundle=True, hmr=False, instrumented=False)
256256
return logs
257257

258258
@staticmethod
259-
def preview_file_changed_messages(device, file_name, run_type=RunType.INCREMENTAL,
259+
def preview_file_changed_messages(device, platform, file_name, run_type=RunType.INCREMENTAL,
260260
bundle=True, hmr=True, instrumented=False):
261261
logs = ["Start syncing changes for device {0}".format(str(device.model))]
262262
if bundle or hmr:

tests/cli/preview/templates/hello_word_js_tests.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import time
23
import unittest
34

45
from core.base_test.tns_run_test import TnsRunTest
@@ -31,7 +32,7 @@ def setUpClass(cls):
3132
cls.emu_API24 = DeviceManager.Emulator.ensure_available(Settings.Emulators.EMU_API_24)
3233

3334
# Download Preview and Playground packages
34-
# Preview.get_app_packages()
35+
Preview.get_app_packages()
3536

3637
# Install Preview and Playground
3738
Preview.install_preview_app(cls.emu, Platform.ANDROID)
@@ -96,19 +97,20 @@ def test_210_tns_preview_android_livesync_on_two_emulators(self):
9697
log = File.read(result.log_file)
9798
url = Preview.get_url(log)
9899
Preview.run_url(url=url, device=self.emu)
99-
strings = TnsLogs.preview_initial_messages(device=self.emu)
100+
strings = TnsLogs.preview_initial_messages(device=self.emu, platform=Platform.ANDROID)
100101
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
101-
self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text, timeout=90)
102+
self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text, timeout=120)
102103

103104
# Click on TAP button on emulator
104105
Adb.click_element_by_text(self.emu.id, 'TAP', case_sensitive=True)
105106

107+
time.sleep(2)
106108
# Preview on second emulator
107109
Preview.run_url(url=url, device=self.emu_API24)
108110
# Here use bundle=False because on consecutive preview build is not executed again
109111
# and no bundle messages are displayed in log
110-
strings = TnsLogs.preview_initial_messages(device=self.emu, bundle=False)
111-
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
112+
strings = TnsLogs.preview_initial_messages(device=self.emu, platform=Platform.ANDROID)
113+
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)
112114
self.emu_API24.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
113115

114116
# Verify first emulator is not refreshed, state of app is preserved
@@ -136,7 +138,7 @@ def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
136138
log = File.read(result.log_file)
137139
url = Preview.get_url(log)
138140
Preview.run_url(url=url, device=self.emu)
139-
strings = TnsLogs.preview_initial_messages(device=self.emu)
141+
strings = TnsLogs.preview_initial_messages(device=self.emu, platform=Platform.ANDROID)
140142
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
141143
self.emu.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
142144

@@ -145,7 +147,7 @@ def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
145147

146148
# Preview on simulator
147149
Preview.run_url(url=url, device=self.sim)
148-
strings = TnsLogs.preview_initial_messages(device=self.sim)
150+
strings = TnsLogs.preview_initial_messages(device=self.sim, platform=Platform.IOS)
149151
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings)
150152
self.sim.wait_for_text(text=Changes.JSHelloWord.JS.old_text)
151153

@@ -162,8 +164,8 @@ def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
162164
log = File.read(result.log_file)
163165
log = File.extract_part_of_text(log, '[VERIFIED]')
164166
# Verify files are synced once
165-
TnsAssert.file_is_synced_once(log, Platform.ANDROID, 'main-view-model.js')
166-
TnsAssert.file_is_synced_once(log, Platform.IOS, 'main-view-model.js')
167+
TnsAssert.file_is_synced_once(log, device=self.emu, file_name='main-view-model.js')
168+
TnsAssert.file_is_synced_once(log, device=self.sim, file_name='main-view-model.js')
167169
# Mark that part of the log as verified before next sync
168170
File.append(result.log_file, '[VERIFIED]')
169171

@@ -177,8 +179,8 @@ def test_210_tns_preview_on_simulator_and_emulator_livesync(self):
177179
log = File.read(result.log_file)
178180
log = File.extract_part_of_text(log, '[VERIFIED]')
179181
# Verify files are synced once
180-
TnsAssert.file_is_synced_once(log, Platform.ANDROID, 'main-page.xml')
181-
TnsAssert.file_is_synced_once(log, Platform.IOS, 'main-page.xml')
182+
TnsAssert.file_is_synced_once(log, device=self.emu, file_name='main-page.xml')
183+
TnsAssert.file_is_synced_once(log, device=self.sim, file_name='main-page.xml')
182184

183185
def test_240_tns_preview_android_verify_plugin_warnings(self):
184186
"""

tests/cli/preview/templates/hello_word_ng_tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import unittest
33
from core.base_test.tns_test import TnsTest
44
from core.base_test.tns_run_test import TnsRunTest
5+
from core.enums.app_type import AppType
56
from core.enums.os_type import OSType
67
from core.enums.platform_type import Platform
78
from core.settings import Settings

0 commit comments

Comments
 (0)