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