File tree Expand file tree Collapse file tree
cef3/wx-subpackage/examples Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111import wx
1212import wx .lib .agw .flatnotebook as fnb
1313import cefpython3 .wx .chromectrl as chrome
14+ import platform
15+ import sys
1416
1517ROOT_NAME = "My Locations"
1618
@@ -32,6 +34,14 @@ def __init__(self):
3234 self .initComponents ()
3335 self .layoutComponents ()
3436 self .initEventHandlers ()
37+ if len (sys .argv ) == 2 and sys .argv [1 ] == "test-launch" :
38+ wx .CallLater (500 , self .testLaunch )
39+
40+ def testLaunch (self ):
41+ # This hash is checked by /tests/test-launch.sh script
42+ # to detect whether CEF initialized successfully.
43+ print ("b8ba7d9945c22425328df2e21fbb64cd" )
44+ self .Close ()
3545
3646 def initComponents (self ):
3747 self .tree = wx .TreeCtrl (self , id = - 1 , size = (200 , - 1 ))
@@ -73,8 +83,16 @@ def OnPageClosing(self, event):
7383 def OnClose (self , event ):
7484 self .Destroy ()
7585
86+
7687if __name__ == '__main__' :
7788 chrome .Initialize ()
89+ if platform .system () == "Linux" :
90+ # CEF initialization fails intermittently on Linux during
91+ # launch of a subprocess (Issue 131). The solution is
92+ # to offload cpu for half a second after Initialize
93+ # has returned (it still runs some stuff in its thread).
94+ import time
95+ time .sleep (0.5 )
7896 print ('sample2.py: wx.version=%s' % wx .version ())
7997 app = wx .PySimpleApp ()
8098 MainFrame ().Show ()
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Usage: ./test-launch.sh 500
4+
5+ # When launching this test script more than once in current
6+ # Linux session then the CEF initialization issue is hard
7+ # to reproduce. The best results are when launching tests
8+ # in a clean Ubuntu session, just log out and log in again,
9+ # and run the test immediately. You could also run a few
10+ # terminal sessions with several test scripts running
11+ # simultaneously to simulate heavy overload.
12+
13+ for (( i = 1 ; i <= $1 ; i++ )) ; do
14+ output=$( python ./../cef3/wx-subpackage/examples/sample2.py test-launch)
15+ code=$?
16+ if [[ $code != 0 || $output != * b8ba7d9945c22425328df2e21fbb64cd* ]]; then
17+ echo " EXIT CODE: $code "
18+ echo " OUTPUT: $output "
19+ echo " ERROR!"
20+ read -p " Press ENTER to exit"
21+ exit $code
22+ fi
23+ echo RUN $i OK
24+ done
25+
26+ echo TEST SUCCEEDED
27+ read -p " Press ENTER to exit"
You can’t perform that action at this time.
0 commit comments