Skip to content

Add test for jar file in plugin: android-runtime PR905 #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions data/issues/android-runtime-pr-905/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
In NativeScript, the app.js file is the entry point to your application.
You can use this file to perform app-level initialization, but the primary
purpose of the file is to pass control to the app’s first module.
*/

require("./bundle-config");
var application = require("application");

com.example.lib.myClass.doSomethingMethodFromJar("jar file loaded!")
application.start({ moduleName: "main-page" });

/*
Do not place any code after the application has been started as it will not
be executed on iOS.
*/
Binary file added data/issues/android-runtime-pr-905/customLib.jar
Binary file not shown.
30 changes: 30 additions & 0 deletions tests/emulator/run_android_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,36 @@ def test_350_tns_run_android_should_start_emulator(self):
else:
raise nose.SkipTest('This test is not valid when devices are connected.')

def test_360_tns_run_android_with_jar_file_in_plugin(self):
"""
App should not crash when reference .jar file in some plugin
https://github.com/NativeScript/android-runtime/pull/905
"""

# Create app
Tns.create_app(self.app_name)

# Add .jar file in plugin and modify the app to reference it
custom_jar_file = os.path.join('data', 'issues', 'android-runtime-pr-905', 'customLib.jar')
modules_widgets = os.path.join(self.app_name, 'node_modules', 'tns-core-modules-widgets', 'platforms', 'android')
File.copy(src=custom_jar_file, dest=modules_widgets)

source = os.path.join('data', 'issues', 'android-runtime-pr-905', 'app.js')
target = os.path.join(self.app_name, 'app', 'app.js')
File.copy(src=source, dest=target)

# `tns run android` and wait until app is deployed
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
assert_success=False)
strings = ['Project successfully built',
'Successfully installed on device with identifier', EMULATOR_ID,
'Successfully synced application']
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)

# Verify app looks correct inside emulator
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
expected_image='livesync-hello-world_home')

@unittest.skip("Skip because of https://github.com/NativeScript/nativescript-cli/issues/2825")
def test_390_tns_run_android_should_warn_if_package_ids_do_not_match(self):
"""
Expand Down