Skip to content

Commit 6951b08

Browse files
Vasil ChimevVasil Chimev
Vasil Chimev
authored and
Vasil Chimev
committed
Update livesync_simulator.py
NativeScript/nativescript-cli#1225
1 parent 45b8666 commit 6951b08

File tree

1 file changed

+27
-64
lines changed

1 file changed

+27
-64
lines changed

tests/livesync_simulator.py

Lines changed: 27 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import shutil, time
1111

12-
from helpers._os_lib import cleanup_folder, replace
12+
from helpers._os_lib import cleanup_folder, replace, remove
1313
from helpers._tns_lib import IOS_RUNTIME_SYMLINK_PATH, \
1414
create_project, platform_add, run, livesync, TNS_PATH
1515
from helpers.device import stop_emulators
@@ -98,6 +98,8 @@ def test_001_full_livesync_ios_simulator_xml_js_css_tns_files(self):
9898
"app/tns_modules/application/application-common.js")
9999
assert "require(\"globals\"); // test" in output
100100

101+
102+
# Add new files
101103
def test_101_livesync_ios_simulator_watch_add_xml_file(self):
102104
shutil.copyfile("TNS_App/app/main-page.xml", "TNS_App/app/test/test.xml")
103105
self.wait_for_text_in_output("app/test/test.xml")
@@ -120,6 +122,8 @@ def test_103_livesync_ios_simulator_watch_add_css_file(self):
120122
output = cat_app_file_on_simulator("TNSApp", "app/test/test.css")
121123
assert "color: #284848;" in output
122124

125+
126+
# Change in files
123127
def test_111_livesync_ios_simulator_watch_change_xml_file(self):
124128
replace("TNS_App/app/main-page.xml", "TEST", "WATCH")
125129
self.wait_for_text_in_output("app/main-page.xml")
@@ -142,101 +146,60 @@ def test_113_livesync_ios_simulator_watch_change_css_file(self):
142146
output = cat_app_file_on_simulator("TNSApp", "app/app.css")
143147
assert "color: green;" in output
144148

145-
# https://github.com/NativeScript/nativescript-cli/issues/1210
149+
150+
# # Delete files
146151
# def test_121_livesync_ios_simulator_watch_delete_xml_file(self):
147152
# remove("TNS_App/app/test/test.xml")
148153
# self.wait_for_text_in_output("app/test/test.xml")
149-
#
154+
#
150155
# output = cat_app_file_on_simulator("TNSApp", "app/test/test.xml")
151156
# assert "No such file or directory" in output
152-
#
157+
#
153158
# def test_122_livesync_ios_simulator_watch_delete_js_file(self):
154159
# remove("TNS_App/app/test/test.js")
155160
# self.wait_for_text_in_output("app/test/test.js")
156161
# time.sleep(2)
157-
#
162+
#
158163
# output = cat_app_file_on_simulator("TNSApp", "app/test/test.js")
159164
# assert "No such file or directory" in output
160-
#
165+
#
161166
# def test_123_livesync_ios_simulator_watch_delete_css_file(self):
162167
# remove("TNS_App/app/test/test.css")
163168
# self.wait_for_text_in_output("app/test/test.css")
164-
#
169+
#
165170
# output = cat_app_file_on_simulator("TNSApp", "app/test/test.css")
166171
# assert "No such file or directory" in output
167172

173+
168174
def test_301_livesync_ios_simulator_before_run(self):
169175
self.terminate_watcher()
170-
cleanup_folder('TNS_App')
176+
cleanup_folder('appTest')
171177

172-
create_project(proj_name="TNS_App")
178+
create_project(proj_name="appTest")
173179
platform_add(platform="ios", framework_path=IOS_RUNTIME_SYMLINK_PATH, \
174-
path="TNS_App", symlink=True)
180+
path="appTest", symlink=True)
175181

176182
# replace
177-
replace("TNS_App/app/main-page.xml", "TAP", "TEST")
178-
replace("TNS_App/app/main-view-model.js", "taps", "clicks")
179-
replace("TNS_App/app/app.css", "30", "20")
183+
replace("appTest/app/main-page.xml", "TAP", "TEST")
184+
replace("appTest/app/main-view-model.js", "taps", "clicks")
185+
replace("appTest/app/app.css", "30", "20")
180186

181-
replace("TNS_App/node_modules/tns-core-modules/LICENSE", "2015", "9999")
187+
replace("appTest/node_modules/tns-core-modules/LICENSE", "2015", "9999")
182188
replace(
183-
"TNS_App/node_modules/tns-core-modules/application/application-common.js",
189+
"appTest/node_modules/tns-core-modules/application/application-common.js",
184190
"(\"globals\");", "(\"globals\"); // test")
185191

186-
livesync(platform="ios", emulator=True, path="TNS_App")
192+
livesync(platform="ios", emulator=True, path="appTest")
187193

188-
output = cat_app_file_on_simulator("TNSApp", "app/main-page.xml")
194+
output = cat_app_file_on_simulator("appTest", "app/main-page.xml")
189195
assert "<Button text=\"TEST\" tap=\"{{ tapAction }}\" />" in output
190-
output = cat_app_file_on_simulator("TNSApp", "app/main-view-model.js")
196+
output = cat_app_file_on_simulator("appTest", "app/main-view-model.js")
191197
assert "this.set(\"message\", this.counter + \" clicks left\");" in output
192-
output = cat_app_file_on_simulator("TNSApp", "app/app.css")
198+
output = cat_app_file_on_simulator("appTest", "app/app.css")
193199
assert "font-size: 20;" in output
194200

195-
output = cat_app_file_on_simulator("TNSApp", "app/tns_modules/LICENSE")
201+
output = cat_app_file_on_simulator("appTest", "app/tns_modules/LICENSE")
196202
assert "Copyright (c) 9999 Telerik AD" in output
197-
output = cat_app_file_on_simulator("TNSApp", \
203+
output = cat_app_file_on_simulator("appTest", \
198204
"app/tns_modules/application/application-common.js")
199205
assert "require(\"globals\"); // test" in output
200-
201-
# https://github.com/NativeScript/nativescript-cli/issues/1225
202-
# def test_301_livesync_ios_simulator_before_run(self):
203-
# print "~~~ Killing subprocess ..."
204-
# self.process.terminate()
205-
#
206-
# time.sleep(2)
207-
# if psutil.pid_exists(self.process.pid):
208-
# print "~~~ Forced killing subprocess ..."
209-
# self.process.kill()
210-
#
211-
# cleanup_folder('appTest')
212-
# create_project(proj_name="appTest")
213-
# platform_add(platform="ios", framework_path=IOS_RUNTIME_SYMLINK_PATH, \
214-
# path="appTest", symlink=True)
215-
# build(platform="ios", path="appTest")
216-
#
217-
# # replace
218-
# replace("appTest/app/main-page.xml", "TAP", "TEST")
219-
# replace("appTest/app/main-view-model.js", "taps", "clicks")
220-
# replace("appTest/app/app.css", "30", "20")
221-
#
222-
# replace("appTest/node_modules/tns-core-modules/LICENSE", "2015", "9999")
223-
# replace(
224-
# "appTest/node_modules/tns-core-modules/application/application-common.js",
225-
# "(\"globals\");", "(\"globals\"); // test")
226-
#
227-
# livesync(platform="ios", emulator=True, path="appTest")
228-
# self.wait_for_text_in_output("prepared")
229-
# time.sleep(2)
230-
#
231-
# output = cat_app_file_on_simulator("appTest", "app/main-page.xml")
232-
# assert "<Button text=\"TEST\" tap=\"{{ tapAction }}\" />" in output
233-
# output = cat_app_file_on_simulator("appTest", "app/main-view-model.js")
234-
# assert "this.set(\"message\", this.counter + \" clicks left\");" in output
235-
# output = cat_app_file_on_simulator("appTest", "app/app.css")
236-
# assert "font-size: 20;" in output
237-
#
238-
# output = cat_app_file_on_simulator("appTest", "app/tns_modules/LICENSE")
239-
# assert "Copyright (c) 9999 Telerik AD" in output
240-
# output = cat_app_file_on_simulator("appTest", \
241-
# "app/tns_modules/application/application-common.js")
242-
# assert "require(\"globals\"); // test" in output

0 commit comments

Comments
 (0)