diff --git a/data/issues/android-runtime-pr-923/app.js b/data/issues/android-runtime-pr-923/app.js new file mode 100755 index 00000000..dda0d563 --- /dev/null +++ b/data/issues/android-runtime-pr-923/app.js @@ -0,0 +1,22 @@ +/* +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. +*/ + +require("./bundle-config"); +var application = require("application"); +var extendedClassesSpaces = require("./extended-classes spaces"); +var extendedClassesDashes = require("./extended-classes-dashes"); +var extendedClassesInDirWithSpaces = require("./dir spaces/extended-classes"); + +var i1 = extendedClassesSpaces.getExtendedClassInstance(); +var i2 = extendedClassesDashes.getExtendedClassInstance(); +var i3 = extendedClassesInDirWithSpaces.getExtendedClassInstance(); + +application.start({ moduleName: "main-page" }); + +/* +Do not place any code after the application has been started as it will not +be executed on iOS. +*/ diff --git a/data/issues/android-runtime-pr-923/dir spaces/extended-classes.js b/data/issues/android-runtime-pr-923/dir spaces/extended-classes.js new file mode 100755 index 00000000..8d56b35c --- /dev/null +++ b/data/issues/android-runtime-pr-923/dir spaces/extended-classes.js @@ -0,0 +1,23 @@ +function getExtendedClasses() { + var ExtendedClass = java.lang.Object.extend({ + + }); + + return { + ExtendedClass + }; +} + +function getExtendedClassInstance() { + var Clazz = getExtendedClasses().ExtendedClass; + var instance; + + instance = new Clazz(); + + return instance; +} + +module.exports = { + getExtendedClasses, + getExtendedClassInstance +} \ No newline at end of file diff --git a/data/issues/android-runtime-pr-923/extended-classes spaces.js b/data/issues/android-runtime-pr-923/extended-classes spaces.js new file mode 100755 index 00000000..8d56b35c --- /dev/null +++ b/data/issues/android-runtime-pr-923/extended-classes spaces.js @@ -0,0 +1,23 @@ +function getExtendedClasses() { + var ExtendedClass = java.lang.Object.extend({ + + }); + + return { + ExtendedClass + }; +} + +function getExtendedClassInstance() { + var Clazz = getExtendedClasses().ExtendedClass; + var instance; + + instance = new Clazz(); + + return instance; +} + +module.exports = { + getExtendedClasses, + getExtendedClassInstance +} \ No newline at end of file diff --git a/data/issues/android-runtime-pr-923/extended-classes-dashes.js b/data/issues/android-runtime-pr-923/extended-classes-dashes.js new file mode 100755 index 00000000..e97e96fd --- /dev/null +++ b/data/issues/android-runtime-pr-923/extended-classes-dashes.js @@ -0,0 +1,23 @@ +function getExtendedClasses() { + var ExtendedClass = android.view.View.MeasureSpec.extend({ + + }); + + return { + ExtendedClass + }; +} + +function getExtendedClassInstance() { + var Clazz = getExtendedClasses().ExtendedClass; + var instance; + + instance = new Clazz(); + + return instance; +} + +module.exports = { + getExtendedClasses, + getExtendedClassInstance +} \ No newline at end of file diff --git a/tests/emulator/run_android_ng_tests.py b/tests/emulator/run_android_ng_tests.py index 6bc5e013..0116bf2f 100644 --- a/tests/emulator/run_android_ng_tests.py +++ b/tests/emulator/run_android_ng_tests.py @@ -10,13 +10,15 @@ from core.base_class.BaseClass import BaseClass from core.device.device import Device from core.device.emulator import Emulator +from core.osutils.command_log_level import CommandLogLevel from core.osutils.file import File from core.osutils.folder import Folder from core.osutils.os_type import OSType -from core.settings.settings import ANDROID_PACKAGE, EMULATOR_ID, EMULATOR_NAME, CURRENT_OS +from core.settings.settings import ANDROID_PACKAGE, EMULATOR_ID, EMULATOR_NAME, CURRENT_OS, TEST_RUN_HOME from core.tns.replace_helper import ReplaceHelper from core.tns.tns import Tns from core.tns.tns_platform_type import Platform +from core.device.helpers.adb import Adb class RunAndroidEmulatorTestsNG(BaseClass): @@ -210,3 +212,28 @@ def test_280_tns_run_android_console_time(self): # Verify console.time() works console_time = ['JS: startup:'] Tns.wait_for_log(log_file=log, string_list=console_time) + + + def test_420_check_dex_files_on_device(self): + """ + check for files on device - shouldn't have *.dex + """ + Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, + assert_success=False) + File.remove(self.app_name + "/app/app.js") + Folder.copy(TEST_RUN_HOME + "/data/issues/android-runtime-pr-923/app.js", TEST_RUN_HOME + "/TestApp/app/") + Folder.create(self.app_name + "/app/" + "dir spaces") + + Folder.copy(TEST_RUN_HOME + "/data/issues/android-runtime-pr-923/dir spaces/extended-classes.js", + TEST_RUN_HOME + "/TestApp/app/dir spaces") + Folder.copy(TEST_RUN_HOME + "/data/issues/android-runtime-pr-923/extended-classes spaces.js", + TEST_RUN_HOME + "/TestApp/app") + Folder.copy(TEST_RUN_HOME + "/data/issues/android-runtime-pr-923/extended-classes-dashes.js", + TEST_RUN_HOME + "/TestApp/app") + + Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID, '--justlaunch': ''}) + # command = "shell ls /data/data/org.nativescript.TestApp/code_cache/secondary-dexes | grep '\.dex'" + command = "shell ls /data/data/org.nativescript.TestApp/code_cache/secondary-dexes" + output = Adb.run(device_id=EMULATOR_ID, command=command, log_level=CommandLogLevel.FULL) + print output + assert "dex" in output \ No newline at end of file