示例#1
0
    def test_get_window_display(self):
        numdisplays = video.get_num_video_displays()
        flags = (video.SDL_WINDOW_BORDERLESS,
                 video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
        for flag in flags:
            window = video.create_window("Test", 10, 10, 10, 10, flag)
            self.assertIsInstance(window, video.SDL_Window)
            self.assertEqual(video.get_window_position(window), (10, 10))
            self.assertEqual(video.get_window_size(window), (10, 10))
            self.assertEqual(video.get_window_flags(window) & flag, flag)
            self.assertEqual(video.get_window_title(window), "Test")

            dindex = video.get_window_display(window)
            self.assertTrue(0 <= dindex <= numdisplays,
                            "Invalid display index")
            video.destroy_window(window)
            self.assertRaises(sdl.SDLError, video.get_window_display, window)
示例#2
0
    def test_set_window_display_mode(self):
        flags = (video.SDL_WINDOW_BORDERLESS,
                 video.SDL_WINDOW_BORDERLESS | video.SDL_WINDOW_HIDDEN)
        for flag in flags:
            window = video.create_window("Test", 10, 10, 10, 10, flag)
            dindex = video.get_window_display(window)
            dmode = video.get_current_display_mode(dindex)

            video.set_window_display_mode(window, dmode)
            wmode = video.get_window_display_mode(window)
            self.assertEqual(dmode.format, wmode.format)
            self.assertEqual(dmode.w, wmode.w)
            self.assertEqual(dmode.h, wmode.h)
            self.assertEqual(dmode.refresh_rate, wmode.refresh_rate)

            video.destroy_window(window)
            self.assertRaises(sdl.SDLError, video.set_window_display_mode,
                              window, dmode)