[pypy-commit] lang-smalltalk bitblt: add test for display flushing

timfel noreply at buildbot.pypy.org
Mon Mar 18 13:59:02 CET 2013


Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: bitblt
Changeset: r206:80508809991a
Date: 2013-03-18 13:45 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/80508809991a/

Log:	add test for display flushing

diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -643,6 +643,29 @@
     assert space.objtable["w_display"] is mock_display
     assert mock_display.fetch(space, 0) is w_bitmap
 
+def test_primitive_force_display_update(monkeypatch):
+    assert space.objtable["w_display"] is None
+    mock_display = model.W_PointersObject(space.w_Point, 4)
+    w_wordbmp = model.W_WordsObject(space.w_Array, 100)
+    mock_display.store(space, 0, w_wordbmp) # bitmap
+    mock_display.store(space, 1, space.wrap_int(32)) # width
+    mock_display.store(space, 2, space.wrap_int(10)) # height
+    mock_display.store(space, 3, space.wrap_int(1))  # depth
+    prim(primitives.BE_DISPLAY, [mock_display])
+
+    class DisplayFlush(Exception):
+        pass
+
+    def flush_to_screen_mock():
+        raise DisplayFlush
+
+    try:
+        monkeypatch.setattr(mock_display.fetch(space, 0), "flush_to_screen", flush_to_screen_mock)
+        with py.test.raises(DisplayFlush):
+            prim(primitives.FORCE_DISPLAY_UPDATE, [mock_display])
+    finally:
+        monkeypatch.undo()
+
 # Note:
 #   primitives.NEXT is unimplemented as it is a performance optimization
 #   primitives.NEXT_PUT is unimplemented as it is a performance optimization


More information about the pypy-commit mailing list