1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
import pytest
from tests.base.interactive import InteractiveTestCase
from pyglet import window
from pyglet.gl import *
@pytest.mark.requires_user_validation
class WINDOW_OPEN(InteractiveTestCase):
def open_window(self):
return window.Window(200, 200)
def draw_window(self, window, colour):
window.switch_to()
glClearColor(*colour)
glClear(GL_COLOR_BUFFER_BIT)
window.flip()
def test_open_window(self):
"""Test that a window can be opened.
Expected behaviour:
One small window will be opened coloured purple.
"""
w1 = self.open_window()
self.draw_window(w1, (1, 0, 1, 1))
w1.dispatch_events()
self.user_verify('Do you see one small purple coloured window?')
w1.close()
def test_open_multiple_windows(self):
"""Test that multiple windows can be opened.
Expected behaviour:
Two small windows will be opened, one coloured yellow and the other
purple.
Close either window or press ESC to end the test.
"""
w1 = self.open_window()
w2 = self.open_window()
self.draw_window(w1, (1, 0, 1, 1))
self.draw_window(w2, (1, 1, 0, 1))
w1.dispatch_events()
w2.dispatch_events()
self.user_verify('Do you see one small purple coloured window '
'and one small yellow coloured window?')
w1.close()
w2.close()
|