1
- import os
2
1
import unittest
3
2
4
3
from core .base_class .BaseClass import BaseClass
5
4
from core .device .emulator import Emulator
6
5
from core .device .simulator import Simulator
7
6
from core .npm .npm import Npm
8
- from core .osutils .file import File
9
7
from core .osutils .os_type import OSType
10
8
from core .settings .settings import ANDROID_KEYSTORE_PATH , \
11
9
ANDROID_KEYSTORE_PASS , ANDROID_KEYSTORE_ALIAS , ANDROID_KEYSTORE_ALIAS_PASS , EMULATOR_ID , CURRENT_OS , \
12
10
IOS_RUNTIME_PATH , SIMULATOR_NAME , ANDROID_RUNTIME_PATH
13
11
from core .tns .replace_helper import ReplaceHelper
14
12
from core .tns .tns import Tns
15
- from core .tns .tns_platform_type import Platform
16
- from core .tns .tns_verifications import TnsAsserts
17
13
from tests .webpack .helpers .helpers import Helpers
18
14
19
15
@@ -53,54 +49,7 @@ def setUp(self):
53
49
def tearDownClass (cls ):
54
50
BaseClass .tearDownClass ()
55
51
56
- def test_000_build_without_bundle (self ):
57
- Tns .build_android (attributes = {"--path" : self .app_name })
58
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "debug" ))
59
- assert 13000000 < apk_size < 13500000 , "Actual apk size is " + str (apk_size )
60
- Helpers .run_android_via_adb (app_name = self .app_name , config = "debug" , image = self .image_original )
61
-
62
- if CURRENT_OS is OSType .OSX :
63
- Tns .build_ios (attributes = {"--path" : self .app_name })
64
-
65
- Tns .build_ios (attributes = {"--path" : self .app_name , "--release" : "" , "--for-device" : "" })
66
- app_path = Helpers .get_app_path (app_name = self .app_name ).replace ("emulator" , "device" )
67
- ipa_path = app_path .replace (".app" , ".ipa" )
68
- ipa_size = File .get_size (ipa_path )
69
- assert 13000000 < ipa_size < 13500000 , "Actual app is " + str (ipa_size )
70
-
71
- def test_001_android_build_with_bundle (self ):
72
- Tns .build_android (attributes = {"--path" : self .app_name , "--bundle" : "" })
73
-
74
- base_path = os .path .join (self .app_name , TnsAsserts .PLATFORM_ANDROID_APP_PATH )
75
- bundle_js_size = File .get_size (os .path .join (base_path , "bundle.js" ))
76
- starter_js_size = File .get_size (os .path .join (base_path , "starter.js" ))
77
- vendor_js_size = File .get_size (os .path .join (base_path , "vendor.js" ))
78
- main_page_xml_size = File .get_size (os .path .join (base_path , "main-page.xml" ))
79
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "debug" ))
80
-
81
- assert 6500 < bundle_js_size < 7000 , "Actual bundle_js_size is " + str (bundle_js_size )
82
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
83
- assert 1200000 < vendor_js_size < 1310000 , "Actual vendor_js_size is " + str (vendor_js_size )
84
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
85
- assert 12000000 < apk_size < 13000000 , "Actual apk_size is " + str (apk_size )
86
-
87
- Helpers .run_android_via_adb (app_name = self .app_name , config = "debug" , image = self .image_original )
88
-
89
- @unittest .skipIf (CURRENT_OS != OSType .OSX , "Run only on macOS." )
90
- def test_001_ios_build_with_bundle (self ):
91
- Tns .build_ios (attributes = {"--path" : self .app_name , "--bundle" : "" })
92
-
93
- app_path = Helpers .get_app_path (app_name = self .app_name )
94
- bundle_js_size = File .get_size (os .path .join (app_path , "app" , "bundle.js" ))
95
- starter_js_size = File .get_size (os .path .join (app_path , "app" , "starter.js" ))
96
- vendor_js_size = File .get_size (os .path .join (app_path , "app" , "vendor.js" ))
97
- main_page_xml_size = File .get_size (os .path .join (app_path , "app" , "main-page.xml" ))
98
- assert 6500 < bundle_js_size < 7000 , "Actual bundle_js_size is " + str (bundle_js_size )
99
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
100
- assert 1400000 < vendor_js_size < 1450000 , "Actual vendor_js_size is " + str (vendor_js_size )
101
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
102
-
103
- def test_002_android_build_release_with_bundle (self ):
52
+ def test_001_android_build_release_with_bundle (self ):
104
53
Tns .build_android (attributes = {"--path" : self .app_name ,
105
54
"--keyStorePath" : ANDROID_KEYSTORE_PATH ,
106
55
"--keyStorePassword" : ANDROID_KEYSTORE_PASS ,
@@ -109,42 +58,15 @@ def test_002_android_build_release_with_bundle(self):
109
58
"--release" : "" ,
110
59
"--bundle" : "" })
111
60
112
- base_path = os .path .join (self .app_name , TnsAsserts .PLATFORM_ANDROID_APP_PATH )
113
- bundle_js_size = File .get_size (os .path .join (base_path , "bundle.js" ))
114
- starter_js_size = File .get_size (os .path .join (base_path , "starter.js" ))
115
- vendor_js_size = File .get_size (os .path .join (base_path , "vendor.js" ))
116
- main_page_xml_size = File .get_size (os .path .join (base_path , "main-page.xml" ))
117
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "release" ))
118
-
119
- assert 6500 < bundle_js_size < 7000
120
- assert 30 < starter_js_size < 50
121
- assert 1200000 < vendor_js_size < 1310000
122
- assert 1600 < main_page_xml_size < 2000
123
- assert 11000000 < apk_size < 11500000
124
-
61
+ Helpers .verify_size (app_name = self .app_name , config = "js-android-bundle" )
125
62
Helpers .run_android_via_adb (app_name = self .app_name , config = "release" , image = self .image_original )
126
63
127
64
@unittest .skipIf (CURRENT_OS != OSType .OSX , "Run only on macOS." )
128
- def test_002_ios_build_release_with_bundle (self ):
65
+ def test_001_ios_build_release_with_bundle (self ):
129
66
Tns .build_ios (attributes = {"--path" : self .app_name , "--release" : "" , "--for-device" : "" , "--bundle" : "" })
130
- app_path = Helpers .get_app_path (app_name = self .app_name ).replace ("emulator" , "device" )
131
- ipa_path = app_path .replace (".app" , ".ipa" )
132
- bundle_js_size = File .get_size (os .path .join (app_path , "app" , "bundle.js" ))
133
- starter_js_size = File .get_size (os .path .join (app_path , "app" , "starter.js" ))
134
- vendor_js_size = File .get_size (os .path .join (app_path , "app" , "vendor.js" ))
135
- main_page_xml_size = File .get_size (os .path .join (app_path , "app" , "main-page.xml" ))
136
- ipa_size = File .get_size (ipa_path )
137
- assert 6500 < bundle_js_size < 7000 , "Actual bundle_js_size is " + str (bundle_js_size )
138
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
139
- assert 1400000 < vendor_js_size < 1450000 , "Actual vendor_js_size is " + str (vendor_js_size )
140
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
141
- assert 12500000 < ipa_size < 13000000 , "Actual app is " + str (ipa_size )
142
-
143
- def test_100_android_build_release_with_and_bundle_and_uglify (self ):
144
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
145
- Tns .platform_remove (platform = Platform .ANDROID , attributes = {"--path" : self .app_name })
146
- Tns .platform_add_android (attributes = {'--path' : self .app_name , '--frameworkPath' : ANDROID_RUNTIME_PATH })
67
+ Helpers .verify_size (app_name = self .app_name , config = "js-ios-bundle" )
147
68
69
+ def test_100_android_build_release_with_bundle_and_uglify (self ):
148
70
Tns .build_android (attributes = {"--path" : self .app_name ,
149
71
"--keyStorePath" : ANDROID_KEYSTORE_PATH ,
150
72
"--keyStorePassword" : ANDROID_KEYSTORE_PASS ,
@@ -154,47 +76,17 @@ def test_100_android_build_release_with_and_bundle_and_uglify(self):
154
76
"--bundle" : "" ,
155
77
"--env.uglify" : "" })
156
78
157
- base_path = os .path .join (self .app_name , TnsAsserts .PLATFORM_ANDROID_APP_PATH )
158
- bundle_js_size = File .get_size (os .path .join (base_path , "bundle.js" ))
159
- starter_js_size = File .get_size (os .path .join (base_path , "starter.js" ))
160
- vendor_js_size = File .get_size (os .path .join (base_path , "vendor.js" ))
161
- main_page_xml_size = File .get_size (os .path .join (base_path , "main-page.xml" ))
162
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "release" ))
163
-
164
- assert 3500 < bundle_js_size < 3750 , "Actual bundle_js_size is " + str (bundle_js_size )
165
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
166
- assert 670000 < vendor_js_size < 680000 , "Actual vendor_js_size is " + str (vendor_js_size )
167
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
168
- assert 11000000 < apk_size < 11500000 , "Actual app is " + str (apk_size )
169
-
79
+ Helpers .verify_size (app_name = self .app_name , config = "js-android-bundle-uglify" )
170
80
Helpers .run_android_via_adb (app_name = self .app_name , config = "release" , image = self .image_original )
171
81
172
82
@unittest .skipIf (CURRENT_OS != OSType .OSX , "Run only on macOS." )
173
- def test_100_ios_build_release_with_and_bundle_and_uglify (self ):
174
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
175
- Tns .platform_remove (platform = Platform .IOS , attributes = {"--path" : self .app_name })
176
- Tns .platform_add_ios (attributes = {'--path' : self .app_name , '--frameworkPath' : IOS_RUNTIME_PATH })
177
-
83
+ def test_100_ios_build_release_with_bundle_and_uglify (self ):
178
84
Tns .build_ios (attributes = {"--path" : self .app_name , "--release" : "" , "--for-device" : "" , "--bundle" : "" ,
179
85
"--env.uglify" : "" })
180
- app_path = Helpers .get_app_path (app_name = self .app_name ).replace ("emulator" , "device" )
181
- ipa_path = app_path .replace (".app" , ".ipa" )
182
- bundle_js_size = File .get_size (os .path .join (app_path , "app" , "bundle.js" ))
183
- starter_js_size = File .get_size (os .path .join (app_path , "app" , "starter.js" ))
184
- vendor_js_size = File .get_size (os .path .join (app_path , "app" , "vendor.js" ))
185
- main_page_xml_size = File .get_size (os .path .join (app_path , "app" , "main-page.xml" ))
186
- ipa_size = File .get_size (ipa_path )
187
- assert 3500 < bundle_js_size < 3750 , "Actual bundle_js_size is " + str (bundle_js_size )
188
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
189
- assert 685000 < vendor_js_size < 695000 , "Actual vendor_js_size is " + str (vendor_js_size )
190
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
191
- assert 12500000 < ipa_size < 13000000 , "Actual app is " + str (ipa_size )
192
-
193
- def test_110_android_build_release_with_and_bundle_and_snapshot (self ):
194
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
195
- Tns .platform_remove (platform = Platform .ANDROID , attributes = {"--path" : self .app_name })
196
- Tns .platform_add_android (attributes = {'--path' : self .app_name , '--frameworkPath' : ANDROID_RUNTIME_PATH })
197
86
87
+ Helpers .verify_size (app_name = self .app_name , config = "js-ios-bundle-uglify" )
88
+
89
+ def test_110_android_build_release_with_bundle_and_snapshot (self ):
198
90
Tns .build_android (attributes = {"--path" : self .app_name ,
199
91
"--keyStorePath" : ANDROID_KEYSTORE_PATH ,
200
92
"--keyStorePassword" : ANDROID_KEYSTORE_PASS ,
@@ -204,47 +96,10 @@ def test_110_android_build_release_with_and_bundle_and_snapshot(self):
204
96
"--bundle" : "" ,
205
97
"--env.snapshot" : "" })
206
98
207
- base_path = os .path .join (self .app_name , TnsAsserts .PLATFORM_ANDROID_APP_PATH )
208
- bundle_js_size = File .get_size (os .path .join (base_path , "bundle.js" ))
209
- starter_js_size = File .get_size (os .path .join (base_path , "starter.js" ))
210
- vendor_js_size = File .get_size (os .path .join (base_path , "vendor.js" ))
211
- main_page_xml_size = File .get_size (os .path .join (base_path , "main-page.xml" ))
212
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "release" ))
213
-
214
- assert 6500 < bundle_js_size < 7000 , "Actual bundle_js_size is " + str (bundle_js_size )
215
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
216
- assert vendor_js_size == 0 , "Actual vendor_js_size is " + str (vendor_js_size )
217
- assert 1600 < main_page_xml_size < 2000 , "Actual main_page_xml_size is " + main_page_xml_size
218
- assert 13000000 < apk_size < 14000000 , "Actual app is " + str (apk_size )
219
-
99
+ Helpers .verify_size (app_name = self .app_name , config = "js-android-bundle-snapshot" )
220
100
Helpers .run_android_via_adb (app_name = self .app_name , config = "release" , image = self .image_original )
221
101
222
- @unittest .skipIf (CURRENT_OS != OSType .OSX , "Run only on macOS." )
223
- def test_110_ios_build_release_with_and_bundle_and_snapshot (self ):
224
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
225
- Tns .platform_remove (platform = Platform .IOS , attributes = {"--path" : self .app_name })
226
- Tns .platform_add_ios (attributes = {'--path' : self .app_name , '--frameworkPath' : IOS_RUNTIME_PATH })
227
-
228
- Tns .build_ios (attributes = {"--path" : self .app_name , "--release" : "" , "--for-device" : "" , "--bundle" : "" ,
229
- "--env.snapshot" : "" })
230
- app_path = Helpers .get_app_path (app_name = self .app_name ).replace ("emulator" , "device" )
231
- ipa_path = app_path .replace (".app" , ".ipa" )
232
- bundle_js_size = File .get_size (os .path .join (app_path , "app" , "bundle.js" ))
233
- starter_js_size = File .get_size (os .path .join (app_path , "app" , "starter.js" ))
234
- vendor_js_size = File .get_size (os .path .join (app_path , "app" , "vendor.js" ))
235
- main_page_xml_size = File .get_size (os .path .join (app_path , "app" , "main-page.xml" ))
236
- ipa_size = File .get_size (ipa_path )
237
- assert 6500 < bundle_js_size < 7000 , "Actual bundle_js_size is " + str (bundle_js_size )
238
- assert 30 < starter_js_size < 50 , "Actual starter_js_size is " + str (starter_js_size )
239
- assert 1400000 < vendor_js_size < 1450000 , "Actual vendor_js_size is " + str (vendor_js_size )
240
- assert 1600 < main_page_xml_size < 2000
241
- assert 12500000 < ipa_size < 13000000 , "Actual app is " + str (ipa_size )
242
-
243
- def test_120_android_build_release_with_and_bundle_and_snapshot_and_uglify (self ):
244
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
245
- Tns .platform_remove (platform = Platform .ANDROID , attributes = {"--path" : self .app_name })
246
- Tns .platform_add_android (attributes = {'--path' : self .app_name , '--frameworkPath' : ANDROID_RUNTIME_PATH })
247
-
102
+ def test_120_android_build_release_with_bundle_and_snapshot_and_uglify (self ):
248
103
Tns .build_android (attributes = {"--path" : self .app_name ,
249
104
"--keyStorePath" : ANDROID_KEYSTORE_PATH ,
250
105
"--keyStorePassword" : ANDROID_KEYSTORE_PASS ,
@@ -255,43 +110,9 @@ def test_120_android_build_release_with_and_bundle_and_snapshot_and_uglify(self)
255
110
"--env.uglify" : "" ,
256
111
"--env.snapshot" : "" })
257
112
258
- base_path = os .path .join (self .app_name , TnsAsserts .PLATFORM_ANDROID_APP_PATH )
259
- bundle_js_size = File .get_size (os .path .join (base_path , "bundle.js" ))
260
- starter_js_size = File .get_size (os .path .join (base_path , "starter.js" ))
261
- vendor_js_size = File .get_size (os .path .join (base_path , "vendor.js" ))
262
- main_page_xml_size = File .get_size (os .path .join (base_path , "main-page.xml" ))
263
- apk_size = File .get_size (Helpers .get_apk_path (app_name = self .app_name , config = "release" ))
264
-
265
- assert 3500 < bundle_js_size < 3750
266
- assert 30 < starter_js_size < 50
267
- assert vendor_js_size == 0
268
- assert 1600 < main_page_xml_size < 2000
269
-
270
- assert 12500000 < apk_size < 13500000 , "Actual app is " + str (apk_size )
271
-
113
+ Helpers .verify_size (app_name = self .app_name , config = "js-android-bundle-uglify-snapshot" )
272
114
Helpers .run_android_via_adb (app_name = self .app_name , config = "release" , image = self .image_original )
273
115
274
- @unittest .skipIf (CURRENT_OS != OSType .OSX , "Run only on macOS." )
275
- def test_120_ios_build_release_with_and_bundle_and_snapshot_and_uglify (self ):
276
- # Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
277
- Tns .platform_remove (platform = Platform .IOS , attributes = {"--path" : self .app_name })
278
- Tns .platform_add_ios (attributes = {'--path' : self .app_name , '--frameworkPath' : IOS_RUNTIME_PATH })
279
-
280
- Tns .build_ios (attributes = {"--path" : self .app_name , "--release" : "" , "--for-device" : "" , "--bundle" : "" ,
281
- "--env.snapshot" : "" , "--env.uglify" : "" })
282
- app_path = Helpers .get_app_path (app_name = self .app_name ).replace ("emulator" , "device" )
283
- ipa_path = app_path .replace (".app" , ".ipa" )
284
- bundle_js_size = File .get_size (os .path .join (app_path , "app" , "bundle.js" ))
285
- starter_js_size = File .get_size (os .path .join (app_path , "app" , "starter.js" ))
286
- vendor_js_size = File .get_size (os .path .join (app_path , "app" , "vendor.js" ))
287
- main_page_xml_size = File .get_size (os .path .join (app_path , "app" , "main-page.xml" ))
288
- ipa_size = File .get_size (ipa_path )
289
- assert 3500 < bundle_js_size < 3750
290
- assert 30 < starter_js_size < 50
291
- assert 680000 < vendor_js_size < 700000 , "Actual vendor_js_size is " + str (vendor_js_size )
292
- assert 1600 < main_page_xml_size < 2000
293
- assert 12500000 < ipa_size < 13000000 , "Actual app is " + str (ipa_size )
294
-
295
116
def test_200_run_android_with_bundle_sync_changes (self ):
296
117
log = Tns .run_android (attributes = {'--path' : self .app_name ,
297
118
"--bundle" : "" ,
0 commit comments