Skip to content

Commit c420fc3

Browse files
author
Natalia Hristova
authored
Add test for jar file in plugin: android-runtime PR905 (#89)
1 parent 88494cd commit c420fc3

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
In NativeScript, the app.js file is the entry point to your application.
3+
You can use this file to perform app-level initialization, but the primary
4+
purpose of the file is to pass control to the app’s first module.
5+
*/
6+
7+
require("./bundle-config");
8+
var application = require("application");
9+
10+
com.example.lib.myClass.doSomethingMethodFromJar("jar file loaded!")
11+
application.start({ moduleName: "main-page" });
12+
13+
/*
14+
Do not place any code after the application has been started as it will not
15+
be executed on iOS.
16+
*/
1.01 KB
Binary file not shown.

tests/emulator/run_android_tests.py

+30
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,36 @@ def test_350_tns_run_android_should_start_emulator(self):
507507
else:
508508
raise nose.SkipTest('This test is not valid when devices are connected.')
509509

510+
def test_360_tns_run_android_with_jar_file_in_plugin(self):
511+
"""
512+
App should not crash when reference .jar file in some plugin
513+
https://github.com/NativeScript/android-runtime/pull/905
514+
"""
515+
516+
# Create app
517+
Tns.create_app(self.app_name)
518+
519+
# Add .jar file in plugin and modify the app to reference it
520+
custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
521+
modules_widgets = os.path.join(self.app_name, 'node_modules', 'tns-core-modules-widgets', 'platforms', 'android')
522+
File.copy(src=custom_jar_file, dest=modules_widgets)
523+
524+
source = os.path.join('data', 'issues', 'android-runtime-pr-905', 'app.js')
525+
target = os.path.join(self.app_name, 'app', 'app.js')
526+
File.copy(src=source, dest=target)
527+
528+
# `tns run android` and wait until app is deployed
529+
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
530+
assert_success=False)
531+
strings = ['Project successfully built',
532+
'Successfully installed on device with identifier', EMULATOR_ID,
533+
'Successfully synced application']
534+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
535+
536+
# Verify app looks correct inside emulator
537+
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
538+
expected_image='livesync-hello-world_home')
539+
510540
@unittest.skip("Skip because of https://github.com/NativeScript/nativescript-cli/issues/2825")
511541
def test_390_tns_run_android_should_warn_if_package_ids_do_not_match(self):
512542
"""

0 commit comments

Comments
 (0)