Skip to content

Commit ad25929

Browse files
author
Vasil Hristov
authored
Merge pull request #354 from NativeScript/vhristov/add_kotlin_tests
Add tests for kotlin and gradle.properties.
2 parents 97706a9 + 25272de commit ad25929

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
useKotlin=true

core/utils/file_utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ def get_files_names_in_zip(file_path):
306306
zfile.close()
307307
return file_names
308308

309+
@staticmethod
310+
def is_file_in_zip(zip_file, file_name_to_check):
311+
files_list = File.get_files_names_in_zip(zip_file)
312+
for current_file in files_list:
313+
if file_name_to_check in str(current_file.filename):
314+
return True
315+
return False
316+
309317
@staticmethod
310318
def download(file_name, url, destination_dir=Settings.TEST_RUN_HOME):
311319
file_path = os.path.join(destination_dir, file_name)

tests/runtimes/android/abi_split_with_snapshot_tests.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ def setUpClass(cls):
4141
Adb.uninstall(cls.app_id, device_id, assert_success=False)
4242
Tns.platform_add_android(APP_NAME, framework_path=Android.FRAMEWORK_PATH)
4343

44-
@staticmethod
45-
def check_file_in_zip(zip_file, file_name_to_check):
46-
files_list = File.get_files_names_in_zip(zip_file)
47-
for current_file in files_list:
48-
if file_name_to_check in str(current_file.filename):
49-
return True
50-
return False
51-
5244
def test_100_build_app_with_abi_split_and_snapshot(self):
5345
"""
5446
Test build with abi split and snapshot. Also check if the apk for emulator is working
@@ -83,31 +75,31 @@ def test_100_build_app_with_abi_split_and_snapshot(self):
8375

8476
app_x86_64_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
8577
"app-x86_64-release.apk")
86-
assert self.check_file_in_zip(app_x86_64_release_path, os.path.join("x86_64", "libNativeScript.so"))
78+
assert File.is_file_in_zip(app_x86_64_release_path, os.path.join("x86_64", "libNativeScript.so"))
8779
assert File.exists(app_x86_64_release_path)
8880

8981
app_arm64_v8a_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
9082
"app-arm64-v8a-release.apk")
9183
assert File.exists(app_arm64_v8a_release_path)
92-
assert self.check_file_in_zip(app_arm64_v8a_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
84+
assert File.is_file_in_zip(app_arm64_v8a_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
9385

9486
app_armeabi_v7a_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
9587
"app-armeabi-v7a-release.apk")
9688
assert File.exists(app_armeabi_v7a_release_path)
97-
assert self.check_file_in_zip(app_armeabi_v7a_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
89+
assert File.is_file_in_zip(app_armeabi_v7a_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
9890

9991
app_x86_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
10092
"app-x86-release.apk")
10193
assert File.exists(app_x86_release_path)
102-
assert self.check_file_in_zip(app_x86_release_path, os.path.join("x86", "libNativeScript.so"))
94+
assert File.is_file_in_zip(app_x86_release_path, os.path.join("x86", "libNativeScript.so"))
10395

10496
app_universal_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
10597
"app-universal-release.apk")
10698
assert File.exists(app_universal_release_path)
107-
assert self.check_file_in_zip(app_universal_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
108-
assert self.check_file_in_zip(app_universal_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
109-
assert self.check_file_in_zip(app_universal_release_path, os.path.join("x86", "libNativeScript.so"))
110-
assert self.check_file_in_zip(app_universal_release_path, os.path.join("x86_64", "libNativeScript.so"))
99+
assert File.is_file_in_zip(app_universal_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
100+
assert File.is_file_in_zip(app_universal_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
101+
assert File.is_file_in_zip(app_universal_release_path, os.path.join("x86", "libNativeScript.so"))
102+
assert File.is_file_in_zip(app_universal_release_path, os.path.join("x86_64", "libNativeScript.so"))
111103

112104
AbiSplitHelper.assert_apk(
113105
os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH, "app-x86-release.apk"),

tests/runtimes/android/android_plugins_tests.py

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from data.templates import Template
1414
from products.nativescript.tns import Tns
1515

16+
PLATFORM_ANDROID_APK_DEBUG_PATH = os.path.join('platforms', 'android', 'app', 'build', 'outputs', 'apk', 'debug')
1617
APP_NAME = AppName.DEFAULT
1718

1819

@@ -331,3 +332,23 @@ def test_451_support_external_buildscript_config_in_plugin(self):
331332
Tns.plugin_add(plugin_path, path=APP_NAME, verify=False)
332333

333334
Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)
335+
336+
Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
337+
338+
def test_452_support_gradle_properties_for_enable_Kotlin(self):
339+
"""
340+
Support gradle.properties file for enable Kotlin
341+
https://github.com/NativeScript/android-runtime/issues/1459
342+
https://github.com/NativeScript/android-runtime/issues/1463
343+
"""
344+
Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
345+
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
346+
'android-runtime-1463-1459', 'gradle.properties')
347+
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
348+
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)
349+
350+
Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)
351+
app_universal_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_DEBUG_PATH,
352+
"app-debug.apk")
353+
assert File.exists(app_universal_release_path)
354+
assert File.is_file_in_zip(app_universal_release_path, os.path.join("kotlin")), "Kotlin is not working!"

tests/runtimes/ios/ios_runtime_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_201_test_init_mocha_js_stacktrace(self):
6565
# https://github.com/NativeScript/nativescript-cli/issues/4524
6666
strings = ['JavaScript stack trace',
6767
'JS ERROR AssertionError: expected -1 to equal 1']
68-
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90)
68+
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)
6969

7070
def test_380_tns_run_ios_plugin_dependencies(self):
7171
"""

0 commit comments

Comments
 (0)