Skip to content

Commit 0e2503c

Browse files
committed
Add JS bindings long integer test. Add comments on DPI awareness.
1 parent 06d3b8c commit 0e2503c

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

examples/hello_world.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Hello world example. Doesn't depend on any third party GUI framework.
22
# Tested with CEF Python v57.0+.
3+
#
4+
# ==== High DPI support on Windows ====
5+
# To enable DPI awareness on Windows you have to either embed DPI aware manifest
6+
# in your executable created with pyinstaller or change python.exe properties manually:
7+
# Compatibility > High DPI scaling override > Application.
8+
# Setting DPI awareness programmatically via a call to cef.DpiAware.EnableHighDpiSupport
9+
# is problematic in Python, may not work and can cause display glitches.
310

411
from cefpython3 import cefpython as cef
512
import platform

unittests/main_test.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@
5858
print("test_function() ok");
5959
6060
// Test binding property: test_property1
61-
if (test_property1 == "Test binding property to the 'window' object") {
61+
if (test_property1 === "Test binding property to the 'window' object") {
6262
print("test_property_1 ok");
6363
} else {
6464
throw new Error("test_property1 contains invalid string");
6565
}
6666
6767
// Test binding property: test_property2
68-
if (JSON.stringify(test_property2) == '{"key1":"Test binding property'+
69-
' to the \\'window\\' object","key2":["Inside list",1,2]}') {
68+
if (JSON.stringify(test_property2) === '{"key1":"Test binding property'+
69+
' to the \\'window\\' object","key2":["Inside list",2147483647,"2147483648"]}') {
7070
print("test_property2 ok");
7171
} else {
72+
print("test_property2 invalid value: " + JSON.stringify(test_property2));
7273
throw new Error("test_property2 contains invalid value");
7374
}
7475
@@ -81,7 +82,7 @@
8182
print("[TIMER] Call Python function and then js callback that was"+
8283
" passed (Issue #277 test)");
8384
external.test_callbacks(function(msg_from_python, py_callback){
84-
if (msg_from_python == "String sent from Python") {
85+
if (msg_from_python === "String sent from Python") {
8586
print("test_callbacks() ok");
8687
var execution_time = new Date().getTime() - start_time;
8788
print("[TIMER]: Elapsed = "+String(execution_time)+" ms");
@@ -163,15 +164,23 @@ def test_main(self):
163164
cef.LoadCrlSetsFile(crlset)
164165
subtest_message("cef.LoadCrlSetsFile ok")
165166

166-
# High DPI on Windows
167+
# High DPI on Windows.
168+
# Setting DPI awareness from Python is usually too late and should be done
169+
# via manifest file. Alternatively change python.exe properties > Compatibility
170+
# > High DPI scaling override > Application.
171+
# Using cef.DpiAware.EnableHighDpiSupport is problematic, it can cause
172+
# display glitches.
167173
if WINDOWS:
168174
self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple)
169175
window_size = cef.DpiAware.CalculateWindowSize(800, 600)
170176
self.assertIsInstance(window_size, tuple)
171177
self.assertGreater(window_size[0], 0)
172178
self.assertGreater(cef.DpiAware.Scale((800, 600))[0], 0)
173-
cef.DpiAware.EnableHighDpiSupport()
174-
self.assertTrue(cef.DpiAware.IsProcessDpiAware())
179+
180+
# OFF - see comments above.
181+
# cef.DpiAware.EnableHighDpiSupport()
182+
# self.assertTrue(cef.DpiAware.IsProcessDpiAware())
183+
175184
# Make some calls again after DPI Aware was set
176185
self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple)
177186
self.assertGreater(cef.DpiAware.Scale([800, 600])[0], 0)
@@ -374,9 +383,10 @@ def __init__(self, test_case):
374383
self.test_case = test_case
375384

376385
# Test binding properties to the 'window' object.
386+
# 2147483648 is out of INT_MAX limit and will be sent to JS as string value.
377387
self.test_property1 = "Test binding property to the 'window' object"
378388
self.test_property2 = {"key1": self.test_property1,
379-
"key2": ["Inside list", 1, 2]}
389+
"key2": ["Inside list", 2147483647, 2147483648]}
380390

381391
# Asserts for True/False will be checked just before shutdown
382392
self.test_for_True = True # Test whether asserts are working correctly

0 commit comments

Comments
 (0)