Skip to content

Commit 2f02060

Browse files
author
Vasil Hristov
authored
Add test for issue 1571.Change NDK version in snapshot tests. (#469)
1 parent 28bb2f8 commit 2f02060

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "org.nativescript.TestApp"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
dependencies {
10+
implementation 'androidx.core:core-ktx:1.0.2'
11+
}
12+
repositories{
13+
maven { url "https://jitpack.io" }
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var createViewModel = require("./main-view-model").createViewModel;
2+
//var AlbumSelectActivity = $in.myinnos.awesomeimagepicker.activities.AlbumSelectActivity;
3+
4+
function onNavigatingTo(args) {
5+
var page = args.object;
6+
page.bindingContext = createViewModel();
7+
sleep(2000);
8+
console.log("###TEST PASSED###");
9+
}
10+
exports.onNavigatingTo = onNavigatingTo;
11+
12+
function sleep(milliseconds) {
13+
var start = new Date().getTime();
14+
for (var i = 0; i < 1e7; i++) {
15+
if ((new Date().getTime() - start) > milliseconds){
16+
break;
17+
}
18+
}
19+
}

tests/runtimes/android/abi_split_with_snapshot_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ def test_100_build_app_with_abi_split_and_snapshot(self):
5454
new_string = "webpackConfig: config,\
5555
targetArchs: [ \"arm\", \"arm64\", \"ia32\", \"ia64\" ],\
5656
useLibs: true,\
57-
androidNdkPath: \"/tns-official/NDK/android-ndk-r19c-linux/\","
57+
androidNdkPath: \"/tns-official/NDK/android-ndk-r21-linux/\","
5858
elif platform == "darwin":
5959
new_string = "webpackConfig: config,\
6060
targetArchs: [ \"arm\", \"arm64\", \"ia32\", \"ia64\" ],\
6161
useLibs: true,\
62-
androidNdkPath: \"/tns-official/NDK/android-ndk-r19c-mac/\","
62+
androidNdkPath: \"/tns-official/NDK/android-ndk-r21-mac/\","
6363

6464
target_file = os.path.join(TEST_RUN_HOME, APP_NAME, 'webpack.config.js')
6565
File.replace(target_file, old_string, new_string)

tests/runtimes/android/android_app_gradle_tests.py

+24
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,27 @@ def test_452_assert_static_binding_generator_is_generating_correct_code(self):
252252
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=320,
253253
period=5)
254254
assert test_result, 'Static binding generator did not generated code! Logs: ' + File.read(log.log_file)
255+
256+
def test_453_native_package_with_kotlin_are_working(self):
257+
"""
258+
Test native packages with kotlin are working
259+
https://github.com/NativeScript/android-runtime/issues/1571
260+
"""
261+
# Change main-page.js so it contains only logging information
262+
source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1571',
263+
'main-page.js')
264+
target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'main-page.js')
265+
File.copy(source=source_js, target=target_js, backup_files=True)
266+
# Change app app.gradle so it contains the dependencies to androidx.core:core-ktx:1.0.2
267+
source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1571',
268+
'app.gradle')
269+
target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'app.gradle')
270+
File.copy(source=source_js, target=target_js, backup_files=True)
271+
log = Tns.run_android(APP_NAME, device=self.emulator.id, wait=False, verify=False)
272+
273+
strings = ['Project successfully built', 'Successfully installed on device with identifier', self.emulator.id]
274+
275+
Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=240, period=5)
276+
277+
test_result = Wait.until(lambda: "###TEST PASSED###" in File.read(log.log_file), timeout=100, period=5)
278+
assert test_result, 'Native packages with kotlin are not working! Logs:' + File.read(log.log_file)

0 commit comments

Comments
 (0)