Skip to content

Commit 53d0c63

Browse files
committed
Update unit tests. Property can be a function too.
1 parent 1a118ed commit 53d0c63

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎unittests/main_test.py‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
print("Chrome: <b>"+version.chrome_version+"</b>");
4242
print("CEF: <b>"+version.cef_version+"</b>");
4343
44+
// Test binding function: test_function
45+
test_function();
46+
print("test_function() ok");
47+
4448
// Test binding property: test_property1
4549
if (test_property1 == "Test binding property to the 'window' object") {
4650
print("test_property_1 ok");
@@ -56,9 +60,9 @@
5660
throw new Error("test_property2 contains invalid value");
5761
}
5862
59-
// Test binding function: test_function
60-
test_function();
61-
print("test_function() ok");
63+
// Test binding function: test_property3_function
64+
test_property3_function();
65+
print("test_property3_function() ok");
6266
6367
// Test binding external object and use of javascript<>python callbacks
6468
var start_time = new Date().getTime();
@@ -145,6 +149,11 @@ def test_main(self):
145149
bindings.SetFunction("test_function", external.test_function)
146150
bindings.SetProperty("test_property1", external.test_property1)
147151
bindings.SetProperty("test_property2", external.test_property2)
152+
# Property with a function value can also be bound. CEF Python
153+
# supports passing functions as callbacks when called from
154+
# javascript, and as a side effect any value and in this case
155+
# a property can also be a function.
156+
bindings.SetProperty("test_property3_function", external.test_property3_function)
148157
bindings.SetProperty("cefpython_version", cef.GetVersion())
149158
bindings.SetObject("external", external)
150159
browser.SetJavascriptBindings(bindings)
@@ -310,13 +319,18 @@ def __init__(self, test_case):
310319
# Asserts for True/False will be checked just before shutdown
311320
self.test_for_True = True # Test whether asserts are working correctly
312321
self.test_function_True = False
322+
self.test_property3_function_True = False
313323
self.test_callbacks_True = False
314324
self.py_callback_True = False
315325

316326
def test_function(self):
317327
"""Test binding function to the 'window' object."""
318328
self.test_function_True = True
319329

330+
def test_property3_function(self):
331+
"""Test binding function to the 'window' object."""
332+
self.test_property3_function_True = True
333+
320334
def test_callbacks(self, js_callback):
321335
"""Test both javascript and python callbacks."""
322336
def py_callback(msg_from_js):

0 commit comments

Comments
 (0)