Пример #1
0
 def test_SDL_GetSetWindowPosition(self):
     window = video.SDL_CreateWindow(b"Test", 10, 10, 10, 10, 0)
     px, py = c_int(), c_int()
     video.SDL_GetWindowPosition(window, byref(px), byref(py))
     assert (px.value, py.value) == (10, 10)
     video.SDL_SetWindowPosition(window, 0, 0)
     video.SDL_GetWindowPosition(window, byref(px), byref(py))
     assert (px.value, py.value) == (0, 0)
     video.SDL_SetWindowPosition(window, 600, 900)
     video.SDL_GetWindowPosition(window, byref(px), byref(py))
     assert (px.value, py.value) == (600, 900)
     video.SDL_SetWindowPosition(window, -200, -10)
     video.SDL_GetWindowPosition(window, byref(px), byref(py))
     assert (px.value, py.value) == (-200, -10)
     video.SDL_DestroyWindow(window)
Пример #2
0
 def test_SDL_GetWindowFromID(self):
     get_id = video.SDL_GetWindowID
     get_title = video.SDL_GetWindowTitle
     flags = (video.SDL_WINDOW_BORDERLESS,
              video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
     for flag in flags:
         window = video.SDL_CreateWindow(b"Test", 10, 10, 10, 10, flag)
         window2 = video.SDL_GetWindowFromID(video.SDL_GetWindowID(window))
         assert get_id(window) == get_id(window2)
         assert get_title(window) == get_title(window2)
         px1, py1, px2, py2 = c_int(), c_int(), c_int(), c_int()
         video.SDL_GetWindowPosition(window, byref(px1), byref(px2))
         video.SDL_GetWindowPosition(window2, byref(px2), byref(px2))
         assert (px1.value, py1.value) == (px2.value, py2.value)
         video.SDL_GetWindowSize(window, byref(px1), byref(px2))
         video.SDL_GetWindowSize(window2, byref(px2), byref(px2))
         assert (px1.value, py1.value) == (px2.value, py2.value)
Пример #3
0
 def test_SDL_GetWindowFromID(self):
     flags = (video.SDL_WINDOW_BORDERLESS,
              video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
     for flag in flags:
         window = video.SDL_CreateWindow(b"Test", 10, 10, 10, 10, flag)
         window2 = video.SDL_GetWindowFromID(video.SDL_GetWindowID(window))
         self.assertEqual(video.SDL_GetWindowID(window),
                          video.SDL_GetWindowID(window2))
         self.assertEqual(video.SDL_GetWindowTitle(window),
                          video.SDL_GetWindowTitle(window2))
         px1, py1, px2, py2 = c_int(), c_int(), c_int(), c_int()
         video.SDL_GetWindowPosition(window, byref(px1), byref(px2))
         video.SDL_GetWindowPosition(window2, byref(px2), byref(px2))
         self.assertEqual((px1.value, py1.value), (px2.value, py2.value))
         video.SDL_GetWindowSize(window, byref(px1), byref(px2))
         video.SDL_GetWindowSize(window2, byref(px2), byref(px2))
         self.assertEqual((px1.value, py1.value), (px2.value, py2.value))
Пример #4
0
 def test_SDL_CreateWindow(self):
     # Borderless to ensure that the size check works
     flags = (video.SDL_WINDOW_BORDERLESS,
              video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
     for flag in flags:
         window = video.SDL_CreateWindow(b"Test", 10, 11, 12, 13, flag)
         assert isinstance(window.contents, video.SDL_Window)
         px, py = c_int(), c_int()
         video.SDL_GetWindowPosition(window, byref(px), byref(py))
         assert (px.value, py.value) == (10, 11)
         video.SDL_GetWindowSize(window, byref(px), byref(py))
         assert (px.value, py.value) == (12, 13)
         assert video.SDL_GetWindowFlags(window) & flag == flag
         assert video.SDL_GetWindowTitle(window) == b"Test"
         video.SDL_DestroyWindow(window)
Пример #5
0
    def test_SDL_GetWindowDisplayIndex(self):
        numdisplays = video.SDL_GetNumVideoDisplays()
        flags = (video.SDL_WINDOW_BORDERLESS,
                 video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
        for flag in flags:
            window = video.SDL_CreateWindow(b"Test", 10, 11, 12, 13, flag)
            assert isinstance(window.contents, video.SDL_Window)
            px, py = c_int(), c_int()
            video.SDL_GetWindowPosition(window, byref(px), byref(py))
            assert (px.value, py.value) == (10, 11)
            video.SDL_GetWindowSize(window, byref(px), byref(py))
            assert (px.value, py.value) == (12, 13)
            assert video.SDL_GetWindowFlags(window) & flag == flag
            assert video.SDL_GetWindowTitle(window) == b"Test"

            dindex = video.SDL_GetWindowDisplayIndex(window)
            assert 0 <= dindex <= numdisplays, "Invalid display index"
            video.SDL_DestroyWindow(window)
Пример #6
0
    def test_SDL_GetWindowDisplayIndex(self):
        numdisplays = video.SDL_GetNumVideoDisplays()
        flags = (video.SDL_WINDOW_BORDERLESS,
                 video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
        for flag in flags:
            window = video.SDL_CreateWindow(b"Test", 10, 11, 12, 13, flag)
            self.assertIsInstance(window.contents, video.SDL_Window)
            px, py = c_int(), c_int()
            video.SDL_GetWindowPosition(window, byref(px), byref(py))
            self.assertEqual((px.value, py.value), (10, 11))
            video.SDL_GetWindowSize(window, byref(px), byref(py))
            self.assertEqual((px.value, py.value), (12, 13))
            self.assertEqual(video.SDL_GetWindowFlags(window) & flag, flag)
            self.assertEqual(video.SDL_GetWindowTitle(window), b"Test")

            dindex = video.SDL_GetWindowDisplayIndex(window)
            self.assertTrue(0 <= dindex <= numdisplays,
                            "Invalid display index")
            video.SDL_DestroyWindow(window)