Skip to content

Commit 623bdb2

Browse files
author
vhristov5555
committed
PC-2018.1.4 <vhristov@vhristov Merge branch 'master'
2 parents 8f13e64 + 2b08c8a commit 623bdb2

File tree

2 files changed

+64
-44
lines changed

2 files changed

+64
-44
lines changed

core/tns/tns.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def create_app(app_name, attributes={}, log_trace=False, assert_success=True, up
219219
attributes_to_string = "".join("{0} {1}".format(k, v))
220220
attr = {}
221221
if not any(s in attributes_to_string for s in ("--ng", "--template", "--tsc")):
222-
if BRANCH is "master":
222+
if BRANCH == "master":
223223
attr = {"--template": SUT_FOLDER + os.path.sep + "tns-template-hello-world.tgz"}
224224
else:
225225
attr = {"--template": "tns-template-hello-world"}

tests/build/common/resources_generate_tests.py

+63-43
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,32 @@
88
from core.osutils.folder import Folder
99
from core.osutils.image_utils import ImageUtils
1010
from core.osutils.os_type import OSType
11-
from core.settings.settings import CURRENT_OS
11+
from core.settings.settings import CURRENT_OS, TEST_RUN_HOME
1212
from core.tns.tns import Tns
1313

1414

1515
class ResourcesGenerateTests(BaseClass):
16-
image_path = os.path.join(os.getcwd(), "data", "images", "resources_generate", "star.png")
17-
expected_images = os.path.join(os.getcwd(), "data", "images", "resources_generate")
18-
expected_images_android = os.path.join(os.getcwd(), expected_images, "Android")
19-
expected_images_ios = os.path.join(os.getcwd(), expected_images, "iOS")
16+
image_path = os.path.join(TEST_RUN_HOME, "data", "images", "resources_generate", "star.png")
17+
18+
expected_images = os.path.join(TEST_RUN_HOME, "data", "images", "resources_generate")
19+
expected_images_android = os.path.join(TEST_RUN_HOME, expected_images, "Android")
20+
expected_images_ios = os.path.join(TEST_RUN_HOME, expected_images, "iOS")
21+
22+
app_resources = os.path.join("app", "App_Resources", "Android", "src", "main", "res")
23+
app_resources_old = os.path.join("app", "App_Resources", "Android")
24+
assets_base = os.path.join("app", "App_Resources", "iOS", "Assets.xcassets")
25+
assets_icons = os.path.join(assets_base, "AppIcon.appiconset")
26+
27+
drawable_folders = ["drawable-hdpi", "drawable-ldpi", "drawable-mdpi", "drawable-xhdpi", "drawable-xxhdpi",
28+
"drawable-xxxhdpi"]
29+
30+
app_based_on_old_template = "TestApp40"
2031

2132
@classmethod
2233
def setUpClass(cls):
2334
BaseClass.setUpClass(cls.__name__)
2435
Tns.create_app(cls.app_name)
36+
Tns.create_app(cls.app_based_on_old_template, attributes={"--template": "[email protected]"})
2537

2638
def setUp(self):
2739
BaseClass.setUp(self)
@@ -32,71 +44,48 @@ def tearDown(self):
3244
@classmethod
3345
def tearDownClass(cls):
3446
BaseClass.tearDownClass()
35-
Folder.cleanup("Test App")
47+
Folder.cleanup(cls.app_based_on_old_template)
3648
Folder.cleanup("temp_ios_resources")
3749

38-
def test_001_tns_resources_generate_icons(self):
39-
app_resources_android = os.path.join(os.getcwd(), self.app_name, "app", "App_Resources", "Android")
40-
app_resources_ios = os.path.join(os.getcwd(), self.app_name, "app", "App_Resources", "iOS", "Assets.xcassets",
41-
"AppIcon.appiconset")
42-
43-
output = run("tns resources generate icons \"" + self.image_path + "\"" + " --path " + self.app_name)
44-
assert "Generating icons" in output
45-
assert "Icons generation completed" in output
46-
47-
# Android
48-
folders = ["drawable-hdpi", "drawable-ldpi", "drawable-mdpi", "drawable-xhdpi", "drawable-xxhdpi",
49-
"drawable-xxxhdpi"]
50-
51-
for folder in folders:
50+
@staticmethod
51+
def check_icons(app_resources_android, app_resources_ios):
52+
for folder in ResourcesGenerateTests.drawable_folders:
5253
actual_icon = os.path.join(app_resources_android, folder, "icon.png")
53-
expected_icon = os.path.join(self.expected_images_android, folder, "icon.png")
54+
expected_icon = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "icon.png")
5455
result = ImageUtils.image_match(actual_icon, expected_icon, 0.1)
5556

5657
if str(result[0]) is "False":
5758
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_icon, expected_icon,
5859
str(result[1]))
5960
# iOS
6061
if CURRENT_OS == OSType.OSX:
61-
icons = ["icon-29.png", "[email protected]", "[email protected]", "icon-40.png", "[email protected]", "[email protected]",
62+
icons = ["icon-29.png", "[email protected]", "[email protected]", "icon-40.png", "[email protected]",
63+
6264
6365
"icon-1024.png"]
6466

6567
for icon in icons:
6668
actual_icon = os.path.join(app_resources_ios, icon)
67-
expected_icon = os.path.join(self.expected_images_ios, icon)
69+
expected_icon = os.path.join(ResourcesGenerateTests.expected_images_ios, icon)
6870
result = ImageUtils.image_match(actual_icon, expected_icon, 0.1)
6971

7072
if str(result[0]) is "False":
7173
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_icon, expected_icon,
7274
str(result[1]))
7375

74-
assert True
75-
76-
def test_002_tns_resources_generate_spalshes(self):
77-
app_resources_android = os.path.join(os.getcwd(), self.app_name, "app", "App_Resources", "Android")
78-
app_resources_ios = os.path.join(os.getcwd(), self.app_name, "app", "App_Resources", "iOS", "Assets.xcassets")
79-
80-
output = run("tns resources generate splashes \"" + self.image_path + "\"" + " --background green --path "
81-
+ self.app_name)
82-
assert "Generating splash screens" in output
83-
assert "Splash screens generation completed" in output
84-
85-
# Android
86-
folders = ["drawable-hdpi", "drawable-ldpi", "drawable-mdpi", "drawable-xhdpi", "drawable-xxhdpi",
87-
"drawable-xxxhdpi"]
88-
89-
for folder in folders:
76+
@staticmethod
77+
def check_splashes(app_resources_android, app_resources_ios):
78+
for folder in ResourcesGenerateTests.drawable_folders:
9079
actual_logo = os.path.join(app_resources_android, folder, "logo.png")
91-
expected_logo = os.path.join(self.expected_images_android, folder, "logo.png")
80+
expected_logo = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "logo.png")
9281
result = ImageUtils.image_match(actual_logo, expected_logo, 0.1)
9382

9483
if str(result[0]) is "False":
9584
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_logo, expected_logo,
9685
str(result[1]))
9786

9887
actual_background = os.path.join(app_resources_android, folder, "background.png")
99-
expected_background = os.path.join(self.expected_images_android, folder, "background.png")
88+
expected_background = os.path.join(ResourcesGenerateTests.expected_images_android, folder, "background.png")
10089
result = ImageUtils.image_match(actual_background, expected_background, 0.1)
10190

10291
if str(result[0]) is "False":
@@ -125,10 +114,41 @@ def test_002_tns_resources_generate_spalshes(self):
125114

126115
for image in ios_images:
127116
actual_image = os.path.join(os.getcwd(), "temp_ios_resources", image)
128-
expected_image = os.path.join(self.expected_images_ios, image)
117+
expected_image = os.path.join(ResourcesGenerateTests.expected_images_ios, image)
129118
result = ImageUtils.image_match(actual_image, expected_image, 0.1)
130119

131120
if str(result[0]) is "False":
132121
assert False, "Images: \n{0} and \n{1} \nhas diff: {2}".format(actual_image, expected_image,
133122
str(result[1]))
134-
assert True
123+
124+
def test_001_tns_resources_generate_icons(self):
125+
app_resources_android = os.path.join(TEST_RUN_HOME, self.app_name, self.app_resources)
126+
app_resources_ios = os.path.join(TEST_RUN_HOME, self.app_name, self.assets_icons)
127+
128+
output = run("tns resources generate icons \"" + self.image_path + "\"" + " --path " + self.app_name)
129+
assert "Generating icons" in output
130+
assert "Icons generation completed" in output
131+
132+
ResourcesGenerateTests.check_icons(app_resources_android, app_resources_ios)
133+
134+
def test_002_tns_resources_generate_splashes(self):
135+
app_resources_android = os.path.join(TEST_RUN_HOME, self.app_name, self.app_resources)
136+
app_resources_ios = os.path.join(TEST_RUN_HOME, self.app_name, self.assets_base)
137+
138+
output = run("tns resources generate splashes \"" + self.image_path + "\"" + " --background green --path "
139+
+ self.app_name)
140+
assert "Generating splash screens" in output
141+
assert "Splash screens generation completed" in output
142+
143+
ResourcesGenerateTests.check_splashes(app_resources_android, app_resources_ios)
144+
145+
def test_100_tns_resources_generate_icons_old_template_structure(self):
146+
app_resources_android = os.path.join(TEST_RUN_HOME, self.app_based_on_old_template, self.app_resources_old)
147+
app_resources_ios = os.path.join(TEST_RUN_HOME, self.app_based_on_old_template, self.assets_icons)
148+
149+
output = run(
150+
"tns resources generate icons \"" + self.image_path + "\"" + " --path " + self.app_based_on_old_template)
151+
assert "Generating icons" in output
152+
assert "Icons generation completed" in output
153+
154+
ResourcesGenerateTests.check_icons(app_resources_android, app_resources_ios)

0 commit comments

Comments
 (0)