self.test_property2 = {"key1": self.test_property1, "key2": ["Inside list", 1, 2]} # Asserts for True/False will be checked just before shutdown self.test_for_True = True # Test whether asserts are working correctly self.test_function_True = False self.test_property3_function_True = False self.test_callbacks_True = False self.py_callback_True = False def test_function(self): """Test binding function to the 'window' object.""" self.test_function_True = True def test_property3_function(self): """Test binding function to the 'window' object.""" self.test_property3_function_True = True def test_callbacks(self, js_callback): """Test both javascript and python callbacks.""" def py_callback(msg_from_js): self.py_callback_True = True self.test_case.assertEqual(msg_from_js, "String sent from Javascript") self.test_callbacks_True = True js_callback.Call("String sent from Python", py_callback) if __name__ == "__main__": _test_runner.main(os.path.basename(__file__))
import _test_runner from os.path import basename # Globals g_count = 0 class IsolatedTest1(unittest.TestCase): def test_isolated1(self): global g_count g_count += 1 self.assertEqual(g_count, 1) def test_isolated2(self): global g_count g_count += 1 self.assertEqual(g_count, 2) class IsolatedTest2(unittest.TestCase): def test_isolated3(self): global g_count g_count += 1 self.assertEqual(g_count, 1) if __name__ == "__main__": _test_runner.main(basename(__file__))
# Test binding properties to the 'window' object. self.test_property1 = "Test binding property to the 'window' object" self.test_property2 = { "key1": self.test_property1, "key2": ["Inside list", 1, 2] } # Asserts for True/False will be checked just before shutdown self.test_for_True = True # Test whether asserts are working correctly self.test_function_True = False self.test_callbacks_True = False self.py_callback_True = False def test_function(self): """Test binding function to the 'window' object.""" self.test_function_True = True def test_callbacks(self, js_callback): """Test both javascript and python callbacks.""" def py_callback(msg_from_js): self.py_callback_True = True self.test_case.assertEqual(msg_from_js, "String sent from Javascript") self.test_callbacks_True = True js_callback.Call("String sent from Python", py_callback) if __name__ == "__main__": _test_runner.main(basename(__file__))
self.GetViewRect_True = True rect_out.extend([0, 0, 800, 600]) return True def OnPaint(self, element_type, paint_buffer, **_): """Called when an element should be painted.""" if element_type == cef.PET_VIEW: self.test_case.assertEqual(paint_buffer.width, 800) self.test_case.assertEqual(paint_buffer.height, 600) if not self.OnPaint_True: self.OnPaint_True = True subtest_message("RenderHandler.OnPaint: viewport ok") else: raise Exception("Unsupported element_type in OnPaint") def OnTextSelectionChanged(self, selected_text, selected_range, **_): if not self.OnTextSelectionChanged_True: self.OnTextSelectionChanged_True = True # First call self.test_case.assertEqual(selected_text, "") self.test_case.assertEqual(selected_range, [0, 0]) else: # Second call. # <h1> tag should be selected. self.test_case.assertEqual(selected_text, "Off-screen rendering test") if __name__ == "__main__": _test_runner.main(os.path.basename(__file__))