1
1
"""
2
2
Tests for building projects with the Android platform
3
3
"""
4
+ import datetime
4
5
import os
5
6
import unittest
6
7
from zipfile import ZipFile
@@ -88,7 +89,15 @@ def test_001_build_android(self):
88
89
File .copy (src = src , dest = dest_1 )
89
90
File .copy (src = src , dest = dest_2 )
90
91
91
- Tns .build_android (attributes = {"--path" : self .app_name })
92
+ # Verify incremental native build
93
+ before_build = datetime .datetime .now ()
94
+ output = Tns .build_android (attributes = {"--path" : self .app_name })
95
+ after_build = datetime .datetime .now ()
96
+ assert "Gradle build..." in output , "Gradle build not called."
97
+ assert output .count ("Gradle build..." ) is 1 , "Only one gradle build is triggered."
98
+ assert (after_build - before_build ).total_seconds () < 20 , "Incremental build takes more then 20 sec."
99
+
100
+ # Verify platform specific files
92
101
assert File .pattern_exists (self .platforms_android , "*.aar" )
93
102
assert not File .pattern_exists (self .platforms_android , "*.plist" )
94
103
assert not File .pattern_exists (self .platforms_android , "*.android.js" )
@@ -102,6 +111,24 @@ def test_001_build_android(self):
102
111
assert not File .pattern_exists (self .app_name + "/temp" , "*.android.*" )
103
112
assert not File .pattern_exists (self .app_name + "/temp" , "*.ios.*" )
104
113
114
+ # Verify clean build force native project rebuild
115
+ before_build = datetime .datetime .now ()
116
+ output = Tns .build_android (attributes = {"--path" : self .app_name })
117
+ after_build = datetime .datetime .now ()
118
+ assert "Gradle build..." in output , "Gradle build not called."
119
+ assert output .count ("Gradle build..." ) is 1 , "Only one gradle build is triggered."
120
+ assert (after_build - before_build ).total_seconds () < 15 , "Incremental build takes more then 15 sec."
121
+
122
+ # Verify incremental native build
123
+ before_build = datetime .datetime .now ()
124
+ output = Tns .build_android (attributes = {"--path" : self .app_name , "--clean" : "" })
125
+ after_build = datetime .datetime .now ()
126
+ build_time = (after_build - before_build ).total_seconds ()
127
+ assert "Gradle build..." in output , "Gradle build not called."
128
+ assert output .count ("Gradle build..." ) is 2 , "Only one gradle build is triggered."
129
+ assert build_time > 15 , "Clean build takes less then 15 sec."
130
+ assert build_time < 90 , "Clean build takes more than 90 sec."
131
+
105
132
def test_002_build_android_release (self ):
106
133
Tns .build_android (attributes = {"--path" : self .app_name ,
107
134
"--keyStorePath" : ANDROID_KEYSTORE_PATH ,
0 commit comments