Skip to content

Commit 9be643d

Browse files
committed
Update test_200_calling_custom_generated_classes_declared_in_manifest
1 parent 41f4281 commit 9be643d

Some content is hidden

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

42 files changed

+33
-185
lines changed

core/device/helpers/adb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get_logcat(device_id):
6868
Dump the log and then exit (don't block).
6969
:param device_id: Device id.
7070
"""
71-
Adb.run(command='logcat -d', device_id=device_id)
71+
return Adb.run(command='logcat -d', device_id=device_id)
7272

7373
@staticmethod
7474
def clear_logcat(device_id):

data/apps/sbg-test-app.tgz

1.46 MB
Binary file not shown.

data/apps/sbg-test-app/App_Resources/Android/AndroidManifest.xml

-41
This file was deleted.

data/apps/sbg-test-app/App_Resources/Android/app.gradle

-15
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

data/apps/sbg-test-app/App_Resources/iOS/Info.plist

-66
This file was deleted.

data/apps/sbg-test-app/App_Resources/iOS/build.xcconfig

-5
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-31.5 KB
Binary file not shown.
Binary file not shown.

data/apps/sbg-test-app/app.js

Whitespace-only changes.

data/apps/sbg-test-app/custom-nativescript-activity.js

-22
This file was deleted.

data/apps/sbg-test-app/my-custom-class.js

-17
This file was deleted.

data/apps/sbg-test-app/package.json

-18
This file was deleted.

tests/build/android/prepare_android_tests.py

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def test_310_prepare_should_flatten_scoped_dependencies(self):
129129
ng_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_NPM_MODULES_PATH, '@angular', 'core')
130130
assert File.exists(ng_path), "Scoped dependencies are flattened, please see #1783!"
131131

132+
def test_320_unmet_peer_dependencies_do_not_stop_prepare(self):
133+
Tns.create_app_ng(self.app_name, update_modules=False)
134+
# Cleanup node_modules and let CLI install npm dependencies
135+
Folder.cleanup(os.path.join(TEST_RUN_HOME, self.app_name, 'node_modules'))
136+
output = Tns.prepare_android(attributes={"--path": self.app_name})
137+
assert "requires a peer of tns-core-modules" in output, "No npm warning for unmet peer dependencies."
138+
assert "but none was installed" in output, "No npm warning for unmet peer dependencies."
139+
132140
def test_400_prepare_missing_or_missing_platform(self):
133141
Tns.create_app(self.app_name, update_modules=False)
134142

tests/emulator/android_runtime_tests.py

+24
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22
Test for specific needs of Android runtime.
33
"""
44
import os
5+
import subprocess
6+
import threading
57
from time import sleep
68

79
from core.base_class.BaseClass import BaseClass
810
from core.device.emulator import Emulator
11+
from core.device.helpers.adb import ADB_PATH, Adb
912
from core.osutils.file import File
1013
from core.osutils.folder import Folder
1114
from core.settings.settings import ANDROID_RUNTIME_PATH, EMULATOR_ID
1215
from core.tns.tns import Tns
1316

1417

1518
class RuntimeTests(BaseClass):
19+
custom_js_file = os.path.join(BaseClass.app_name, "app", "my-custom-class.js")
20+
tns_folder = os.path.join(BaseClass.app_name, "platforms", "android", "src", "main", "java", "com", "tns")
21+
gen_folder = os.path.join(tns_folder, "gen")
22+
generated_java_file = os.path.join(tns_folder, "MyJavaClass.java")
23+
1624
@classmethod
1725
def setUpClass(cls):
1826
logfile = os.path.join("out", cls.__name__ + ".txt")
@@ -25,6 +33,22 @@ def tearDownClass(cls):
2533
BaseClass.tearDownClass()
2634
Folder.cleanup(cls.app_name)
2735

36+
def test_200_calling_custom_generated_classes_declared_in_manifest(self):
37+
Tns.create_app(self.app_name, attributes={"--template": os.path.join("data", "apps", "sbg-test-app.tgz")})
38+
Tns.platform_add_android(attributes={"--frameworkPath": ANDROID_RUNTIME_PATH, "--path": self.app_name})
39+
Adb.clear_logcat(device_id=EMULATOR_ID)
40+
Tns.run_android(attributes={"--path": self.app_name, "--device": EMULATOR_ID, "--justlaunch": ""})
41+
sleep(10)
42+
output = Adb.get_logcat(device_id=EMULATOR_ID)
43+
44+
# make sure app hasn't crashed
45+
assert "Displayed org.nativescript.TNSApp/com.tns.ErrorReportActivity" not in output, \
46+
"App crashed with error activity"
47+
# check if we got called from custom activity that overrides the default one
48+
assert "we got called from onCreate of custom-nativescript-activity.js" in output, "Expected output not found"
49+
# make sure we called custom activity declared in manifest
50+
assert "we got called from onCreate of my-custom-class.js" in output, "Expected output not found"
51+
2852
def test_300_verbose_log_android(self):
2953
Tns.create_app(self.app_name,
3054
attributes={"--template": os.path.join("data", "apps", "verbose-hello-world.tgz")})

0 commit comments

Comments
 (0)