Skip to content
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

Add test for instanceof works for interfaces #131

Merged
merged 5 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions data/issues/android-runtime-739/main-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var createViewModel = require("./main-view-model").createViewModel;
var myRunnable = new java.lang.Runnable({
run: function(){}
});

function onNavigatingTo(args) {
var page = args.object;
page.bindingContext = createViewModel();
console.log("### TEST START ###");
if (myRunnable instanceof java.lang.Runnable) {
console.log("### TEST PASSED ###");
}
else
{
console.log("### TEST FAILED ###");
}
console.log("### TEST END ###");
}
exports.onNavigatingTo = onNavigatingTo;
33 changes: 33 additions & 0 deletions tests/emulator/android_runtime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from core.osutils.folder import Folder
from core.settings.settings import ANDROID_PACKAGE, EMULATOR_ID
from core.tns.tns import Tns
from core.tns.tns_platform_type import Platform
from core.tns.tns_verifications import TnsAsserts


Expand All @@ -26,6 +27,10 @@ def setUpClass(cls):
Emulator.ensure_available()
Folder.cleanup('./' + cls.app_name)

def tearDown(self):
Tns.kill()
BaseClass.tearDown(self)

@classmethod
def tearDownClass(cls):
BaseClass.tearDownClass()
Expand Down Expand Up @@ -65,3 +70,31 @@ def test_300_verbose_log_android(self):
log_string = File.read(log)
assert "TNS.Native" in log_string, "__enableVerboseLogging() do not enable TNS.Native logs!"
assert "TNS.Java" in log_string, "__enableVerboseLogging() do not enable TNS.Java logs!"

def test_302_check_if_class_implements_java_interface(self):
"""
Test if java class implements java interface
https://github.com/NativeScript/android-runtime/issues/739
"""
# Change main-page.js so it contains only logging information
source_js = os.path.join('data', "issues", 'android-runtime-739', 'main-page.js')
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
File.copy(src=source_js, dest=target_js)

Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False)
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
assert_success=False)

strings = ['Project successfully built',
'Successfully installed on device with identifier', EMULATOR_ID,
'Successfully synced application']

Tns.wait_for_log(log_file=log, string_list=strings, timeout=240, check_interval=10, clean_log=False)
try:
Tns.wait_for_log(log_file=log, string_list=["### TEST PASSED ###"], timeout=60, check_interval=10,
clean_log=False)
except Exception as e:
print str(e)
assert 1 == 2, 'Check(instanceof) for java class implements java interface does not work' \
'(myRunnable instanceof java.lang.Runnable)'