Skip to content

Commit 01673b5

Browse files
authored
Merge pull request #423 from NativeScript/release
core: merge release 6.2.0 in master
2 parents c5676e5 + 2e14c22 commit 01673b5

File tree

11 files changed

+240
-224
lines changed

11 files changed

+240
-224
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gatherAnalyticsData=true
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
useKotlin=true
1+
useKotlin=true
2+
gatherAnalyticsData=true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
useKotlin=true

data/sync/blank_vue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55

66
from core.enums.app_type import AppType
7+
from core.enums.os_type import OSType
78
from core.log.log import Log
89
from core.settings import Settings
910
from core.utils.wait import Wait
@@ -47,7 +48,7 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
4748
device.get_screen(path=initial_state)
4849

4950
# Verify that application is not restarted on file changes when hmr=true
50-
if hmr:
51+
if hmr and Settings.HOST_OS != OSType.WINDOWS:
5152
not_existing_string_list = ['Restarting application']
5253
else:
5354
not_existing_string_list = None

data/sync/hello_world_js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=True,
8383
raise ValueError('Invalid app_type value.')
8484

8585
# Verify that application is not restarted on file changes when hmr=true
86-
if hmr:
86+
if hmr and Settings.HOST_OS != OSType.WINDOWS:
8787
not_existing_string_list = ['Restarting application']
8888
else:
8989
not_existing_string_list = None

data/sync/hello_world_ng.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from core.enums.app_type import AppType
88
from core.enums.device_type import DeviceType
99
from core.enums.platform_type import Platform
10+
from core.enums.os_type import OSType
1011
from core.settings import Settings
1112
from data.changes import Changes, Sync
1213
from data.const import Colors
@@ -48,7 +49,7 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a
4849
result = run_hello_world_ng(app_name=app_name, platform=platform, device=device, uglify=uglify, aot=aot, hmr=hmr)
4950

5051
# Verify that application is not restarted on file changes when hmr=true
51-
if hmr:
52+
if hmr and Settings.HOST_OS != OSType.WINDOWS:
5253
not_existing_string_list = ['Restarting application']
5354
else:
5455
not_existing_string_list = None
@@ -142,7 +143,7 @@ def preview_sync_hello_world_ng(app_name, platform, device, bundle=True, hmr=Tru
142143
instrumented=instrumented, click_open_alert=click_open_alert)
143144

144145
# Verify that application is not restarted on file changes when hmr=true
145-
if hmr:
146+
if hmr and Settings.HOST_OS != OSType.WINDOWS:
146147
not_existing_string_list = ['Restarting application']
147148
else:
148149
not_existing_string_list = None

data/sync/master_detail_vue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from core.enums.app_type import AppType
99
from core.enums.platform_type import Platform
10+
from core.enums.os_type import OSType
1011
from core.settings import Settings
1112
from core.utils.appium.appium_driver import AppiumDriver
1213
from core.utils.wait import Wait
@@ -37,7 +38,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True):
3738
device.get_screen(path=initial_state)
3839

3940
# Verify that application is not restarted on file changes when hmr=true
40-
if hmr:
41+
if hmr and Settings.HOST_OS != OSType.WINDOWS:
4142
not_existing_string_list = ['Restarting application']
4243
else:
4344
not_existing_string_list = None

tests/cli/build/android_app_bundle_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_100_run_android_app_bundle_compile_snapshot(self):
8585

8686
# Verify app can be deployed on emulator via nativescript
8787
# Verify app looks correct inside emulator
88-
self.emu.wait_for_text(text='TAP')
88+
self.emu.wait_for_text(text='TAP', timeout=240)
8989

9090
# Verify that the correct .so file is included in the package
9191
File.unzip(path_to_apks, os.path.join(self.app_name, 'apks'))

tests/runtimes/android/android_plugins_tests.py

Lines changed: 128 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
# pylint: disable=invalid-name
55
import os
6+
import json
67

78
from core.base_test.tns_test import TnsTest
89
from core.utils.assertions import Assert
@@ -19,6 +20,7 @@
1920
PLATFORM_ANDROID_APK_DEBUG_PATH = os.path.join('platforms', 'android', 'app', 'build', 'outputs', 'apk', 'debug')
2021
APP_NAME = AppName.DEFAULT
2122
APK_DEBUG_PATH = os.path.join(TEST_RUN_HOME, APP_NAME, PLATFORM_ANDROID_APK_DEBUG_PATH, "app-debug.apk")
23+
ANALYTICS_FILE = os.path.join(TEST_RUN_HOME, APP_NAME, 'platforms', 'android', 'analytics', 'build-statistics.json')
2224

2325

2426
class AndroidRuntimePluginTests(TnsTest):
@@ -39,6 +41,14 @@ def tearDownClass(cls):
3941
TnsTest.tearDownClass()
4042
Folder.clean(os.path.join(TEST_RUN_HOME, APP_NAME))
4143

44+
@staticmethod
45+
def assert_kotlin_is_working(emulator):
46+
assert File.exists(APK_DEBUG_PATH)
47+
assert File.is_file_in_zip(APK_DEBUG_PATH, os.path.join("kotlin")), "Kotlin is not working!"
48+
Device.click(emulator, text="TAP", case_sensitive=True)
49+
error_message = "Kotlin code is not executed correctly! Logs: "
50+
assert "Kotlin is here!" in Adb.get_logcat(emulator.id), error_message + Adb.get_logcat(emulator.id)
51+
4252
def test_308_native_package_in_plugin_include_gradle_with_compile(self):
4353
"""
4454
Test native packages in plugin could be used with compile in include gradle
@@ -334,17 +344,8 @@ def test_451_support_external_buildscript_config_in_plugin(self):
334344
Tns.plugin_add(plugin_path, path=APP_NAME, verify=False)
335345

336346
Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)
337-
338347
Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
339348

340-
@staticmethod
341-
def assert_kotlin_is_working(emulator):
342-
assert File.exists(APK_DEBUG_PATH)
343-
assert File.is_file_in_zip(APK_DEBUG_PATH, os.path.join("kotlin")), "Kotlin is not working!"
344-
Device.click(emulator, text="TAP", case_sensitive=True)
345-
error_message = "Kotlin code is not executed correctly! Logs: "
346-
assert "Kotlin is here!" in Adb.get_logcat(emulator.id), error_message + Adb.get_logcat(emulator.id)
347-
348349
def test_452_support_gradle_properties_for_enable_Kotlin_with_jar(self):
349350
"""
350351
Support gradle.properties file for enable Kotlin
@@ -371,22 +372,75 @@ def test_452_support_gradle_properties_for_enable_Kotlin_with_jar(self):
371372
strings = ['Project successfully built',
372373
'Successfully installed on device with identifier', self.emulator.id,
373374
'Successfully synced application']
374-
375375
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=300,
376376
period=5)
377377
messages = "App with Kotlin enabled and kotlin jar not build correctly! Logs: "
378378
assert test_result, messages + File.read(log.log_file)
379379

380380
self.assert_kotlin_is_working(self.emulator)
381+
with open(ANALYTICS_FILE, "r") as read_file:
382+
data = json.load(read_file)
383+
error_message = "kotlinUsage->hasKotlinRuntimeClasses is not set to True! Analytics is not correct!"
384+
assert data["kotlinUsage"]["hasKotlinRuntimeClasses"] is True, error_message
385+
error_message = "kotlinUsage->hasUseKotlinPropertyInApp is not set to True! Analytics is not correct!"
386+
assert data["kotlinUsage"]["hasUseKotlinPropertyInApp"] is True, error_message
387+
388+
def test_453_support_Kotlin_with_jar_without_use_kotlin(self):
389+
"""
390+
Support gradle.properties file for enable Kotlin
391+
https://github.com/NativeScript/android-runtime/issues/1459
392+
https://github.com/NativeScript/android-runtime/issues/1463
393+
"""
394+
395+
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
396+
'android-runtime-1463-1459', 'analytics', 'gradle.properties')
397+
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
398+
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)
399+
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
400+
'android-runtime-1463-1459', 'test-jar-1.0-SNAPSHOT.jar')
401+
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'libs')
402+
Folder.create(target_app_gradle)
403+
Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True)
404+
405+
with open(ANALYTICS_FILE, "r") as read_file:
406+
data = json.load(read_file)
407+
error_message = "kotlinUsage->hasKotlinRuntimeClasses is not set to False! Analytics is not correct!"
408+
assert data["kotlinUsage"]["hasKotlinRuntimeClasses"] is False, error_message
409+
error_message = "kotlinUsage->hasUseKotlinPropertyInApp is not set to False! Analytics is not correct!"
410+
assert data["kotlinUsage"]["hasUseKotlinPropertyInApp"] is False, error_message
411+
412+
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)
413+
# Not working https://github.com/NativeScript/android-runtime/issues/1522
414+
# Tns.build_android(os.path.join(TEST_RUN_HOME, APP_NAME), verify=True).output
415+
log = Tns.run_android(APP_NAME, device=self.emulator.id, wait=False, verify=False)
416+
source_js = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files', 'android-runtime-1463-1459',
417+
'main-view-model.js')
418+
target_js = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'main-view-model.js')
419+
File.copy(source=source_js, target=target_js, backup_files=True)
420+
log = Tns.run_android(APP_NAME, device=self.emulator.id, wait=False, verify=False)
381421

382-
def test_453_support_gradle_properties_for_enable_Kotlin_with_kotlin_file(self):
422+
strings = ['Successfully synced application org.nativescript.TestApp on device ']
423+
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=300,
424+
period=5)
425+
messages = "App with Kotlin enabled and kotlin jar not build correctly! Logs: "
426+
assert test_result, messages + File.read(log.log_file)
427+
self.assert_kotlin_is_working(self.emulator)
428+
with open(ANALYTICS_FILE, "r") as read_file:
429+
data = json.load(read_file)
430+
error_message = "kotlinUsage->hasKotlinRuntimeClasses is not set to True! Analytics is not correct!"
431+
assert data["kotlinUsage"]["hasKotlinRuntimeClasses"] is True, error_message
432+
error_message = "kotlinUsage->hasUseKotlinPropertyInApp is not set to False! Analytics is not correct!"
433+
assert data["kotlinUsage"]["hasUseKotlinPropertyInApp"] is False, error_message
434+
435+
def test_454_support_gradle_properties_for_enable_Kotlin_with_kotlin_file(self):
383436
"""
384437
Support gradle.properties file for enable Kotlin
385438
https://github.com/NativeScript/android-runtime/issues/1459
386439
https://github.com/NativeScript/android-runtime/issues/1463
387440
"""
388-
Tns.platform_remove(APP_NAME, platform=Platform.ANDROID)
441+
Tns.platform_remove(app_name=APP_NAME, platform=Platform.ANDROID)
389442
Tns.platform_add_android(APP_NAME, framework_path=Android.FRAMEWORK_PATH)
443+
390444
Adb.clear_logcat(self.emulator.id)
391445
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
392446
'android-runtime-1463-1459', 'gradle.properties')
@@ -413,15 +467,41 @@ def test_453_support_gradle_properties_for_enable_Kotlin_with_kotlin_file(self):
413467
messages = "App with Kotlin enabled and kotlin jar not build correctly! Logs: "
414468
assert test_result, messages + File.read(log.log_file)
415469
self.assert_kotlin_is_working(self.emulator)
416-
417-
def test_454_support_Kotlin_with_jar_without_use_kotlin(self):
470+
with open(ANALYTICS_FILE, "r") as read_file:
471+
data = json.load(read_file)
472+
error_message = "kotlinUsage->hasKotlinRuntimeClasses is not set to True! Analytics is not correct!"
473+
assert data["kotlinUsage"]["hasKotlinRuntimeClasses"] is True, error_message
474+
error_message = "kotlinUsage->hasUseKotlinPropertyInApp is not set to True! Analytics is not correct!"
475+
assert data["kotlinUsage"]["hasUseKotlinPropertyInApp"] is True, error_message
476+
477+
def test_455_analytics_not_generated_when_not_set_as_property_for_enable_Kotlin_with_jar(self):
418478
"""
419479
Support gradle.properties file for enable Kotlin
420480
https://github.com/NativeScript/android-runtime/issues/1459
421481
https://github.com/NativeScript/android-runtime/issues/1463
422482
"""
423-
Tns.plugin_remove("sample-plugin-2", verify=False, path=APP_NAME)
483+
# caused by https://github.com/NativeScript/nativescript-cli/issues/5083
484+
kotlin_file_in_src = os.path.join(TEST_RUN_HOME, APP_NAME, 'platforms', 'android', 'app', 'src', 'main', 'java',
485+
'com',
486+
'Test.kt')
487+
kotlin_file_in_build = os.path.join(TEST_RUN_HOME, APP_NAME, 'platforms', 'android', 'app', 'build', 'tmp',
488+
'kotlin-classes', 'debug', 'com',
489+
'Test.class')
490+
if File.exists(kotlin_file_in_src):
491+
File.delete(kotlin_file_in_src)
492+
if File.exists(kotlin_file_in_build):
493+
File.delete(kotlin_file_in_build)
494+
else:
495+
assert False, "Temp gradle folder is missing for generated kotlin file!"
496+
497+
# bug ends here
498+
if File.exists(ANALYTICS_FILE):
499+
File.delete(ANALYTICS_FILE)
424500
Adb.clear_logcat(self.emulator.id)
501+
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
502+
'android-runtime-1463-1459', 'no-analytics', 'gradle.properties')
503+
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
504+
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)
425505
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
426506
'android-runtime-1463-1459', 'test-jar-1.0-SNAPSHOT.jar')
427507
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android', 'libs')
@@ -436,14 +516,44 @@ def test_454_support_Kotlin_with_jar_without_use_kotlin(self):
436516
strings = ['Project successfully built',
437517
'Successfully installed on device with identifier', self.emulator.id,
438518
'Successfully synced application']
439-
440519
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=300,
441520
period=5)
442521
messages = "App with Kotlin enabled and kotlin jar not build correctly! Logs: "
443522
assert test_result, messages + File.read(log.log_file)
444-
self.assert_kotlin_is_working(self.emulator)
523+
error_message = "Analytics data should NOT be generated when gatherAnalyticsData is not set!"
524+
assert not File.exists(ANALYTICS_FILE), error_message
445525

446-
def test_455_gradle_hooks(self):
526+
def test_456_analytics_working_correct_when_property_is_set_without_Kotlin(self):
527+
"""
528+
Support gradle.properties file for enable Kotlin
529+
https://github.com/NativeScript/android-runtime/issues/1459
530+
https://github.com/NativeScript/android-runtime/issues/1463
531+
"""
532+
Adb.clear_logcat(self.emulator.id)
533+
source_app_gradle = os.path.join(TEST_RUN_HOME, 'assets', 'runtime', 'android', 'files',
534+
'android-runtime-1463-1459', 'analytics', 'gradle.properties')
535+
target_app_gradle = os.path.join(TEST_RUN_HOME, APP_NAME, 'app', 'App_Resources', 'Android')
536+
File.copy(source=source_app_gradle, target=target_app_gradle, backup_files=True)
537+
538+
log = Tns.run_android(APP_NAME, device=self.emulator.id, wait=False, verify=False)
539+
540+
strings = ['Project successfully built',
541+
'Successfully installed on device with identifier', self.emulator.id,
542+
'Successfully synced application']
543+
test_result = Wait.until(lambda: all(string in File.read(log.log_file) for string in strings), timeout=300,
544+
period=5)
545+
messages = "App with Kotlin enabled and kotlin jar not build correctly! Logs: "
546+
assert test_result, messages + File.read(log.log_file)
547+
error_message = "Analytics data should be generated when gatherAnalyticsData is set!"
548+
assert File.exists(ANALYTICS_FILE), error_message
549+
with open(ANALYTICS_FILE, "r") as read_file:
550+
data = json.load(read_file)
551+
error_message = "kotlinUsage->hasKotlinRuntimeClasses is not set to False! Analytics is not correct!"
552+
assert data["kotlinUsage"]["hasKotlinRuntimeClasses"] is False, error_message
553+
error_message = "kotlinUsage->hasUseKotlinPropertyInApp is not set to False! Analytics is not correct!"
554+
assert data["kotlinUsage"]["hasUseKotlinPropertyInApp"] is False, error_message
555+
556+
def test_457_gradle_hooks(self):
447557
"""
448558
Test gradle hooks works correctly
449559
https://docs.nativescript.org/core-concepts/android-runtime/advanced-topics/gradle-hooks

0 commit comments

Comments
 (0)