Skip to content

Add tests for kotlin and gradle.properties. #354

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 2 commits into from
Aug 30, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useKotlin=true
8 changes: 8 additions & 0 deletions core/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ def get_files_names_in_zip(file_path):
zfile.close()
return file_names

@staticmethod
def is_file_in_zip(zip_file, file_name_to_check):
files_list = File.get_files_names_in_zip(zip_file)
for current_file in files_list:
if file_name_to_check in str(current_file.filename):
return True
return False

@staticmethod
def download(file_name, url, destination_dir=Settings.TEST_RUN_HOME):
file_path = os.path.join(destination_dir, file_name)
Expand Down
24 changes: 8 additions & 16 deletions tests/runtimes/android/abi_split_with_snapshot_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ def setUpClass(cls):
Adb.uninstall(cls.app_id, device_id, assert_success=False)
Tns.platform_add_android(APP_NAME, framework_path=Android.FRAMEWORK_PATH)

@staticmethod
def check_file_in_zip(zip_file, file_name_to_check):
files_list = File.get_files_names_in_zip(zip_file)
for current_file in files_list:
if file_name_to_check in str(current_file.filename):
return True
return False

def test_100_build_app_with_abi_split_and_snapshot(self):
"""
Test build with abi split and snapshot. Also check if the apk for emulator is working
Expand Down Expand Up @@ -83,31 +75,31 @@ def test_100_build_app_with_abi_split_and_snapshot(self):

app_x86_64_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
"app-x86_64-release.apk")
assert self.check_file_in_zip(app_x86_64_release_path, os.path.join("x86_64", "libNativeScript.so"))
assert File.is_file_in_zip(app_x86_64_release_path, os.path.join("x86_64", "libNativeScript.so"))
assert File.exists(app_x86_64_release_path)

app_arm64_v8a_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
"app-arm64-v8a-release.apk")
assert File.exists(app_arm64_v8a_release_path)
assert self.check_file_in_zip(app_arm64_v8a_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
assert File.is_file_in_zip(app_arm64_v8a_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))

app_armeabi_v7a_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
"app-armeabi-v7a-release.apk")
assert File.exists(app_armeabi_v7a_release_path)
assert self.check_file_in_zip(app_armeabi_v7a_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
assert File.is_file_in_zip(app_armeabi_v7a_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))

app_x86_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
"app-x86-release.apk")
assert File.exists(app_x86_release_path)
assert self.check_file_in_zip(app_x86_release_path, os.path.join("x86", "libNativeScript.so"))
assert File.is_file_in_zip(app_x86_release_path, os.path.join("x86", "libNativeScript.so"))

app_universal_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH,
"app-universal-release.apk")
assert File.exists(app_universal_release_path)
assert self.check_file_in_zip(app_universal_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
assert self.check_file_in_zip(app_universal_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
assert self.check_file_in_zip(app_universal_release_path, os.path.join("x86", "libNativeScript.so"))
assert self.check_file_in_zip(app_universal_release_path, os.path.join("x86_64", "libNativeScript.so"))
assert File.is_file_in_zip(app_universal_release_path, os.path.join("arm64-v8a", "libNativeScript.so"))
assert File.is_file_in_zip(app_universal_release_path, os.path.join("armeabi-v7a", "libNativeScript.so"))
assert File.is_file_in_zip(app_universal_release_path, os.path.join("x86", "libNativeScript.so"))
assert File.is_file_in_zip(app_universal_release_path, os.path.join("x86_64", "libNativeScript.so"))

AbiSplitHelper.assert_apk(
os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_RELEASE_PATH, "app-x86-release.apk"),
Expand Down
21 changes: 21 additions & 0 deletions tests/runtimes/android/android_plugins_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from data.templates import Template
from products.nativescript.tns import Tns

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


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

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

Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)

def test_452_support_gradle_properties_for_enable_Kotlin(self):
"""
Support gradle.properties file for enable Kotlin
https://github.com/NativeScript/android-runtime/issues/1459
https://github.com/NativeScript/android-runtime/issues/1463
"""
Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
'android-runtime-1463-1459', 'gradle.properties')
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)

Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)
app_universal_release_path = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_DEBUG_PATH,
"app-debug.apk")
assert File.exists(app_universal_release_path)
assert File.is_file_in_zip(app_universal_release_path, os.path.join("kotlin")), "Kotlin is not working!"
2 changes: 1 addition & 1 deletion tests/runtimes/ios/ios_runtime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_201_test_init_mocha_js_stacktrace(self):
# https://github.com/NativeScript/nativescript-cli/issues/4524
strings = ['JavaScript stack trace',
'JS ERROR AssertionError: expected -1 to equal 1']
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=90)
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=120)

def test_380_tns_run_ios_plugin_dependencies(self):
"""
Expand Down