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
|
Copyright (c) 2005 X.Org Foundation LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
All Rights Reserved.
>>#
>># Project: VSW5
>>#
>># File: xts/Xlib14/XmbSetWMProperties.m
>>#
>># Description:
>># Tests for XmbSetWMProperties()
>>#
>># Modifications:
>># $Log: mbswmprp.m,v $
>># Revision 1.1 2005-02-12 14:37:21 anderson
>># Initial revision
>>#
>># Revision 8.0 1998/12/23 23:38:57 mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0 1998/10/30 23:02:03 mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0 1998/03/02 05:29:58 tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0 1998/01/26 03:26:31 tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0 1995/12/15 09:23:57 tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1 1995/12/15 02:01:41 andy
>># Prepare for GA Release
>>#
>>AVSCODE
>>TITLE XmbSetWMProperties Xlib14
void
XmbSetWMProperties()
>>EXTERN
Display *display_good;
Window window_id_good;
long supplied ;
static XClassHint chints = {
"Resource",
"Class",
} ;
XClassHint *class_hints = &chints ;
static XWMHints wmhints = {
AllHints,
False,
IconicState,
12200,
100,
10,
10,
1200,
800,
} ;
XWMHints *wm_hints = &wmhints ;
char *window_name_good = "window" ;
char *icon_name_good = "icon" ;
static char *argv_good[]={
"CommandName",
"This",
"is",
"an",
"argument",
"list",
"used",
"to",
"verify",
"argument",
"vector",
"passing",
};
static int num_args_good = 12;
static XSizeHints sizehints ={
(PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect|PBaseSize|PWinGravity), /* flags */
90, /* x */
80, /* y */
200, /* width */
100, /* height */
10, /* min_width */
10, /* min_height */
1200, /* max_width */
800, /* max_height */
20, /* width_inc */
10, /* height_inc */
{5 , 5}, /* min_aspect numerator & denominator */
{10, 10}, /* max_aspect numerator & denominator */
10, /* base width */
10, /* base height */
NorthWestGravity /* win gravity */
};
XSizeHints *hints_good = &sizehints;
char *exec_file_name;
int x_init,
y_init,
h_init,
w_init;
svcmbSetWMProperties(display, window_id, window_name,
icon_name, argv, num_args, hints, wmh_good, classh_good)
Display *display;
Window window_id;
char *window_name;
char *icon_name;
char **argv;
int num_args;
XSizeHints *hints;
XWMHints *wmh_good;
XClassHint *classh_good ;
{
extern int errcnt;
extern int errflg;
extern int chkflg;
extern int signal_status();
extern int unexp_err();
extern char *svc_user_arg;
extern char *strcpy();
char fmtstr[256], *call_string;
union msglst fmt_lst[1];
int skip_pixcheck;
int
ss_status, /* save stat return status */
stat_status, /* check stat return status */
setup_status,
cleanup_status,
i1;
/*
* The following definitions are used in the checking code to verify
* that all the events occur as expected. They are used to
* index into an array of integers used to tally the occurrances of
* each event atom of our expected event type.
*/
#define NAME 0
#define ICON_NAME 1
#define WM_HINTS 2
#define COMMAND 3
#define NORMAL_HINTS 4
#define ONCE 1
static char *window_name_return, *icon_name_return;
static XSizeHints hints_return;
static XWMHints *wmhints_return;
static XClassHint class_hints_return;
static int NULL_SPOT = 1;
static unsigned char *data = NULL, *dptr;
static Atom actual_type;
static int actual_format, idx, i;
static unsigned long nitems, fitems;
static unsigned long leftover;
XEvent good_event, event_return_good;
/******
* Turn on buffering and buffer parameter information
* in case an error occurs
******/
regr_args.l_flags.bufrout = 1;
/* buffer display struct info for error checking */
bufrdisp(display);
drawable_id = window_id;
if (regr_args.iter == 0)
regr_args.iter = 1; /* set number of iterations to 1. */
if (regr_args.l_flags.setup)
setup_status = REGR_NORMAL;
XSync(display_arg, 0);
if (regr_args.l_flags.chksta == 1)
ss_status = save_stat(dpy_msk | win_msk ,
gc_id, display_arg, drawable_id);
first_error = 0; /* no errors encountered yet */
errflg = 0;
XSetErrorHandler(signal_status);
XmbSetWMProperties( display, window_id, window_name,
icon_name, argv, num_args,
hints, wmh_good, classh_good);
XSync(display_arg, 0);
XSetErrorHandler(unexp_err);
/* no colormap by default */
r_wait(display_arg, window_arg, time_delay, None);
if (regr_args.l_flags.chksta == 1)
stat_status = chek_stat (dpy_msk | win_msk ,
gc_id, display_arg,
drawable_id, ss_status);
else
stat_status = REGR_NORMAL;
if ((!errflg) && (!chkflg))
if ((badstat(display_arg, estatus, Success)) != REGR_NORMAL)
errflg = 1;
if ((regr_args.l_flags.check) &&
(errflg == 0) &&
(stat_status == REGR_NORMAL))
{
/*
* check that window_name is what we set (if anything)
* in service invocation
*/
(void)XFetchName(display, window_id, &window_name_return);
check_str("window", window_name_return, "window_name");
/* check that icon_name is what we set(if anything)in service invocation */
(void)XGetIconName(display, window_id, &icon_name_return);
check_str("icon", icon_name_return, "icon_name");
wmhints_return = XGetWMHints(display, window_id);
/*
* check the icon_pixmap id is what we set (if anything)
* in service invocation
* and that the .flags field is set to IconPixmapHint
*/
check_dec((long)AllHints, (long)wmhints_return->flags,
"WMHints .flags field");
/* check XSetCommand's argv array */
(void)XGetWindowProperty(display, /* Display */
window_id, /* Window */
XA_WM_COMMAND, /* property atom */
0L, /* long offset */
(long)BUFSIZ, /* long length */
False, /* delete Bool */
XA_STRING, /* atom identifier */
&actual_type, /* atom identifier */
&actual_format, /* format of property(8 bits) */
&nitems, /* number of 8 bit chars */
&leftover, /* bytes remaining on partial read */
&data); /* pointer to the data is spec format*/
/*
* check that the command property data returned
* matches all expected criteria
*/
check_uns (XA_STRING, actual_type,
"command property actual_type=XA_STRING");
check_dec ((long)8, (long)actual_format,
"command property actual_format");
check_dec ((long)0, leftover,
"command property leftover bytes");
/* Get actual length of argv list */
fitems=0;
for (i=0; i < num_args; i++)
fitems += strlen( argv[i]) + NULL_SPOT;
/*
* Walk thru the data buffer and verify that the
* argv arguments are intact
*/
dptr = data;
for(idx = 0, i = 0; *dptr; i++, dptr = &data[idx])
{
/* do some calc's */
idx = strlen((char *)dptr) + NULL_SPOT + idx;
check_str (argv[i], (char *)dptr,
"command property data string");
}
check_uns (fitems, nitems, "command property data length");
check_dec ((long)num_args, (long)i, "number of argv strings");
/*
* check the sizehints are what we set (if anything)
* in the service invocation
*/
(void) XGetWMNormalHints(display, window_id, &hints_return, &supplied);
check_dec((long)hints->flags, (long)hints_return.flags , "XSizeHints->flags");
check_dec((long)hints->x, (long)hints_return.x , "XSizeHints->x");
check_dec((long)hints->y, (long)hints_return.y , "XSizeHints->y");
check_dec((long)hints->width, (long)hints_return.width , "XSizeHints->width");
check_dec((long)hints->height, (long)hints_return.height , "XSizeHints->height");
check_dec((long)hints->min_width, (long)hints_return.min_width , "XSizeHints->min_width");
check_dec((long)hints->min_height, (long)hints_return.min_height , "XSizeHints->min_height");
check_dec((long)hints->max_width, (long)hints_return.max_width , "XSizeHints->max_width");
check_dec((long)hints->max_height, (long)hints_return.max_height , "XSizeHints->max_height");
check_dec((long)hints->width_inc, (long)hints_return.width_inc , "XSizeHints->width_inc");
check_dec((long)hints->height_inc, (long)hints_return.height_inc , "XSizeHints->height_inc");
check_dec((long)hints->min_aspect.x, (long)hints_return.min_aspect.x , "XSizeHints->min_aspect.x");
check_dec((long)hints->min_aspect.y, (long)hints_return.min_aspect.y , "XSizeHints->min_aspect.y");
check_dec((long)hints->max_aspect.x, (long)hints_return.max_aspect.x , "XSizeHints->max_aspect.x");
check_dec((long)hints->max_aspect.y, (long)hints_return.max_aspect.y , "XSizeHints->max_aspect.y");
check_dec((long)hints->base_width, (long)hints_return.base_width , "XSizeHints->base_width");
check_dec((long)hints->base_height, (long)hints_return.base_height , "XSizeHints->base_height");
check_dec((long)hints->win_gravity, (long)hints_return.win_gravity , "XSizeHints->win_gravity");
check_dec((long)wm_hints->flags, (long)wmhints_return->flags , "XWMHints->flags")
;
check_dec((long)wm_hints->input, (long)wmhints_return->input , "XWMHints->input")
;
check_dec((long)wm_hints->initial_state, (long)wmhints_return->initial_state , "XWMHints->initial_state");
check_dec((long)wm_hints->icon_window, (long)wmhints_return->icon_window , "XWMHints->icon_window");
check_dec((long)wm_hints->icon_x, (long)wmhints_return->icon_x , "XWMHints->icon_x");
check_dec((long)wm_hints->icon_y, (long)wmhints_return->icon_y , "XWMHints->icon_y");
check_dec((long)wm_hints->icon_mask, (long)wmhints_return->icon_mask , "XWMHints->icon_mask");
check_dec((long)wm_hints->window_group, (long)wmhints_return->window_group , "XWMHints->window_group");
(void)XGetClassHint(display_arg, window_arg, &class_hints_return);
/* check the class_hints structure */
check_str(class_hints->res_name, class_hints_return.res_name , "XClassHints->res_name");
check_str(class_hints->res_class, class_hints_return.res_class , "XClassHints->res_class");
} /* end of checking code */
XSync(display_arg, 0);
/* Free storage allocated by XGetWindowProperty & XGetWMHints */
if (regr_args.l_flags.cleanup)
{
if (data != NULL)
XFree ((char *)data);
if (wmhints_return != NULL)
XFree ((char *)wmhints_return);
if (class_hints_return.res_name != NULL)
(void)XFree(class_hints_return.res_name);
if (class_hints_return.res_class != NULL)
(void)XFree(class_hints_return.res_class);
XSync (display, 1); /* Discard leftover events */
}
XSync(display_arg, 0);
if (errflg)
{
errcnt++; /* ...increment the error count */
tet_result(TET_FAIL);
}
/*****
* clear all flags
*****/
chkflg = 0;
regr_args.l_flags.bufrout = 0;
dumpbuf();
}
>>ASSERTION Good C
If the implementation is X11R5 or later:
If the value for a window argument does not name a defined window
a call to xname shall return the BadWindow error code.
>>CODE
#if XT_X_RELEASE > 4
display_arg = Dsp;
/*
* Create a GC to save environmental data in
*/
gc_save = XCreateGC(display_arg,
XRootWindow(display_arg,XDefaultScreen(display_arg)),(unsigned long)0,(XGCValues *)0);
BorderPixel = XBlackPixel(display_arg,XDefaultScreen(display_arg));
BackgroundPixel = XWhitePixel(display_arg,XDefaultScreen(display_arg));
colormap_arg = XDefaultColormap(display_arg, XDefaultScreen(display_arg));
PixPerCM = XDisplayWidth(display_arg,
XDefaultScreen(display_arg))*10/XDisplayWidthMM(display_arg,
XDefaultScreen(display_arg));
MaxDisplayWidth = XDisplayWidth(display_arg, XDefaultScreen(display_arg));
MaxDisplayHeight = XDisplayHeight(display_arg, XDefaultScreen(display_arg));
DisplayCenterX = (MaxDisplayWidth / 2) - PixPerCM;
DisplayCenterY = (MaxDisplayHeight / 2) - PixPerCM;
x_init = -1;
y_init = -1;
h_init = -1;
w_init = -1;
if (w_init == -1) w_init = (MaxDisplayWidth - (2 * PixPerCM));
if (h_init == -1) h_init = (MaxDisplayHeight - (2 * PixPerCM));
if (x_init == -1) x_init = PixPerCM - 5;
if (y_init == -1) y_init = PixPerCM - 5;
if ((window_arg = XCreateSimpleWindow(display_arg,
(Window)XRootWindow(display_arg, XDefaultScreen(display_arg)),
x_init, y_init, (unsigned int)w_init, (unsigned int)h_init,
BorderWidth, BorderPixel, BackgroundPixel)) == NULL)
{
tet_infoline("ERROR: Window creation failed.");
tet_infoline(" Check x y w h values in change test");
tet_result(TET_FAIL);
return;
}
XMapWindow (display_arg, window_arg);
XSync (display_arg, 0);
regr_args.l_flags.check = 0;
regr_args.l_flags.nostat = 0;
regr_args.l_flags.perf = 0;
regr_args.l_flags.setup = 0;
regr_args.l_flags.cleanup = 0;
regr_args.l_flags.chksta = 0;
regr_args.l_flags.chkdpy = 0;
regr_args.l_flags.verbose = 0;
regr_args.iter = 1; /* execute service once */
estatus[0] = 1;
setlocale(LC_ALL, "C") ;
display_good = display_arg;
window_id_good = window_arg;
XSelectInput(display_arg, window_arg, PropertyChangeMask);
estatus[0] = 1;
estatus[1] = BadWindow;
if ((regr_args.l_flags.good == 0) || (estatus[1] == Success))
{
regr_args.l_flags.setup = 0;
regr_args.l_flags.cleanup = 0;
regr_args.l_flags.check = 0;
regr_args.l_flags.chksta = 1;
regr_args.l_flags.chkdpy = 0;
{
/*
* Create and destroy a window to make sure
* we have a bad window id or a bad drawable id
*/
Window bad_window;
tet_infoline("PREP: Create a window.");
bad_window = XCreateSimpleWindow(display_arg,
XRootWindow(display_arg, XDefaultScreen(display_arg)),
0, 0, (unsigned int)10, (unsigned int)10, (unsigned int)0,
XWhitePixel(display_arg, XDefaultScreen(display_arg)),
XWhitePixel(display_arg, XDefaultScreen(display_arg)));
tet_infoline("PREP: Destroy the window.");
XDestroyWindow(display_arg, bad_window);
XSync(display_arg, 0);
tet_infoline("TEST: Catt to XmbSetWMProperties with a non-existant window id returns BadWindow error");
svcmbSetWMProperties( display_good,
bad_window, window_name_good,
icon_name_good, argv_good,
num_args_good, hints_good,
wm_hints, class_hints);
}
} /* end if */
tet_result(TET_PASS);
#else
tet_infoline("INFO: Implementation not X11R5 or greater");
tet_result(TET_UNSUPPORTED);
#endif
>>ASSERTION Good C
If the implementation is X11R5 or later:
A call to xname shall set a window's standard window manager properties.
.P
If the window_name argument is non-null, it shall set WM_NAME property.
.P
If the icon_name argument is non-null, it shall set WM_ICON_NAME property.
.P
If the argv argument is non-null, it shall set WM_COMMAND property.
.P
If the argc argument is zero, it shall set WM_CLIENT_MACHINE property.
.P
If the normal_hints argument in non-null, it shall set WM_NORMAL_HINTS property.
.P
If the wm_hints argument is non-null, it shall set WM_HINTS property.
.P
If the class_hints argument is non-null, it shall set WM_CLASS property.
>>CODE
#if XT_X_RELEASE > 4
display_arg = Dsp;
/*
* Create a GC to save environmental data in
*/
gc_save = XCreateGC(display_arg,XRootWindow(display_arg,XDefaultScreen(display_arg)),(unsigned long)0,(XGCValues *)0);
BorderPixel = XBlackPixel(display_arg,XDefaultScreen(display_arg));
BackgroundPixel = XWhitePixel(display_arg,XDefaultScreen(display_arg));
colormap_arg = XDefaultColormap(display_arg, XDefaultScreen(display_arg));
PixPerCM = XDisplayWidth(display_arg,
XDefaultScreen(display_arg))*10/XDisplayWidthMM(display_arg,
XDefaultScreen(display_arg));
MaxDisplayWidth = XDisplayWidth(display_arg, XDefaultScreen(display_arg));
MaxDisplayHeight = XDisplayHeight(display_arg, XDefaultScreen(display_arg));
DisplayCenterX = (MaxDisplayWidth / 2) - PixPerCM;
DisplayCenterY = (MaxDisplayHeight / 2) - PixPerCM;
x_init = -1;
y_init = -1;
h_init = -1;
w_init = -1;
tet_infoline("PREP: Create a window.");
if (w_init == -1) w_init = (MaxDisplayWidth - (2 * PixPerCM));
if (h_init == -1) h_init = (MaxDisplayHeight - (2 * PixPerCM));
if (x_init == -1) x_init = PixPerCM - 5;
if (y_init == -1) y_init = PixPerCM - 5;
if ((window_arg = XCreateSimpleWindow(display_arg,
(Window)XRootWindow(display_arg, XDefaultScreen(display_arg)),
x_init, y_init,
(unsigned int)w_init,
(unsigned int)h_init,
BorderWidth,
BorderPixel,
BackgroundPixel)) == NULL)
{
tet_infoline("ERROR: Window creation failed.");
tet_infoline(" Check x y w h values in change test");
tet_result(TET_FAIL);
return;
}
XMapWindow (display_arg, window_arg);
XSync (display_arg, 0);
regr_args.l_flags.check = 0;
regr_args.l_flags.nostat = 0;
regr_args.l_flags.perf = 0;
regr_args.l_flags.setup = 0;
regr_args.l_flags.cleanup = 0;
regr_args.l_flags.chksta = 0;
regr_args.l_flags.chkdpy = 0;
regr_args.l_flags.verbose = 0;
regr_args.iter = 1; /* execute service once */
estatus[0] = 1;
setlocale(LC_ALL, "C") ;
display_good = display_arg;
window_id_good = window_arg;
XSelectInput(display_arg, window_arg, PropertyChangeMask);
estatus[0] = 1;
estatus[1] = Success;
if ((regr_args.l_flags.good == 0) || (estatus[1] == Success))
{
tet_infoline("TEST: XmbSetWMProperties sets all the specified window properties");
regr_args.l_flags.setup = 0;
regr_args.l_flags.cleanup = 1;
regr_args.l_flags.chkdpy = 0;
regr_args.l_flags.chksta = 1;
regr_args.l_flags.check = 1;
{
svcmbSetWMProperties(display_good, window_id_good,
window_name_good, icon_name_good,
argv_good, num_args_good, hints_good,
wm_hints, class_hints);
}
} /* end if */
tet_result(TET_PASS);
#else
tet_infoline("INFO: Implementation not X11R5 or greater");
tet_result(TET_UNSUPPORTED);
#endif
|