-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhello_word_ng_tests.py
82 lines (66 loc) · 3.65 KB
/
hello_word_ng_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
import unittest
from flaky import flaky
from core.base_test.tns_run_test import TnsRunTest
from core.base_test.tns_test import TnsTest
from core.enums.os_type import OSType
from core.enums.platform_type import Platform
from core.settings import Settings
from core.utils.file_utils import File, Folder
from data.sync.hello_world_ng import preview_sync_hello_world_ng
from data.templates import Template
from products.nativescript.preview_helpers import Preview
from products.nativescript.tns import Tns
class TnsPreviewNGTests(TnsRunTest):
app_name = Settings.AppName.DEFAULT
source_project_dir = os.path.join(Settings.TEST_RUN_HOME, app_name)
target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', app_name)
@classmethod
def setUpClass(cls):
TnsRunTest.setUpClass()
# Download Preview and Playground packages
Preview.get_app_packages()
# Install Preview and Playground
Preview.install_preview_app(cls.emu, Platform.ANDROID)
if Settings.HOST_OS is OSType.OSX:
Preview.install_preview_app(cls.sim, Platform.IOS)
Preview.install_playground_app(cls.sim, Platform.IOS)
# Create app
Tns.create(app_name=cls.app_name, template=Template.HELLO_WORLD_NG.local_package, update=True)
src = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'logs', 'hello-world-ng', 'main.ts')
target = os.path.join(Settings.TEST_RUN_HOME, cls.app_name, 'src')
File.copy(source=src, target=target)
src = os.path.join(Settings.TEST_RUN_HOME, 'assets', 'logs', 'hello-world-ng', 'items.component.ts')
target = os.path.join(Settings.TEST_RUN_HOME, cls.app_name, 'src', 'app', 'item')
File.copy(source=src, target=target)
# Copy TestApp to data folder.
Folder.copy(source=cls.source_project_dir, target=cls.target_project_dir)
def setUp(self):
TnsTest.setUp(self)
# "src" folder of TestApp will be restored before each test.
# This will ensure failures in one test do not cause common failures.
source_src = os.path.join(self.target_project_dir, 'src')
target_src = os.path.join(self.source_project_dir, 'src')
Folder.clean(target_src)
Folder.copy(source=source_src, target=target_src)
class PreviewNGTests(TnsPreviewNGTests):
def test_100_preview_android(self):
"""Preview project on emulator. Make valid changes in TS, CSS and HTML"""
preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.ANDROID,
device=self.emu, instrumented=True)
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
def test_100_preview_ios(self):
"""Preview project on simulator. Make valid changes in TS, CSS and HTML"""
preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.IOS,
device=self.sim, instrumented=True)
@flaky(max_runs=3)
def test_205_preview_android_no_hmr(self):
"""Preview project on emulator with --hmr. Make valid changes in TS, CSS and HTML"""
preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.ANDROID,
device=self.emu, hmr=False)
@flaky(max_runs=3)
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
def test_205_preview_ios_no_hmr(self):
"""Preview project on simulator with --hmr. Make valid changes in TS, CSS and HTML"""
preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.IOS,
device=self.sim, hmr=False)