File: display_test.py

package info (click to toggle)
pygame 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 42,624 kB
  • sloc: ansic: 66,926; python: 48,742; javascript: 1,153; objc: 224; sh: 121; makefile: 59; cpp: 25
file content (1199 lines) | stat: -rw-r--r-- 46,425 bytes parent folder | download
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
import unittest
import os
import sys
import time

import pygame, pygame.transform

from pygame.tests.test_utils import question

from pygame import display


class DisplayModuleTest(unittest.TestCase):
    default_caption = "pygame window"

    def setUp(self):
        display.init()

    def tearDown(self):
        display.quit()

    def test_Info(self):
        inf = pygame.display.Info()
        self.assertNotEqual(inf.current_h, -1)
        self.assertNotEqual(inf.current_w, -1)
        # probably have an older SDL than 1.2.10 if -1.

        screen = pygame.display.set_mode((128, 128))
        inf = pygame.display.Info()
        self.assertEqual(inf.current_h, 128)
        self.assertEqual(inf.current_w, 128)

    def test_flip(self):
        screen = pygame.display.set_mode((100, 100))

        # test without a change
        self.assertIsNone(pygame.display.flip())

        # test with a change
        pygame.Surface.fill(screen, (66, 66, 53))
        self.assertIsNone(pygame.display.flip())

        # test without display init
        pygame.display.quit()
        with self.assertRaises(pygame.error):
            (pygame.display.flip())

        # test without window
        del screen
        with self.assertRaises(pygame.error):
            (pygame.display.flip())

    def test_get_active(self):
        """Test the get_active function"""

        # Initially, the display is not active
        pygame.display.quit()
        self.assertEqual(pygame.display.get_active(), False)

        # get_active defaults to true after a set_mode
        pygame.display.init()
        pygame.display.set_mode((640, 480))
        self.assertEqual(pygame.display.get_active(), True)

        # get_active after init/quit should be False
        # since no display is visible
        pygame.display.quit()
        pygame.display.init()
        self.assertEqual(pygame.display.get_active(), False)

    @unittest.skipIf(
        os.environ.get("SDL_VIDEODRIVER") == "dummy",
        "requires the SDL_VIDEODRIVER to be a non dummy value",
    )
    def test_get_active_iconify(self):
        """Test the get_active function after an iconify"""

        # According to the docs, get_active should return
        # false if the display is iconified
        pygame.display.set_mode((640, 480))

        pygame.event.clear()
        pygame.display.iconify()

        for _ in range(100):
            time.sleep(0.01)
            pygame.event.pump()

        self.assertEqual(pygame.display.get_active(), False)

    def test_get_caption(self):
        screen = display.set_mode((100, 100))

        self.assertEqual(display.get_caption()[0], self.default_caption)

    def test_set_caption(self):
        TEST_CAPTION = "test"
        screen = display.set_mode((100, 100))

        self.assertIsNone(display.set_caption(TEST_CAPTION))
        self.assertEqual(display.get_caption()[0], TEST_CAPTION)
        self.assertEqual(display.get_caption()[1], TEST_CAPTION)

    def test_set_caption_kwargs(self):
        TEST_CAPTION = "test"
        screen = display.set_mode((100, 100))

        self.assertIsNone(display.set_caption(title=TEST_CAPTION))
        self.assertEqual(display.get_caption()[0], TEST_CAPTION)
        self.assertEqual(display.get_caption()[1], TEST_CAPTION)

    def test_caption_unicode(self):
        TEST_CAPTION = "台"
        display.set_caption(TEST_CAPTION)
        self.assertEqual(display.get_caption()[0], TEST_CAPTION)

    def test_get_driver(self):
        drivers = [
            "aalib",
            "android",
            "arm",
            "cocoa",
            "dga",
            "directx",
            "directfb",
            "dummy",
            "emscripten",
            "fbcon",
            "ggi",
            "haiku",
            "khronos",
            "kmsdrm",
            "nacl",
            "offscreen",
            "pandora",
            "psp",
            "qnx",
            "raspberry",
            "svgalib",
            "uikit",
            "vgl",
            "vivante",
            "wayland",
            "windows",
            "windib",
            "winrt",
            "x11",
        ]
        driver = display.get_driver()
        self.assertIn(driver, drivers)

        display.quit()
        with self.assertRaises(pygame.error):
            driver = display.get_driver()

    def test_get_init(self):
        """Ensures the module's initialization state can be retrieved."""
        # display.init() already called in setUp()
        self.assertTrue(display.get_init())

    # This test can be uncommented when issues #991 and #993 are resolved.
    @unittest.skipIf(True, "SDL2 issues")
    def test_get_surface(self):
        """Ensures get_surface gets the current display surface."""
        lengths = (1, 5, 100)

        for expected_size in ((w, h) for w in lengths for h in lengths):
            for expected_depth in (8, 16, 24, 32):
                expected_surface = display.set_mode(expected_size, 0, expected_depth)

                surface = pygame.display.get_surface()

                self.assertEqual(surface, expected_surface)
                self.assertIsInstance(surface, pygame.Surface)
                self.assertEqual(surface.get_size(), expected_size)
                self.assertEqual(surface.get_bitsize(), expected_depth)

    def test_get_surface__mode_not_set(self):
        """Ensures get_surface handles the display mode not being set."""
        surface = pygame.display.get_surface()

        self.assertIsNone(surface)

    def test_get_wm_info(self):
        wm_info = display.get_wm_info()
        # Assert function returns a dictionary type
        self.assertIsInstance(wm_info, dict)

        wm_info_potential_keys = {
            "colorbuffer",
            "connection",
            "data",
            "dfb",
            "display",
            "framebuffer",
            "fswindow",
            "hdc",
            "hglrc",
            "hinstance",
            "lock_func",
            "resolveFramebuffer",
            "shell_surface",
            "surface",
            "taskHandle",
            "unlock_func",
            "wimpVersion",
            "window",
            "wmwindow",
        }

        # If any unexpected dict keys are present, they
        # will be stored in set wm_info_remaining_keys
        wm_info_remaining_keys = set(wm_info.keys()).difference(wm_info_potential_keys)

        # Assert set is empty (& therefore does not
        # contain unexpected dict keys)
        self.assertFalse(wm_info_remaining_keys)

    @unittest.skipIf(
        (
            "skipping for all because some failures on rasppi and maybe other platforms"
            or os.environ.get("SDL_VIDEODRIVER") == "dummy"
        ),
        'OpenGL requires a non-"dummy" SDL_VIDEODRIVER',
    )
    def test_gl_get_attribute(self):
        screen = display.set_mode((0, 0), pygame.OPENGL)

        # We create a list where we store the original values of the
        # flags before setting them with a different value.
        original_values = []

        original_values.append(pygame.display.gl_get_attribute(pygame.GL_ALPHA_SIZE))
        original_values.append(pygame.display.gl_get_attribute(pygame.GL_DEPTH_SIZE))
        original_values.append(pygame.display.gl_get_attribute(pygame.GL_STENCIL_SIZE))
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_ACCUM_RED_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_ACCUM_GREEN_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_ACCUM_BLUE_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_ACCUM_ALPHA_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLEBUFFERS)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLESAMPLES)
        )
        original_values.append(pygame.display.gl_get_attribute(pygame.GL_STEREO))

        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_ACCELERATED_VISUAL)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_MAJOR_VERSION)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_MINOR_VERSION)
        )
        original_values.append(pygame.display.gl_get_attribute(pygame.GL_CONTEXT_FLAGS))
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_PROFILE_MASK)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_SHARE_WITH_CURRENT_CONTEXT)
        )
        original_values.append(
            pygame.display.gl_get_attribute(pygame.GL_FRAMEBUFFER_SRGB_CAPABLE)
        )

        # Setting the flags with values supposedly different from the original values

        # assign SDL1-supported values with gl_set_attribute
        pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8)
        pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 24)
        pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 8)
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_RED_SIZE, 16)
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_GREEN_SIZE, 16)
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_BLUE_SIZE, 16)
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_ALPHA_SIZE, 16)
        pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1)
        pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 1)
        pygame.display.gl_set_attribute(pygame.GL_STEREO, 0)
        pygame.display.gl_set_attribute(pygame.GL_ACCELERATED_VISUAL, 0)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, 1)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, 1)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_FLAGS, 0)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, 0)
        pygame.display.gl_set_attribute(pygame.GL_SHARE_WITH_CURRENT_CONTEXT, 0)
        pygame.display.gl_set_attribute(pygame.GL_FRAMEBUFFER_SRGB_CAPABLE, 0)

        # We create a list where we store the values that we set each flag to
        set_values = [8, 24, 8, 16, 16, 16, 16, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0]

        # We create a list where we store the values after getting them
        get_values = []

        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_DEPTH_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_STENCIL_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_RED_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_GREEN_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_BLUE_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLEBUFFERS))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLESAMPLES))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_STEREO))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCELERATED_VISUAL))
        get_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_MAJOR_VERSION)
        )
        get_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_MINOR_VERSION)
        )
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_CONTEXT_FLAGS))
        get_values.append(
            pygame.display.gl_get_attribute(pygame.GL_CONTEXT_PROFILE_MASK)
        )
        get_values.append(
            pygame.display.gl_get_attribute(pygame.GL_SHARE_WITH_CURRENT_CONTEXT)
        )
        get_values.append(
            pygame.display.gl_get_attribute(pygame.GL_FRAMEBUFFER_SRGB_CAPABLE)
        )

        # We check to see if the values that we get correspond to the values that we set
        # them to or to the original values.
        for i in range(len(original_values)):
            self.assertTrue(
                (get_values[i] == original_values[i])
                or (get_values[i] == set_values[i])
            )

        # test using non-flag argument
        with self.assertRaises(TypeError):
            pygame.display.gl_get_attribute("DUMMY")

    @unittest.skipIf(
        (
            "skipping for all because some failures on rasppi and maybe other platforms"
            or os.environ.get("SDL_VIDEODRIVER") == "dummy"
        ),
        'OpenGL requires a non-"dummy" SDL_VIDEODRIVER',
    )
    def test_gl_get_attribute_kwargs(self):
        screen = display.set_mode((0, 0), pygame.OPENGL)

        # We create a list where we store the original values of the
        # flags before setting them with a different value.
        original_values = []

        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ALPHA_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_DEPTH_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_STENCIL_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_RED_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_GREEN_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_BLUE_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_ALPHA_SIZE)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLEBUFFERS)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLESAMPLES)
        )
        original_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_STEREO))

        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCELERATED_VISUAL)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_MAJOR_VERSION)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_MINOR_VERSION)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_FLAGS)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_PROFILE_MASK)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_SHARE_WITH_CURRENT_CONTEXT)
        )
        original_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_FRAMEBUFFER_SRGB_CAPABLE)
        )

        # Setting the flags with values supposedly different from the original values

        # assign SDL1-supported values with gl_set_attribute
        pygame.display.gl_set_attribute(flag=pygame.GL_ALPHA_SIZE, value=8)
        pygame.display.gl_set_attribute(flag=pygame.GL_DEPTH_SIZE, value=24)
        pygame.display.gl_set_attribute(flag=pygame.GL_STENCIL_SIZE, value=8)
        pygame.display.gl_set_attribute(flag=pygame.GL_ACCUM_RED_SIZE, value=16)
        pygame.display.gl_set_attribute(flag=pygame.GL_ACCUM_GREEN_SIZE, value=16)
        pygame.display.gl_set_attribute(flag=pygame.GL_ACCUM_BLUE_SIZE, value=16)
        pygame.display.gl_set_attribute(flag=pygame.GL_ACCUM_ALPHA_SIZE, value=16)
        pygame.display.gl_set_attribute(flag=pygame.GL_MULTISAMPLEBUFFERS, value=1)
        pygame.display.gl_set_attribute(flag=pygame.GL_MULTISAMPLESAMPLES, value=1)
        pygame.display.gl_set_attribute(flag=pygame.GL_STEREO, value=0)
        pygame.display.gl_set_attribute(flag=pygame.GL_ACCELERATED_VISUAL, value=0)
        pygame.display.gl_set_attribute(flag=pygame.GL_CONTEXT_MAJOR_VERSION, value=1)
        pygame.display.gl_set_attribute(flag=pygame.GL_CONTEXT_MINOR_VERSION, value=1)
        pygame.display.gl_set_attribute(flag=pygame.GL_CONTEXT_FLAGS, value=0)
        pygame.display.gl_set_attribute(flag=pygame.GL_CONTEXT_PROFILE_MASK, value=0)
        pygame.display.gl_set_attribute(
            flag=pygame.GL_SHARE_WITH_CURRENT_CONTEXT, value=0
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_FRAMEBUFFER_SRGB_CAPABLE, value=0
        )

        # We create a list where we store the values that we set each flag to
        set_values = [8, 24, 8, 16, 16, 16, 16, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0]

        # We create a list where we store the values after getting them
        get_values = []

        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_DEPTH_SIZE))
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_STENCIL_SIZE))
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_RED_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_GREEN_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_BLUE_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_ALPHA_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLEBUFFERS)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLESAMPLES)
        )
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_STEREO))
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCELERATED_VISUAL)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_MAJOR_VERSION)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_MINOR_VERSION)
        )
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_FLAGS))
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_CONTEXT_PROFILE_MASK)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_SHARE_WITH_CURRENT_CONTEXT)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_FRAMEBUFFER_SRGB_CAPABLE)
        )

        # We check to see if the values that we get correspond to the values that we set
        # them to or to the original values.
        for i in range(len(original_values)):
            self.assertTrue(
                (get_values[i] == original_values[i])
                or (get_values[i] == set_values[i])
            )

        # test using non-flag argument
        with self.assertRaises(TypeError):
            pygame.display.gl_get_attribute("DUMMY")

    @unittest.skipIf(
        (
            "skipping for all because some failures on rasppi and maybe other platforms"
            or os.environ.get("SDL_VIDEODRIVER") == "dummy"
        ),
        'OpenGL requires a non-"dummy" SDL_VIDEODRIVER',
    )
    def test_gl_set_attribute(self):
        # __doc__ (as of 2008-08-02) for pygame.display.gl_set_attribute:

        # pygame.display.gl_set_attribute(flag, value): return None
        # request an opengl display attribute for the display mode
        #
        # When calling pygame.display.set_mode() with the pygame.OPENGL flag,
        # Pygame automatically handles setting the OpenGL attributes like
        # color and doublebuffering. OpenGL offers several other attributes
        # you may want control over. Pass one of these attributes as the flag,
        # and its appropriate value. This must be called before
        # pygame.display.set_mode()
        #
        # The OPENGL flags are;
        #   GL_ALPHA_SIZE, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
        #   GL_ACCUM_GREEN_SIZE,  GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE,
        #   GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_STEREO

        screen = display.set_mode((0, 0), pygame.OPENGL)

        # We create a list where we store the values that we set each flag to
        set_values = [8, 24, 8, 16, 16, 16, 16, 1, 1, 0]

        # Setting the flags with values supposedly different from the original values

        # assign SDL1-supported values with gl_set_attribute
        pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, set_values[0])
        pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, set_values[1])
        pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, set_values[2])
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_RED_SIZE, set_values[3])
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_GREEN_SIZE, set_values[4])
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_BLUE_SIZE, set_values[5])
        pygame.display.gl_set_attribute(pygame.GL_ACCUM_ALPHA_SIZE, set_values[6])
        pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, set_values[7])
        pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, set_values[8])
        pygame.display.gl_set_attribute(pygame.GL_STEREO, set_values[9])

        # We create a list where we store the values after getting them
        get_values = []

        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_DEPTH_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_STENCIL_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_RED_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_GREEN_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_BLUE_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_ACCUM_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLEBUFFERS))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLESAMPLES))
        get_values.append(pygame.display.gl_get_attribute(pygame.GL_STEREO))

        # We check to see if the values that we get correspond to the values that we set
        # them to or to the original values.
        for i in range(len(set_values)):
            self.assertTrue(get_values[i] == set_values[i])

        # test using non-flag argument
        with self.assertRaises(TypeError):
            pygame.display.gl_get_attribute("DUMMY")

    @unittest.skipIf(
        (
            "skipping for all because some failures on rasppi and maybe other platforms"
            or os.environ.get("SDL_VIDEODRIVER") == "dummy"
        ),
        'OpenGL requires a non-"dummy" SDL_VIDEODRIVER',
    )
    def test_gl_set_attribute_kwargs(self):
        # __doc__ (as of 2008-08-02) for pygame.display.gl_set_attribute:

        # pygame.display.gl_set_attribute(flag, value): return None
        # request an opengl display attribute for the display mode
        #
        # When calling pygame.display.set_mode() with the pygame.OPENGL flag,
        # Pygame automatically handles setting the OpenGL attributes like
        # color and doublebuffering. OpenGL offers several other attributes
        # you may want control over. Pass one of these attributes as the flag,
        # and its appropriate value. This must be called before
        # pygame.display.set_mode()
        #
        # The OPENGL flags are;
        #   GL_ALPHA_SIZE, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
        #   GL_ACCUM_GREEN_SIZE,  GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE,
        #   GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_STEREO

        screen = display.set_mode((0, 0), pygame.OPENGL)

        # We create a list where we store the values that we set each flag to
        set_values = [8, 24, 8, 16, 16, 16, 16, 1, 1, 0]

        # Setting the flags with values supposedly different from the original values

        # assign SDL1-supported values with gl_set_attribute
        pygame.display.gl_set_attribute(flag=pygame.GL_ALPHA_SIZE, value=set_values[0])
        pygame.display.gl_set_attribute(flag=pygame.GL_DEPTH_SIZE, value=set_values[1])
        pygame.display.gl_set_attribute(
            flag=pygame.GL_STENCIL_SIZE, value=set_values[2]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_ACCUM_RED_SIZE, value=set_values[3]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_ACCUM_GREEN_SIZE, value=set_values[4]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_ACCUM_BLUE_SIZE, value=set_values[5]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_ACCUM_ALPHA_SIZE, value=set_values[6]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_MULTISAMPLEBUFFERS, value=set_values[7]
        )
        pygame.display.gl_set_attribute(
            flag=pygame.GL_MULTISAMPLESAMPLES, value=set_values[8]
        )
        pygame.display.gl_set_attribute(flag=pygame.GL_STEREO, value=set_values[9])

        # We create a list where we store the values after getting them
        get_values = []

        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_ALPHA_SIZE))
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_DEPTH_SIZE))
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_STENCIL_SIZE))
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_RED_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_GREEN_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_BLUE_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_ACCUM_ALPHA_SIZE)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLEBUFFERS)
        )
        get_values.append(
            pygame.display.gl_get_attribute(flag=pygame.GL_MULTISAMPLESAMPLES)
        )
        get_values.append(pygame.display.gl_get_attribute(flag=pygame.GL_STEREO))

        # We check to see if the values that we get correspond to the values that we set
        # them to or to the original values.
        for i in range(len(set_values)):
            self.assertTrue(get_values[i] == set_values[i])

        # test using non-flag argument
        with self.assertRaises(TypeError):
            pygame.display.gl_get_attribute("DUMMY")

    @unittest.skipIf(
        os.environ.get("SDL_VIDEODRIVER") in ["dummy", "android"],
        "iconify is only supported on some video drivers/platforms",
    )
    def test_iconify(self):
        pygame.display.set_mode((640, 480))

        self.assertEqual(pygame.display.get_active(), True)

        success = pygame.display.iconify()

        if success:
            active_event = window_minimized_event = False
            # make sure we cycle the event loop enough to get the display
            # hidden. Test that both ACTIVEEVENT and WINDOWMINIMISED event appears
            for _ in range(50):
                time.sleep(0.01)
                for event in pygame.event.get():
                    if event.type == pygame.ACTIVEEVENT:
                        if not event.gain and event.state == pygame.APPACTIVE:
                            active_event = True
                    if event.type == pygame.WINDOWMINIMIZED:
                        window_minimized_event = True

            self.assertTrue(window_minimized_event)
            self.assertTrue(active_event)
            self.assertFalse(pygame.display.get_active())

        else:
            self.fail("Iconify not supported on this platform, please skip")

    def test_init(self):
        """Ensures the module is initialized after init called."""
        # display.init() already called in setUp(), so quit and re-init
        display.quit()
        display.init()

        self.assertTrue(display.get_init())

    def test_init__multiple(self):
        """Ensures the module is initialized after multiple init calls."""
        display.init()
        display.init()

        self.assertTrue(display.get_init())

    def test_list_modes(self):
        modes = pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN, display=0)
        # modes == -1 means any mode is supported.
        if modes != -1:
            self.assertEqual(len(modes[0]), 2)
            self.assertEqual(type(modes[0][0]), int)

        modes = pygame.display.list_modes()
        if modes != -1:
            self.assertEqual(len(modes[0]), 2)
            self.assertEqual(type(modes[0][0]), int)
            self.assertEqual(len(modes), len(set(modes)))

        modes = pygame.display.list_modes(depth=0, flags=0, display=0)
        if modes != -1:
            self.assertEqual(len(modes[0]), 2)
            self.assertEqual(type(modes[0][0]), int)

    def test_mode_ok(self):
        pygame.display.mode_ok((128, 128))
        modes = pygame.display.list_modes()
        if modes != -1:
            size = modes[0]
            self.assertNotEqual(pygame.display.mode_ok(size), 0)

        pygame.display.mode_ok((128, 128), 0, 32)
        pygame.display.mode_ok((128, 128), flags=0, depth=32, display=0)

    def test_mode_ok_fullscreen(self):
        modes = pygame.display.list_modes()
        if modes != -1:
            size = modes[0]
            self.assertNotEqual(
                pygame.display.mode_ok(size, flags=pygame.FULLSCREEN), 0
            )

    def test_mode_ok_scaled(self):
        modes = pygame.display.list_modes()
        if modes != -1:
            size = modes[0]
            self.assertNotEqual(pygame.display.mode_ok(size, flags=pygame.SCALED), 0)

    def test_get_num_displays(self):
        self.assertGreater(pygame.display.get_num_displays(), 0)

    def test_quit(self):
        """Ensures the module is not initialized after quit called."""
        display.quit()

        self.assertFalse(display.get_init())

    def test_quit__multiple(self):
        """Ensures the module is not initialized after multiple quit calls."""
        display.quit()
        display.quit()

        self.assertFalse(display.get_init())

    @unittest.skipIf(
        os.environ.get("SDL_VIDEODRIVER") == "dummy", "Needs a not dummy videodriver"
    )
    def test_set_gamma(self):
        pygame.display.set_mode((1, 1))

        gammas = [0.25, 0.5, 0.88, 1.0]
        for gamma in gammas:
            with self.subTest(gamma=gamma):
                with self.assertWarns(DeprecationWarning):
                    self.assertEqual(pygame.display.set_gamma(gamma), True)
                self.assertEqual(pygame.display.set_gamma(gamma), True)

    @unittest.skipIf(
        os.environ.get("SDL_VIDEODRIVER") == "dummy", "Needs a not dummy videodriver"
    )
    def test_set_gamma__tuple(self):
        pygame.display.set_mode((1, 1))

        gammas = [(0.5, 0.5, 0.5), (1.0, 1.0, 1.0), (0.25, 0.33, 0.44)]
        for r, g, b in gammas:
            with self.subTest(r=r, g=g, b=b):
                self.assertEqual(pygame.display.set_gamma(r, g, b), True)

    @unittest.skipIf(
        not hasattr(pygame.display, "set_gamma_ramp"),
        "Not all systems and hardware support gamma ramps",
    )
    def test_set_gamma_ramp(self):
        # __doc__ (as of 2008-08-02) for pygame.display.set_gamma_ramp:

        # change the hardware gamma ramps with a custom lookup
        # pygame.display.set_gamma_ramp(red, green, blue): return bool
        # set_gamma_ramp(red, green, blue): return bool
        #
        # Set the red, green, and blue gamma ramps with an explicit lookup
        # table. Each argument should be sequence of 256 integers. The
        # integers should range between 0 and 0xffff. Not all systems and
        # hardware support gamma ramps, if the function succeeds it will
        # return True.
        #
        pygame.display.set_mode((5, 5))
        r = list(range(256))
        g = [number + 256 for number in r]
        b = [number + 256 for number in g]
        with self.assertWarns(DeprecationWarning):
            isSupported = pygame.display.set_gamma_ramp(r, g, b)
        if isSupported:
            self.assertTrue(pygame.display.set_gamma_ramp(r, g, b))
        else:
            self.assertFalse(pygame.display.set_gamma_ramp(r, g, b))

    def test_set_mode_kwargs(self):
        pygame.display.set_mode(size=(1, 1), flags=0, depth=0, display=0)

    def test_set_mode_scaled(self):
        surf = pygame.display.set_mode(
            size=(1, 1), flags=pygame.SCALED, depth=0, display=0
        )
        winsize = pygame.display.get_window_size()
        self.assertEqual(
            winsize[0] % surf.get_size()[0],
            0,
            "window width should be a multiple of the surface width",
        )
        self.assertEqual(
            winsize[1] % surf.get_size()[1],
            0,
            "window height should be a multiple of the surface height",
        )
        self.assertEqual(
            winsize[0] / surf.get_size()[0], winsize[1] / surf.get_size()[1]
        )

    def test_set_mode_vector2(self):
        pygame.display.set_mode(pygame.Vector2(1, 1))

    def test_set_mode_unscaled(self):
        """Ensures a window created with SCALED can become smaller."""
        # see https://github.com/pygame/pygame/issues/2327

        screen = pygame.display.set_mode((300, 300), pygame.SCALED)
        self.assertEqual(screen.get_size(), (300, 300))

        screen = pygame.display.set_mode((200, 200))
        self.assertEqual(screen.get_size(), (200, 200))

    def test_screensaver_support(self):
        pygame.display.set_allow_screensaver(True)
        self.assertTrue(pygame.display.get_allow_screensaver())
        pygame.display.set_allow_screensaver(False)
        self.assertFalse(pygame.display.get_allow_screensaver())
        pygame.display.set_allow_screensaver()
        self.assertTrue(pygame.display.get_allow_screensaver())

    # the following test fails always with SDL2
    @unittest.skipIf(True, "set_palette() not supported in SDL2")
    def test_set_palette(self):
        with self.assertRaises(pygame.error):
            palette = [1, 2, 3]
            pygame.display.set_palette(palette)
        pygame.display.set_mode((1024, 768), 0, 8)
        palette = []
        self.assertIsNone(pygame.display.set_palette(palette))

        with self.assertRaises(ValueError):
            palette = 12
            pygame.display.set_palette(palette)
        with self.assertRaises(TypeError):
            palette = [[1, 2], [1, 2]]
            pygame.display.set_palette(palette)
        with self.assertRaises(TypeError):
            palette = [[0, 0, 0, 0, 0]] + [[x, x, x, x, x] for x in range(1, 255)]
            pygame.display.set_palette(palette)
        with self.assertRaises(TypeError):
            palette = "qwerty"
            pygame.display.set_palette(palette)
        with self.assertRaises(TypeError):
            palette = [[123, 123, 123] * 10000]
            pygame.display.set_palette(palette)
        with self.assertRaises(TypeError):
            palette = [1, 2, 3]
            pygame.display.set_palette(palette)

    skip_list = ["dummy", "android"]

    @unittest.skipIf(True, "set_palette() not supported in SDL2")
    def test_set_palette_kwargs(self):
        with self.assertRaises(pygame.error):
            palette = [1, 2, 3]
            pygame.display.set_palette(palette=palette)
        pygame.display.set_mode((1024, 768), 0, 8)
        palette = []
        self.assertIsNone(pygame.display.set_palette(palette=palette))

        with self.assertRaises(ValueError):
            palette = 12
            pygame.display.set_palette(palette=palette)
        with self.assertRaises(TypeError):
            palette = [[1, 2], [1, 2]]
            pygame.display.set_palette(palette=palette)
        with self.assertRaises(TypeError):
            palette = [[0, 0, 0, 0, 0]] + [[x, x, x, x, x] for x in range(1, 255)]
            pygame.display.set_palette(palette=palette)
        with self.assertRaises(TypeError):
            palette = "qwerty"
            pygame.display.set_palette(palette=palette)
        with self.assertRaises(TypeError):
            palette = [[123, 123, 123] * 10000]
            pygame.display.set_palette(palette=palette)
        with self.assertRaises(TypeError):
            palette = [1, 2, 3]
            pygame.display.set_palette(palette=palette)

    skip_list = ["dummy", "android"]

    @unittest.skipIf(
        os.environ.get("SDL_VIDEODRIVER") in skip_list,
        "requires the SDL_VIDEODRIVER to be non dummy",
    )
    def test_toggle_fullscreen(self):
        """Test for toggle fullscreen"""

        # try to toggle fullscreen with no active display
        # this should result in an error
        pygame.display.quit()
        with self.assertRaises(pygame.error):
            pygame.display.toggle_fullscreen()

        pygame.display.init()
        width_height = (640, 480)
        test_surf = pygame.display.set_mode(width_height)

        # try to toggle fullscreen
        try:
            pygame.display.toggle_fullscreen()

        except pygame.error:
            self.fail()

        else:
            # if toggle success, the width/height should be a
            # value found in list_modes
            if pygame.display.toggle_fullscreen() == 1:
                boolean = (
                    test_surf.get_width(),
                    test_surf.get_height(),
                ) in pygame.display.list_modes(
                    depth=0, flags=pygame.FULLSCREEN, display=0
                )

                self.assertEqual(boolean, True)

            # if not original width/height should be preserved
            else:
                self.assertEqual(
                    (test_surf.get_width(), test_surf.get_height()), width_height
                )


class DisplayUpdateTest(unittest.TestCase):
    def question(self, qstr):
        """this is used in the interactive subclass."""

    def setUp(self):
        display.init()
        self.screen = pygame.display.set_mode((500, 500))
        self.screen.fill("black")
        pygame.display.flip()
        pygame.event.pump()  # so mac updates

    def tearDown(self):
        display.quit()

    def test_update_negative(self):
        """takes rects with negative values."""
        self.screen.fill("green")

        r1 = pygame.Rect(0, 0, 100, 100)
        pygame.display.update(r1)

        r2 = pygame.Rect(-10, 0, 100, 100)
        pygame.display.update(r2)

        r3 = pygame.Rect(-10, 0, -100, -100)
        pygame.display.update(r3)

        self.question("Is the screen green in (0, 0, 100, 100)?")

    def test_update_sequence(self):
        """only updates the part of the display given by the rects."""
        self.screen.fill("green")
        rects = [
            pygame.Rect(0, 0, 100, 100),
            pygame.Rect(100, 0, 100, 100),
            pygame.Rect(200, 0, 100, 100),
            pygame.Rect(300, 300, 100, 100),
        ]
        pygame.display.update(rects)
        pygame.event.pump()  # so mac updates

        self.question(f"Is the screen green in {rects}?")

    def test_update_none_skipped(self):
        """None is skipped inside sequences."""
        self.screen.fill("green")
        rects = (
            None,
            pygame.Rect(100, 0, 100, 100),
            None,
            pygame.Rect(200, 0, 100, 100),
            pygame.Rect(300, 300, 100, 100),
        )
        pygame.display.update(rects)
        pygame.event.pump()  # so mac updates

        self.question(f"Is the screen green in {rects}?")

    def test_update_none(self):
        """does NOT update the display."""
        self.screen.fill("green")
        pygame.display.update(None)
        pygame.event.pump()  # so mac updates
        self.question("Is the screen black and NOT green?")

    def test_update_no_args(self):
        """does NOT update the display."""
        self.screen.fill("green")
        pygame.display.update()
        pygame.event.pump()  # so mac updates
        self.question("Is the WHOLE screen green?")

    def test_update_args(self):
        """updates the display using the args as a rect."""
        self.screen.fill("green")
        pygame.display.update(100, 100, 100, 100)
        pygame.event.pump()  # so mac updates
        self.question("Is the screen green in (100, 100, 100, 100)?")

    def test_update_incorrect_args(self):
        """raises a ValueError when inputs are wrong."""

        with self.assertRaises(ValueError):
            pygame.display.update(100, "asdf", 100, 100)

        with self.assertRaises(ValueError):
            pygame.display.update([100, "asdf", 100, 100])

    def test_update_no_init(self):
        """raises a pygame.error."""

        pygame.display.quit()
        with self.assertRaises(pygame.error):
            pygame.display.update()


class DisplayUpdateInteractiveTest(DisplayUpdateTest):
    """Because we want these tests to run as interactive and not interactive."""

    __tags__ = ["interactive"]

    def question(self, qstr):
        """since this is the interactive subclass we ask a question."""
        question(qstr)


class DisplayInteractiveTest(unittest.TestCase):
    __tags__ = ["interactive"]

    def test_set_icon_interactive(self):
        os.environ["SDL_VIDEO_WINDOW_POS"] = "100,250"
        pygame.display.quit()
        pygame.display.init()

        test_icon = pygame.Surface((32, 32))
        test_icon.fill((255, 0, 0))

        pygame.display.set_icon(test_icon)
        screen = pygame.display.set_mode((400, 100))
        pygame.display.set_caption("Is the window icon a red square?")

        response = question("Is the display icon red square?")

        self.assertTrue(response)
        pygame.display.quit()

    def test_set_gamma_ramp(self):
        os.environ["SDL_VIDEO_WINDOW_POS"] = "100,250"
        pygame.display.quit()
        pygame.display.init()

        screen = pygame.display.set_mode((400, 100))
        screen.fill((100, 100, 100))

        blue_ramp = [x * 256 for x in range(0, 256)]
        blue_ramp[100] = 150 * 256  # Can't tint too far or gamma ramps fail
        normal_ramp = [x * 256 for x in range(0, 256)]
        # test to see if this platform supports gamma ramps
        gamma_success = False
        if pygame.display.set_gamma_ramp(normal_ramp, normal_ramp, blue_ramp):
            pygame.display.update()
            gamma_success = True

        if gamma_success:
            response = question("Is the window background tinted blue?")
            self.assertTrue(response)
            # restore normal ramp
            pygame.display.set_gamma_ramp(normal_ramp, normal_ramp, normal_ramp)

        pygame.display.quit()


class FullscreenToggleTests(unittest.TestCase):
    __tags__ = ["interactive"]

    screen = None
    font = None
    isfullscreen = False

    WIDTH = 800
    HEIGHT = 600

    def setUp(self):
        pygame.init()
        if sys.platform == "win32":
            # known issue with windows, must have mode from pygame.display.list_modes()
            # or window created with flag pygame.SCALED
            self.screen = pygame.display.set_mode(
                (self.WIDTH, self.HEIGHT), flags=pygame.SCALED
            )
        else:
            self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
        pygame.display.set_caption("Fullscreen Tests")
        self.screen.fill((255, 255, 255))
        pygame.display.flip()
        self.font = pygame.font.Font(None, 32)

    def tearDown(self):
        if self.isfullscreen:
            pygame.display.toggle_fullscreen()
        pygame.quit()

    def visual_test(self, fullscreen=False):
        text = ""
        if fullscreen:
            if not self.isfullscreen:
                pygame.display.toggle_fullscreen()
                self.isfullscreen = True
            text = "Is this in fullscreen? [y/n]"
        else:
            if self.isfullscreen:
                pygame.display.toggle_fullscreen()
                self.isfullscreen = False
            text = "Is this not in fullscreen [y/n]"
        s = self.font.render(text, False, (0, 0, 0))
        self.screen.blit(s, (self.WIDTH / 2 - self.font.size(text)[0] / 2, 100))
        pygame.display.flip()

        while True:
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        return False
                    if event.key == pygame.K_y:
                        return True
                    if event.key == pygame.K_n:
                        return False
                if event.type == pygame.QUIT:
                    return False

    def test_fullscreen_true(self):
        self.assertTrue(self.visual_test(fullscreen=True))

    def test_fullscreen_false(self):
        self.assertTrue(self.visual_test(fullscreen=False))


@unittest.skipIf(
    os.environ.get("SDL_VIDEODRIVER") == "dummy",
    'OpenGL requires a non-"dummy" SDL_VIDEODRIVER',
)
class DisplayOpenGLTest(unittest.TestCase):
    def test_screen_size_opengl(self):
        """returns a surface with the same size requested.
        |tags:display,slow,opengl|
        """
        pygame.display.init()
        screen = pygame.display.set_mode((640, 480), pygame.OPENGL)
        self.assertEqual((640, 480), screen.get_size())


class X11CrashTest(unittest.TestCase):
    def test_x11_set_mode_crash_gh1654(self):
        # Test for https://github.com/pygame/pygame/issues/1654
        # If unfixed, this will trip a segmentation fault
        pygame.display.init()
        pygame.display.quit()
        screen = pygame.display.set_mode((640, 480), 0)
        self.assertEqual((640, 480), screen.get_size())


if __name__ == "__main__":
    unittest.main()