Skip to content

Commit 91fc222

Browse files
committed
feat: tests for resources generate commands
Add tests for: - tns resources generate - tns resources update
1 parent a25b61b commit 91fc222

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+190
-5
lines changed
1.11 KB
7.47 KB
598 Bytes
2.86 KB
790 Bytes
4.51 KB
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill">
2+
<item>
3+
<bitmap android:gravity="fill" android:src="@drawable/background" />
4+
</item>
5+
<item>
6+
<bitmap android:gravity="center" android:src="@drawable/logo" />
7+
</item>
8+
</layer-list>
1.44 KB
11.6 KB
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"images": [
3+
{
4+
"idiom": "ipad",
5+
"size": "20x20",
6+
"scale": "1x",
7+
"filename": "[email protected]"
8+
},
9+
{
10+
"idiom": "iphone",
11+
"size": "20x20",
12+
"scale": "2x",
13+
"filename": "[email protected]"
14+
},
15+
{
16+
"idiom": "iphone",
17+
"size": "20x20",
18+
"scale": "3x",
19+
"filename": "[email protected]"
20+
},
21+
{
22+
"idiom": "iphone",
23+
"size": "29x29",
24+
"scale": "1x",
25+
"filename": "[email protected]"
26+
},
27+
{
28+
"idiom": "iphone",
29+
"size": "29x29",
30+
"scale": "2x",
31+
"filename": "[email protected]"
32+
},
33+
{
34+
"idiom": "iphone",
35+
"size": "29x29",
36+
"scale": "3x",
37+
"filename": "[email protected]"
38+
},
39+
{
40+
"idiom": "iphone",
41+
"size": "40x40",
42+
"scale": "2x",
43+
"filename": "[email protected]"
44+
},
45+
{
46+
"idiom": "iphone",
47+
"size": "40x40",
48+
"scale": "3x",
49+
"filename": "[email protected]"
50+
},
51+
{
52+
"idiom": "iphone",
53+
"size": "60x60",
54+
"scale": "2x",
55+
"filename": "[email protected]"
56+
},
57+
{
58+
"idiom": "iphone",
59+
"size": "60x60",
60+
"scale": "3x",
61+
"filename": "[email protected]"
62+
},
63+
{
64+
"idiom": "ipad",
65+
"size": "76x76",
66+
"scale": "1x",
67+
"filename": "[email protected]"
68+
},
69+
{
70+
"idiom": "ipad",
71+
"size": "76x76",
72+
"scale": "2x",
73+
"filename": "[email protected]"
74+
},
75+
{
76+
"idiom": "ios-marketing",
77+
"size": "1024x1024",
78+
"scale": "1x",
79+
"filename": "Icon-marketing-1024x1024.png"
80+
}
81+
],
82+
"info": {
83+
"version": 1,
84+
"author": "apetools.webprofusion.com"
85+
}
86+
}
169 KB
6.61 KB
14.1 KB
29.1 KB
163 KB
12.4 KB
35.3 KB
28 KB
12.9 KB
35.7 KB

assets/resources/ios/Default.png

3.6 KB
5.88 KB
4.72 KB
15.4 KB
5.87 KB
12.9 KB

assets/resources/ios/icon-1024.png

19.7 KB

assets/resources/ios/icon-29.png

498 Bytes
916 Bytes
1.33 KB

assets/resources/ios/icon-40.png

666 Bytes
1.22 KB
1.78 KB
1.78 KB
2.74 KB

assets/resources/ios/icon-76.png

1.17 KB
2.27 KB
2.53 KB

assets/resources/star.png

3.36 KB

core/settings/Settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def get_project_home():
5656
TEST_OUT_LOGS = os.path.join(TEST_OUT_HOME, 'logs')
5757
TEST_OUT_IMAGES = os.path.join(TEST_OUT_HOME, 'images')
5858

59+
ASSETS_HOME = os.path.join(TEST_RUN_HOME, 'assets')
60+
5961
SSH_CLONE = os.environ.get('SSH_CLONE', False)
6062

6163

run_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __get_templates():
5757

5858
# Tar local templates in assets folder
5959
template_name = 'template-min'
60-
template_folder = os.path.join(Settings.TEST_RUN_HOME, 'assets', template_name)
60+
template_folder = os.path.join(Settings.ASSETS_HOME, template_name)
6161
out_file = os.path.join(Settings.TEST_SUT_HOME, template_name + '.tgz')
6262
Npm.pack(folder=template_folder, output_file=out_file)
6363

tests/cli/resources/resources.md

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Tests for 'resources generate' icons and splashes
3+
"""
4+
import os
5+
6+
from core.base_test.tns_test import TnsTest
7+
from core.settings import Settings
8+
from core.utils.file_utils import Folder
9+
from data.templates import Template
10+
from products.nativescript.tns import Tns
11+
from products.nativescript.tns_assert import TnsAssert
12+
13+
APP_NAME = Settings.AppName.DEFAULT
14+
APP_NAME_OLD = 'TestApp4'
15+
16+
17+
# noinspection PyMethodMayBeStatic
18+
class ResourcesGenerateTests(TnsTest):
19+
resources = os.path.join(Settings.ASSETS_HOME, 'resources')
20+
expected_images_android = os.path.join(resources, 'android')
21+
expected_images_ios = os.path.join(resources, 'ios')
22+
star_image = os.path.join(resources, 'star.png')
23+
24+
@classmethod
25+
def setUpClass(cls):
26+
TnsTest.setUpClass()
27+
Tns.create(app_name=APP_NAME, template=Template.HELLO_WORLD_JS.local_package, update=True)
28+
29+
@classmethod
30+
def tearDownClass(cls):
31+
TnsTest.tearDownClass()
32+
Folder.clean(os.path.join(Settings.TEST_RUN_HOME, APP_NAME_OLD))
33+
34+
def test_001_tns_resources_generate_icons(self):
35+
command = 'resources generate icons {0}'.format(self.star_image)
36+
result = Tns.exec_command(command=command, path=APP_NAME)
37+
assert 'Generating icons' in result.output
38+
assert 'Icons generation completed' in result.output
39+
assert 'Invalid settings specified for the resizer' not in result.output
40+
41+
def test_200_tns_resources_generate_splashes(self):
42+
command = 'resources generate splashes {0} --background green'.format(self.star_image)
43+
result = Tns.exec_command(command=command, path=APP_NAME)
44+
assert 'Generating splash screens' in result.output
45+
assert 'Splash screens generation completed' in result.output
46+
47+
def test_300_tns_resources_generate_icons_apetools(self):
48+
# Test for https://github.com/NativeScript/nativescript-cli/issues/3666
49+
50+
# Simulate resources generated with apetools
51+
# TODO: Implement it!
52+
53+
# Generate icons with nativescript
54+
self.test_001_tns_resources_generate_icons()
55+
56+
def test_301_tns_resources_generate_icons_old_template_structure(self):
57+
# Create nativescript@4 app
58+
result = Tns.create(app_name=APP_NAME, template='[email protected]', verify=False)
59+
TnsAssert.created(app_name=APP_NAME, output=result.output, webpack=False)
60+
61+
# Generate icons with nativescript
62+
self.test_001_tns_resources_generate_icons()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Tests for 'resources generate' icons and splashes
3+
"""
4+
5+
from core.base_test.tns_test import TnsTest
6+
from core.settings import Settings
7+
from data.templates import Template
8+
from products.nativescript.tns import Tns
9+
from products.nativescript.tns_assert import TnsAssert
10+
11+
APP_NAME = Settings.AppName.DEFAULT
12+
13+
14+
# noinspection PyMethodMayBeStatic
15+
class ResourcesUpdateTests(TnsTest):
16+
17+
def test_300_tns_resources_update(self):
18+
# Create nativescript@3 app
19+
result = Tns.create(app_name=APP_NAME, template='[email protected]', verify=False, update=False)
20+
TnsAssert.created(app_name=APP_NAME, output=result.output, webpack=False)
21+
22+
# Update resources
23+
out = Tns.exec_command(command='resources update', path=APP_NAME).output
24+
assert "Successfully updated your project's application resources '/Android' directory structure." in out
25+
assert "The previous version of your Android application resources has been renamed to '/Android-Pre-v4'" in out
26+
27+
def test_301_tns_resources_update_on_updated_project(self):
28+
result = Tns.create(app_name=APP_NAME, template=Template.MIN_JS.local_package, verify=False, update=False)
29+
TnsAssert.created(app_name=APP_NAME, output=result.output, webpack=False, theme=False)
30+
result = Tns.exec_command(command='resources update', path=APP_NAME)
31+
assert 'The App_Resources have already been updated for the Android platform.' in result.output

0 commit comments

Comments
 (0)