Skip to content

Commit 912e026

Browse files
Vasil ChimevVasil Chimev
authored andcommitted
Refactor LiveSync Android device tests.
1 parent dcc2728 commit 912e026

File tree

2 files changed

+22
-37
lines changed

2 files changed

+22
-37
lines changed

helpers/device.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ def WaitForDevice(deviceName, timeout = 600):
4545
if (found is True) or (time.time() > endTime):
4646
break
4747
return found
48-
48+
4949
def StopEmulators():
5050
KillProcess("emulator")
5151
KillProcess("emulator64-arm")
5252
KillProcess("emulator64-x86")
53-
53+
54+
def StopSimulators():
55+
KillProcess("launchd_sim")
56+
5457
def GivenRunningEmulator():
5558

5659
output = runAUT(tnsPath + " device")

tests/livesync_android.py

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
from helpers._os_lib import CleanupFolder, replace, catAppFile
55
from helpers._tns_lib import androidRuntimePath, \
66
CreateProjectAndAddPlatform, LiveSync, Run
7-
from helpers.device import GivenRealDeviceRunning, StopEmulators
7+
from helpers.device import GivenRealDeviceRunning, StopEmulators, \
8+
StopSimulators
89

910
class LiveSync_Android(unittest.TestCase):
1011

1112
# LiveSync Tests on Android Device
1213

1314
@classmethod
1415
def setUpClass(cls):
15-
super(LiveSync_Android, cls).setUpClass()
1616
StopEmulators()
17+
StopSimulators()
1718

1819
def setUp(self):
1920

@@ -31,7 +32,7 @@ def tearDown(self):
3132

3233
@classmethod
3334
def tearDownClass(cls):
34-
super(LiveSync_Android, cls).tearDownClass()
35+
pass
3536

3637
def test_001_LiveSync_Android_XmlFile(self):
3738
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
@@ -92,46 +93,34 @@ def test_004_LiveSync_Android_Watch(self):
9293
print "force killing child ..."
9394
pr.kill()
9495

95-
def test_011_LiveSync_Android_JsFile(self):
96-
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
97-
Run(platform="android", path="TNS_App")
98-
99-
replace("TNS_App/app/main-view-model.js", "taps", "clicks")
100-
LiveSync(platform="android", path="TNS_App")
101-
102-
output = catAppFile("android", "TNSApp", "app/main-view-model.js")
103-
assert ("this.set(\"message\", this.counter + \" clicks left\");" in output)
104-
105-
def test_012_LiveSync_Android_CssFile(self):
96+
def test_011_LiveSync_Android_CssJs_Files(self):
10697
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
10798
Run(platform="android", path="TNS_App")
10899

109100
replace("TNS_App/app/app.css", "30", "20")
101+
replace("TNS_App/app/main-view-model.js", "taps", "clicks")
110102
LiveSync(platform="android", path="TNS_App")
111103

112104
output = catAppFile("android", "TNSApp", "app/app.css")
113105
assert ("font-size: 20;" in output)
114106

115-
def test_013_LiveSync_Android_TnsModules_File(self):
116-
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
117-
Run(platform="android", path="TNS_App")
118-
119-
replace("TNS_App/node_modules/tns-core-modules/application/application-common.js", "(\"globals\");", "(\"globals\"); // test")
120-
LiveSync(platform="android", path="TNS_App")
121-
122-
output = catAppFile("android", "TNSApp", "app/tns_modules/application/application-common.js")
123-
assert ("require(\"globals\"); // test" in output)
107+
output = catAppFile("android", "TNSApp", "app/main-view-model.js")
108+
assert ("this.set(\"message\", this.counter + \" clicks left\");" in output)
124109

125-
def test_014_LiveSync_Android_TnsModules_LICENSE(self):
110+
def test_012_LiveSync_Android_TnsModules_Files(self):
126111
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
127112
Run(platform="android", path="TNS_App")
128113

129114
replace("TNS_App/node_modules/tns-core-modules/LICENSE", "2015", "9999")
115+
replace("TNS_App/node_modules/tns-core-modules/application/application-common.js", "(\"globals\");", "(\"globals\"); // test")
130116
LiveSync(platform="android", path="TNS_App")
131117

132118
output = catAppFile("android", "TNSApp", "app/tns_modules/LICENSE")
133119
assert ("Copyright (c) 9999 Telerik AD" in output)
134120

121+
output = catAppFile("android", "TNSApp", "app/tns_modules/application/application-common.js")
122+
assert ("require(\"globals\"); // test" in output)
123+
135124
def test_021_LiveSync_Android_AddNewFiles(self):
136125
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
137126
Run(platform="android", path="TNS_App")
@@ -165,22 +154,15 @@ def test_031_LiveSync_Android_DeleteFiles(self):
165154
output = catAppFile("android", "TNSApp", "app/LICENSE")
166155
assert ("cat: files/app/LICENSE: No such file or directory" in output)
167156

168-
def test_302_LiveSync_XmlFile(self):
157+
def test_302_LiveSync(self):
169158
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
170159
Run(platform="android", path="TNS_App")
171160

172161
replace("TNS_App/app/main-page.xml", "TAP", "TEST")
173-
LiveSync(path="TNS_App")
174-
175-
output = catAppFile("android", "TNSApp", "app/main-page.xml")
176-
assert ("<Button text=\"TEST\" tap=\"{{ tapAction }}\" />" in output)
162+
output = LiveSync(path="TNS_App", assertSuccess=False)
177163

178-
def test_303_LiveSync_BeforeRun(self):
179-
CreateProjectAndAddPlatform(projName="TNS_App", platform="android", frameworkPath=androidRuntimePath)
180-
LiveSync(path="TNS_App")
181-
182-
output = catAppFile("android", "TNSApp", "app/main-page.xml")
183-
assert ("<Button text=\"TAP\" tap=\"{{ tapAction }}\" />" in output)
164+
assert ("Multiple device platforms detected (iOS and Android). Specify platform or device on command line." in output)
165+
assert ("# livesync" in output)
184166

185167
# # TODO: Implement it.
186168
# @unittest.skip("Fix LiveSync for Android device.")

0 commit comments

Comments
 (0)