1 /* test-screens.c --- some test cases for the "monitor sanity" checks.
2 * xscreensaver, Copyright (c) 2008 Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
19 /* This file doesn't need the Xt headers, so stub these types out... */
21 #define XtAppContext void*
22 #define XrmDatabase void*
23 #define XtIntervalId void*
24 #define XtPointer void*
27 #include "xscreensaver.h"
32 #define WidthOfScreen(s) 10240
33 #define HeightOfScreen(s) 10240
36 #define screen_number(s) (0)
38 #include "screens.c" /* to get at static void check_monitor_sanity() */
41 char *progclass = "XScreenSaver";
43 const char *blurb(void) { return progname; }
45 Bool safe_XF86VidModeGetViewPort(Display *d, int i, int *x, int *y) { abort(); }
46 void initialize_screen_root_widget(saver_screen_info *ssi) { abort(); }
47 Visual *get_best_gl_visual (saver_info *si, Screen *sc) { abort(); }
51 failstr (monitor_sanity san)
54 case S_SANE: return "OK";
55 case S_ENCLOSED: return "ENC";
56 case S_DUPLICATE: return "DUP";
57 case S_OVERLAP: return "OVR";
58 case S_OFFSCREEN: return "OFF";
59 case S_DISABLED: return "DIS";
65 test (int testnum, const char *screens, const char *desired)
67 monitor *monitors[100];
71 char *token = strtok (strdup(screens), ",");
74 monitor *m = calloc (1, sizeof (monitor));
76 m->id = (testnum * 1000) + nscreens;
77 if (4 != sscanf (token, "%dx%d+%d+%d%c",
78 &m->width, &m->height, &m->x, &m->y, &c))
80 fprintf (stderr, "%s: unparsable geometry: %s\n", blurb(), token);
83 monitors[nscreens] = m;
85 token = strtok (0, ",");
87 monitors[nscreens] = 0;
89 check_monitor_sanity (monitors);
92 for (i = 0; i < nscreens; i++)
94 monitor *m = monitors[i];
95 if (out != result) *out++ = ',';
96 if (m->sanity == S_SANE)
97 sprintf (out, "%dx%d+%d+%d", m->width, m->height, m->x, m->y);
99 strcpy (out, failstr (m->sanity));
104 if (!strcmp (result, desired))
105 fprintf (stderr, "%s: test %2d OK\n", blurb(), testnum);
107 fprintf (stderr, "%s: test %2d FAILED:\n"
119 SI.monitor_layout = monitors;
120 describe_monitor_layout (&SI);
130 # define A(a) test (i++, a, a);
131 # define B(a,b) test (i++, a, b)
135 A("1024x768+0+0,1024x768+1024+0");
136 A("1024x768+0+0,1024x768+0+768");
137 A("1024x768+0+0,1024x768+0+768,1024x768+1024+0");
139 B("1024x768+999999+0",
141 B("1024x768+-999999+-999999",
143 B("1024x768+0+0,1024x768+0+0",
145 B("1024x768+0+0,1024x768+0+0,1024x768+0+0",
146 "1024x768+0+0,DUP,DUP");
147 B("1024x768+0+0,1024x768+1024+0,1024x768+0+0",
148 "1024x768+0+0,1024x768+1024+0,DUP");
149 B("1280x1024+0+0,1024x768+0+64,800x600+0+0,640x480+0+0,720x400+0+0",
150 "1280x1024+0+0,ENC,ENC,ENC,ENC");
151 B("1024x768+0+64,1280x1024+0+0,800x600+0+0,640x480+0+0,800x600+0+0,720x400+0+0",
152 "ENC,1280x1024+0+0,ENC,ENC,ENC,ENC");
153 B("1024x768+0+64,1280x1024+0+0,800x600+0+0,640x480+0+0,1280x1024+0+0,720x400+0+0",
154 "ENC,1280x1024+0+0,ENC,ENC,DUP,ENC");
155 B("720x400+0+0,640x480+0+0,800x600+0+0,1024x768+0+64,1280x1024+0+0",
156 "ENC,ENC,ENC,ENC,1280x1024+0+0");
157 B("1280x1024+0+0,800x600+1280+0,800x600+1300+0",
158 "1280x1024+0+0,800x600+1280+0,OVR");
159 B("1280x1024+0+0,800x600+1280+0,800x600+1300+0,1280x1024+0+0,800x600+1280+0",
160 "1280x1024+0+0,800x600+1280+0,OVR,DUP,DUP");
162 /* +-------------+----+ +------+---+ 1: 1440x900, widescreen display
163 | : | | 3+4 : | 2: 1280x1024, conventional display
164 | 1+2 : 1 | +......+ | 3: 1024x768, laptop
165 | : | | 3 | 4: 800x600, external projector
166 +.............+----+ +----------+
171 B("1440x900+0+0,1280x1024+0+0,1024x768+1440+0,800x600+1440+0",
172 "1440x900+0+0,OVR,1024x768+1440+0,ENC");
173 B("800x600+0+0,800x600+0+0,800x600+800+0",
174 "800x600+0+0,DUP,800x600+800+0");
175 B("1600x1200+0+0,1360x768+0+0",
176 "1600x1200+0+0,ENC");
181 main (int argc, char **argv)
185 s = strrchr(progname, '/');
186 if (s) progname = s+1;
189 fprintf (stderr, "usage: %s\n", argv[0]);