File: sdl2ext_window_test.py

package info (click to toggle)
pysdl2 0.9.9%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,276 kB
  • sloc: python: 18,592; makefile: 148; sh: 40
file content (118 lines) | stat: -rw-r--r-- 4,076 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import sys
import pytest
from sdl2 import ext as sdl2ext
from sdl2 import surface, video


class TestSDL2ExtWindow(object):
    __tags__ = ["sdl", "sdl2ext"]

    @classmethod
    def setup_class(cls):
        try:
            sdl2ext.init()
        except sdl2ext.SDLError:
            raise pytest.skip('Video subsystem not supported')

    @classmethod
    def teardown_class(cls):
        sdl2ext.quit()

    def test_Window(self):
        flags = video.SDL_WINDOW_BORDERLESS
        sizes = ((1, 1), (10, 10), (10, 20), (200, 17), (640, 480), (800, 600))
        for w, h in sizes:
            window = sdl2ext.Window("Window", size=(w, h), flags=flags)
            assert window.size == (w, h)
            window.close()

        with pytest.raises(TypeError):
            sdl2ext.Window("Test", None, None, None)
        with pytest.raises(TypeError):
            sdl2ext.Window("Test", None, None)
        with pytest.raises(TypeError):
            sdl2ext.Window("Test", None)


    def test_Window_title(self):
        window = sdl2ext.Window("Window", size=(10, 10))
        assert window.title == "Window"
        window.title = "Test1234"
        assert window.title == "Test1234"
        window.close()

        #window.title = None
        #self.assertEqual(window.title, "None")
        #window.title = 1234
        #self.assertEqual(window.title, "1234")

#     @interactive("Was the window shown?")
#     def test_Window_show(self):
#         window = sdl2ext.Window("Test Show Window", size=(200, 200))
#         window.show()
#         doprint("""Please check, if a window with the title
# 'Test Show Window' is shown""")

#     @interactive("Did the window vanish from your sight and pop up again?")
#     def test_Window_hide(self):
#         window = sdl2ext.Window("Test Hide Window", size=(200, 200))
#         window.show()
#         doprint("""Please check, if a window with the title
# 'Test Hide Window' is shown""")
#         window.hide()
#         doprint("Please check, that the window is not shown anymore")
#         window.show()
#         doprint("Please check, if the window is shown again")

#     @interactive("Was the window maximized?")
#     def test_Window_maximize(self):
#         window = sdl2ext.Window("Test Maximize Window", size=(200, 200),
#                                 flags=video.SDL_WINDOW_RESIZABLE)
#         window.show()
#         doprint("""Please check, that a window with the title
# 'Test Maximize Window' is shown""")
#         window.maximize()
#         doprint("Please check, if the window was maximized properly")

#     @interactive("Was the window minimized?")
#     def test_Window_minimize(self):
#         window = sdl2ext.Window("Test Minimize Window", size=(200, 200))
#         window.show()
#         doprint("""Please check, that a window with the title
# 'Test Minimize Window' is shown""")
#         window.minimize()
#         doprint("Please check, if the window was minimized properly")

    @pytest.mark.skip("not implemented")
    def test_Window_refresh(self):
        pass

    def test_Window_get_surface(self):
        window = sdl2ext.Window("Surface", size=(200, 200))
        sf = window.get_surface()
        assert isinstance(sf, surface.SDL_Surface)
        window.close()

    @pytest.mark.skip("not implemented")
    def test_Window_open(self):
        pass

    @pytest.mark.skip("not implemented")
    def test_Window_close(self):
        pass

    def test_Window_position(self):
        window = sdl2ext.Window("Position", size=(200, 200), position=(100, 100))
        assert window.position == (100, 100)
        window.position = 70, 300
        assert window.position == (70, 300)
        window.close()

    @pytest.mark.skip("not implemented")
    def test_Window_size(self):
        # This may fail for fullscreen WMs or Win10 tablet modes
        window = sdl2ext.Window("Size", size=(200, 200), flags=video.SDL_WINDOW_RESIZABLE)
        assert window.size == (200, 200)
        window.size = 150, 77
        assert window.size == (150, 77)
        window.close()