1
- # pylint: disable=too-many-branches
2
- # pylint: disable=too-many-statements
3
1
import os
4
2
import unittest
5
3
6
- from core .base_test .tns_test import TnsTest
4
+ from core .base_test .tns_run_test import TnsRunTest
7
5
from core .enums .env import EnvironmentType
8
6
from core .enums .os_type import OSType
9
7
from core .enums .platform_type import Platform
10
8
from core .enums .styling_type import StylingType
11
9
from core .settings import Settings
12
- from core .utils .device .adb import Adb
13
- from core .utils .device .device_manager import DeviceManager
14
10
from core .utils .file_utils import Folder
15
11
from core .utils .json_utils import JsonUtils
16
12
from data .apps import Apps
19
15
from products .nativescript .app import App
20
16
from products .nativescript .tns import Tns
21
17
from products .nativescript .tns_assert import TnsAssert
18
+ from products .nativescript .tns_paths import TnsPaths
22
19
23
20
24
21
# noinspection PyMethodMayBeStatic
25
- class NGNewTests (TnsTest ):
22
+ class NGNewTests (TnsRunTest ):
26
23
app_name = Settings .AppName .DEFAULT
27
- app_folder = os .path .join (Settings .TEST_RUN_HOME , app_name )
28
- emu = None
29
- sim = None
30
-
31
- @classmethod
32
- def setUpClass (cls ):
33
- TnsTest .setUpClass ()
34
- cls .emu = DeviceManager .Emulator .ensure_available (Settings .Emulators .DEFAULT )
35
- if Settings .HOST_OS is OSType .OSX :
36
- cls .sim = DeviceManager .Simulator .ensure_available (Settings .Simulators .DEFAULT )
24
+ app_path = TnsPaths .get_app_path (app_name = app_name )
37
25
38
26
def setUp (self ):
39
- TnsTest .setUp (self )
27
+ TnsRunTest .setUp (self )
40
28
NG .kill ()
41
- Adb .open_home (device_id = self .emu .id ) # Open home page to be sure we do not find old text
42
- Folder .clean (self .app_folder )
29
+ Folder .clean (self .app_path )
43
30
44
31
def tearDown (self ):
45
32
NG .kill ()
46
- TnsTest .tearDown (self )
47
-
48
- @classmethod
49
- def tearDownClass (cls ):
50
- TnsTest .tearDownClass ()
33
+ TnsRunTest .tearDown (self )
51
34
52
35
def test_001_simple (self ):
53
36
NGNewTests .create_and_run (shared = False )
@@ -110,7 +93,8 @@ def create_and_run(shared=True, sample=False, theme=True, style=None, prefix=Non
110
93
App .update (app_name = NGNewTests .app_name , modules = True , angular = True , typescript = False , web_pack = False )
111
94
112
95
# Run the app
113
- NGNewTests .run_bundle (app_data = app_data , webpack = webpack , shared = shared , theme = theme )
96
+ NGNewTests .run_bundle (app_data = app_data , webpack = webpack , shared = shared , theme = theme ,
97
+ emu = NGNewTests .emu , sim = NGNewTests .sim )
114
98
115
99
@staticmethod
116
100
def create_app (app_data , shared , sample , theme , style , prefix , source_dir , webpack ):
@@ -163,14 +147,14 @@ def create_app(app_data, shared, sample, theme, style, prefix, source_dir, webpa
163
147
assert Folder .exists (os .path .join (Settings .TEST_RUN_HOME , NGNewTests .app_name , source_dir ))
164
148
165
149
@staticmethod
166
- def run_bundle (app_data , webpack , shared , theme ):
150
+ def run_bundle (app_data , webpack , shared , theme , emu , sim ):
167
151
# Run android (if webpack is available -> use --bundle)
168
152
Tns .run (app_name = NGNewTests .app_name , platform = Platform .ANDROID , emulator = True , bundle = webpack )
169
153
for text in app_data .texts :
170
- NGNewTests . emu .wait_for_text (text = text , timeout = 300 )
154
+ emu .wait_for_text (text = text , timeout = 300 )
171
155
# Check if theme is really applied (only for non shared projects, shared is not good example to check)
172
156
if not shared :
173
- blue_pixels = NGNewTests . emu .get_pixels_by_color (color = Colors .LIGHT_BLUE )
157
+ blue_pixels = emu .get_pixels_by_color (color = Colors .LIGHT_BLUE )
174
158
if theme :
175
159
assert blue_pixels > 1000 , 'Default {N} theme is NOT applied on Android.'
176
160
else :
@@ -180,10 +164,10 @@ def run_bundle(app_data, webpack, shared, theme):
180
164
if Settings .HOST_OS is OSType .OSX :
181
165
Tns .run (app_name = NGNewTests .app_name , platform = Platform .IOS , emulator = True , bundle = webpack )
182
166
for text in app_data .texts :
183
- NGNewTests . sim .wait_for_text (text = text , timeout = 300 )
167
+ sim .wait_for_text (text = text , timeout = 300 )
184
168
# Check if theme is really applied (only for non shared projects, shared is not good example to check)
185
169
if not shared :
186
- blue_pixels = NGNewTests . emu .get_pixels_by_color (color = Colors .LIGHT_BLUE )
170
+ blue_pixels = emu .get_pixels_by_color (color = Colors .LIGHT_BLUE )
187
171
if theme :
188
172
assert blue_pixels > 1000 , 'Default {N} theme is NOT applied on iOS.'
189
173
else :
0 commit comments