Skip to content

Commit 267f606

Browse files
author
Vasil Hristov
authored
Add test for instanceof works for interfaces (#131)
* Add test for instanceof works for interfaces. NativeScript/android#739 * Update android_runtime_tests.py * Update android_runtime_tests.py * Update android_runtime_tests.py
1 parent bcaf246 commit 267f606

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var createViewModel = require("./main-view-model").createViewModel;
2+
var myRunnable = new java.lang.Runnable({
3+
run: function(){}
4+
});
5+
6+
function onNavigatingTo(args) {
7+
var page = args.object;
8+
page.bindingContext = createViewModel();
9+
console.log("### TEST START ###");
10+
if (myRunnable instanceof java.lang.Runnable) {
11+
console.log("### TEST PASSED ###");
12+
}
13+
else
14+
{
15+
console.log("### TEST FAILED ###");
16+
}
17+
console.log("### TEST END ###");
18+
}
19+
exports.onNavigatingTo = onNavigatingTo;

tests/emulator/android_runtime_tests.py

+29
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,32 @@ def test_301_native_package_starting_with_in_are_working(self):
100100
except Exception as e:
101101
print str(e)
102102
assert 1 == 2, 'Native packages starting with in could not be accessed'
103+
104+
def test_302_check_if_class_implements_java_interface(self):
105+
"""
106+
Test if java class implements java interface
107+
https://github.com/NativeScript/android-runtime/issues/739
108+
"""
109+
# Change main-page.js so it contains only logging information
110+
source_js = os.path.join('data', "issues", 'android-runtime-739', 'main-page.js')
111+
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
112+
File.copy(src=source_js, dest=target_js)
113+
114+
Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name}, assert_success=False)
115+
Tns.platform_add_android(attributes={"--path": self.app_name, "--frameworkPath": ANDROID_PACKAGE})
116+
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
117+
assert_success=False)
118+
119+
strings = ['Project successfully built',
120+
'Successfully installed on device with identifier', EMULATOR_ID,
121+
'Successfully synced application']
122+
123+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=240, check_interval=10, clean_log=False)
124+
try:
125+
Tns.wait_for_log(log_file=log, string_list=["### TEST PASSED ###"], timeout=60, check_interval=10,
126+
clean_log=False)
127+
except Exception as e:
128+
print str(e)
129+
assert 1 == 2, 'Check(instanceof) for java class implements java interface does not work' \
130+
'(myRunnable instanceof java.lang.Runnable)'
131+

0 commit comments

Comments
 (0)