MCPcopy Create free account
hub / github.com/cztomczak/cefpython / GlobalHandler

Class GlobalHandler

unittests/_common.py:140–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139
140class GlobalHandler(object):
141 def __init__(self, test_case):
142 self.test_case = test_case
143
144 # Asserts for True/False will be checked just before shutdown
145 self.test_for_True = True # Test whether asserts are working correctly
146 self.OnAfterCreatedMain_True = False
147
148 if "main_test" in test_case.id():
149 self.OnAfterCreatedPopup_True = False
150 self.PopupClosed_True = False
151 self.HasDevTools_True = False
152
153 def _OnAfterCreated(self, browser, **_):
154 # For asserts that are checked automatically before shutdown its
155 # values should be set first, so that when other asserts fail
156 # (the ones called through the test_case member) they are reported
157 # correctly.
158 if not self.OnAfterCreatedMain_True:
159 # First call for main browser.
160 # browser.GetUrl() returns empty at this moment.
161 self.OnAfterCreatedMain_True = True
162 self.test_case.assertEqual(browser.GetIdentifier(),
163 MAIN_BROWSER_ID)
164 self.test_case.assertFalse(browser.IsPopup())
165 else:
166 # Second call for implicit popup browser opened via js.
167 # Should execute only for main test.
168 # Should not execute for DevTools window.
169 assert "main_test" in self.test_case.id()
170 assert not self.OnAfterCreatedPopup_True
171 self.OnAfterCreatedPopup_True = True
172 self.test_case.assertEqual(browser.GetIdentifier(),
173 POPUP_BROWSER_ID)
174 # browser.GetUrl() returns empty at this moment.
175 self.test_case.assertTrue(browser.IsPopup())
176 if WINDOWS:
177 cef.WindowUtils.SetTitle(browser, "Popup test")
178 # Close the popup browser after 250 ms
179 cef.PostDelayedTask(cef.TID_UI, 250, close_popup, self, browser)
180
181
182class LoadHandler(object):

Callers 2

test_osrMethod · 0.70
test_mainMethod · 0.70

Calls

no outgoing calls

Tested by 2

test_osrMethod · 0.56
test_mainMethod · 0.56