Skip to content
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
22 changes: 22 additions & 0 deletions assets/runtime/android/files/android-runtime-689/app.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
// implementation 'com.android.support:recyclerview-v7:+'
//}

// If you want to add something to be applied before applying plugins' include.gradle files
// e.g. project.ext.googlePlayServicesVersion = "15.0.1"
// create a file named before-plugins.gradle in the current directory and place it there

android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
dependencies {
compile 'de.mrmaffen:vlc-android-sdk:2.0.6'
}
}
14 changes: 14 additions & 0 deletions assets/runtime/android/files/android-runtime-689/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
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.
*/

const application = require("tns-core-modules/application");

application.run({ moduleName: "app-root" });

/*
Do not place any code after the application has been started as it will not
be executed on iOS.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Observable = require("tns-core-modules/data/observable").Observable;

function getMessage(counter) {
if (counter <= 0) {
return "Hoorraaay! You unlocked the NativeScript clicker achievement!";
} else {
return `${counter} taps left`;
}
}

function createViewModel() {
const viewModel = new Observable();
viewModel.counter = 42;
viewModel.message = getMessage(viewModel.counter);
var test = new org.videolan.libvlc.MediaPlayer.EventListener({
onEvent: function() {
console.log("Test Pass!");
}
})
test.onEvent();
viewModel.onTap = () => {
viewModel.counter--;
viewModel.set("message", getMessage(viewModel.counter));
};

return viewModel;
}

exports.createViewModel = createViewModel;
27 changes: 27 additions & 0 deletions tests/runtimes/android/android_app_gradle_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,30 @@ def test_450_support_external_buildscript_config_in_app_res_android_folder(self)
Tns.platform_add_android(APP_NAME, framework_path=Android.FRAMEWORK_PATH)

Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)

def test_452_assert_static_binding_generator_is_generating_correct_code(self):
"""
Test static binding generator is generationg correct code
https://github.com/NativeScript/android-runtime/issues/689
"""
source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-689',
'app.js')
target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'app.js')
File.copy(source=source_js, target=target_js)
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-689',
'app.gradle')
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'app.gradle')
File.copy(source=source_app_gradle, target=target_app_gradle)

source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-689',
'main-view-model.js')
target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'main-view-model.js')
File.copy(source=source_js, target=target_js)

log = Tns.run_android(APP_NAME, device=self.emulator.id, wait=False, verify=False)

strings = ['Successfully synced application', 'on device', self.emulator.id,
'Test Pass!']
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=320,
period=5)
assert test_result, 'Static binding generator did not generated code! Logs: ' + File.read(log.log_file)