summaryrefslogtreecommitdiff
path: root/xts5/Xlib4/XCreateWindow/XCreateWindow.m
blob: dd9d0ebd433233230971f4a96d8b581640b6ef8a (plain)
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
Copyright (c) 2005 X.Org Foundation L.L.C.

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. 1995
All Rights Reserved.

>># Project: VSW5
>># 
>># File: xts5/Xlib4/XCreateWindow/XCreateWindow.m
>># 
>># Description:
>># 	Tests for XCreateWindow()
>># 
>># Modifications:
>># $Log: crtwdw.m,v $
>># Revision 1.2  2005-11-03 08:43:33  jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2  2005/04/15 14:05:25  anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0  1998/12/23 23:26:23  mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0  1998/10/30 22:44:39  mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0  1998/03/02 05:18:39  tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0  1998/01/26 03:15:10  tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.1  1996/05/09 20:59:49  andy
>># Fixed cursorfont include
>>#
>># Revision 4.0  1995/12/15  08:47:23  tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1  1995/12/15  00:45:52  andy
>># Prepare for GA Release
>>#
/*
Portions of this software are based on Xlib and X Protocol Test Suite.
We have used this material under the terms of its copyright, which grants
free use, subject to the conditions below.  Note however that those
portions of this software that are based on the original Test Suite have
been significantly revised and that all such revisions are copyright (c)
1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
revisions cannot be separated from the freely copyable material, the net
result is that use of this software is governed by the ApTest copyright.

Copyright (c) 1990, 1991  X Consortium

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
X CONSORTIUM 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.

Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of UniSoft not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  UniSoft
makes no representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied warranty.
*/
>>TITLE XCreateWindow Xlib4
Window

Display	*display = Dsp;
Window	parent = DRW(Dsp);
int 	x = 50;
int 	y = 60;
unsigned int 	width = 20;
unsigned int 	height = 17;
unsigned int 	border_width = 2;
int 	depth = DefaultDepth(Dsp, DefaultScreen(Dsp));
unsigned int 	class = InputOutput;
Visual	*visual = DefaultVisual(Dsp, DefaultScreen(Dsp));
unsigned long	valuemask = 0;
XSetWindowAttributes	*attributes = &Atts;
>>SET fail-return
>>SET startup fontstartup
>>SET cleanup fontcleanup
>>EXTERN

static XSetWindowAttributes	Atts;

static Window
interceptXCW(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes)
Display	*display;
Window	parent;
int 	x;
int 	y;
unsigned int 	width;
unsigned int 	height;
unsigned int 	border_width;
int 	depth;
unsigned int 	class;
Visual	*visual;
unsigned long	valuemask;
XSetWindowAttributes	*attributes;
{
Colormap	cm;
Visual	*vis;
XWindowAttributes	atts;

	/*
	 * Problem:  The colormap has to match the visual, however the default
	 * is CopyFromParent which is of no use when the parent has a different
	 * type to the window that is being created.
	 * If parent, visual, depths are not default and the test is not already
	 * setting the colormap and class is InputOutput then set an appropriate
	 * one here.
	 */
	if ((valuemask & CWColormap) == 0 &&
			(
			visual != DefaultVisual(Dsp, DefaultScreen(Dsp)) ||
			parent != DefaultRootWindow(Dsp) ||
			depth != DefaultDepth(Dsp, DefaultScreen(Dsp))
			)
		) {

		if (visual == CopyFromParent || class == CopyFromParent)
			XGetWindowAttributes(display, parent, &atts);

		if (visual == CopyFromParent) {
			vis = atts.visual;
		} else
			vis = visual;

		if (class == InputOutput || (class == CopyFromParent && atts.class == InputOutput)) {
			cm = makecolmap(display, vis, AllocNone);
			attributes->colormap = cm;
			valuemask |= CWColormap;
		}
	}

        /*
         * Set the border pixel value if not set to ensure that a depth
         * mismatch does not occur (since the default BorderPixel is
         * CopyFromParent) causing a BadMatch.
	 * We only need to do this for InputOutput windows, of course,
	 * otherwise we get a BadMatch for an attempted draw on an
	 * InputOnly window.
 	 * Also we must never ever do this if we are using a border pixmap.
         */
	if ( (valuemask & CWBorderPixmap) == 0 && 
		(valuemask & CWBorderPixel) == 0 &&
		( visual != DefaultVisual(Dsp, DefaultScreen(Dsp)) ||
	 	 parent != DefaultRootWindow(Dsp) ||
		 depth != DefaultDepth(Dsp, DefaultScreen(Dsp))
		))
	{

		if (class == CopyFromParent)
			XGetWindowAttributes(display, parent, &atts);

		if (class == InputOutput ||
			(class == CopyFromParent &&
			atts.class == InputOutput))
		{

			attributes->border_pixel = W_FG;
			valuemask |= CWBorderPixel;
		}
        }

	return XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes);
}
#define XCreateWindow interceptXCW

>>ASSERTION Good A
A call to xname creates an unmapped subwindow for a specified parent window
and returns the window ID of the created window.
>>STRATEGY
Call xname.
Do simple checks on returned id.
>>CODE
Window	win;

	win = XCALL;
	if (win & 0xe0000000) {
		report("Window ID has some of top three bits set");
		FAIL;
	} else {
		XDestroyWindow(display, win);
		PASS;
	}


>>ASSERTION Good A
The window attributes specified in
.A valuemask
are set to the values in the
.A attributes
structure.
>>STRATEGY
Create window with all attributes set to non-default values.
Get the window attributes with XGetWindowAttributes.
Verify that they are the same as the ones set.
The attributes that can't be checked in this way are the subject of other
  assertions.
>>EXTERN
#include	"X11/cursorfont.h"
>>CODE
XSetWindowAttributes	atts;
XWindowAttributes	getatts;
Window	win;
Colormap	cm;
Cursor		curs;
int 	n;

	cm = XCreateColormap(display, DRW(display), DefaultVisual(display, DefaultScreen(display)), AllocNone);
	curs = XCreateFontCursor(display, XC_coffee_mug);

	atts.bit_gravity = SouthEastGravity;
	atts.win_gravity = EastGravity;
	atts.backing_store = WhenMapped;
	atts.backing_planes = 0xaaaaaaaa;
	atts.backing_pixel = 1;
	atts.save_under = True;
	atts.event_mask = PropertyChangeMask;
	atts.do_not_propagate_mask = KeyPressMask;
	atts.override_redirect = True;
	atts.colormap = cm;
	atts.cursor = curs;

	attributes = &atts;
	valuemask = CWBitGravity|CWWinGravity|CWBackingStore|CWBackingPlanes|
		CWBackingPixel|CWSaveUnder|CWEventMask|CWDontPropagate|
		CWOverrideRedirect|CWColormap|CWCursor;

	win = XCALL;

	XGetWindowAttributes(display, win, &getatts);
	if (isdeleted())
		return;

	n = checkatts(attributes, &getatts, valuemask);
	if (n > 0) {
		report("There %s %d incorrect attribute%s", 
					(n>1)?"were":"was", n, (n>1)?"s":"");
		FAIL;
	} else if (n < 0) {
		/* already reported a path check error in checkatts */
		return;
	} else
		CHECK;

	XDestroyWindow(display, win);
	CHECKPASS(1);

>>EXTERN

static int
checkatts(setatts, getatts, vmask)
XSetWindowAttributes	*setatts;
XWindowAttributes	*getatts;
unsigned long 	vmask;
{
int 	pass = 0, fail = 0;

	/*
	 * Maybe we should alway check everything??? (No vmask)
	 */
	if ((vmask&CWBitGravity) && setatts->bit_gravity != getatts->bit_gravity) {
		report("bit_gravity got %s, expected %s",
			bitgravityname(getatts->bit_gravity),
			bitgravityname(setatts->bit_gravity));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWWinGravity) && setatts->win_gravity != getatts->win_gravity) {
		report("window_gravity got %s, expected %s",
			wingravityname(getatts->win_gravity),
			wingravityname(setatts->win_gravity));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWBackingStore) && setatts->backing_store != getatts->backing_store) {
		report("backing_store got %s, expected %s",
			backingstorename(getatts->backing_store),
			backingstorename(setatts->backing_store));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWBackingPlanes) && setatts->backing_planes != getatts->backing_planes) {
		report("backing_planes got 0x%x, expected 0x%x",
			getatts->backing_planes,
			setatts->backing_planes);
		FAIL;
	} else
		CHECK;

	if (setatts->backing_pixel != getatts->backing_pixel) {
		report("backing_pixel got 0x%x, expected 0x%x",
			getatts->backing_pixel,
			setatts->backing_pixel);
		FAIL;
	} else
		CHECK;

	if ((vmask&CWSaveUnder) && setatts->save_under != getatts->save_under) {
		report("save_under got %s, expected %s",
			boolname(getatts->save_under),
			boolname(setatts->save_under));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWEventMask) && setatts->event_mask != getatts->your_event_mask) {
		report("event_mask got %s, expected %s",
			eventmaskname(getatts->your_event_mask),
			eventmaskname(setatts->event_mask));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWDontPropagate) && setatts->do_not_propagate_mask != getatts->do_not_propagate_mask) {
		report("do_not_propagate_mask got %s, expected %s",
			eventmaskname(getatts->do_not_propagate_mask),
			eventmaskname(setatts->do_not_propagate_mask));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWOverrideRedirect) && setatts->override_redirect != getatts->override_redirect) {
		report("override_redirect got %s, expected %s",
			boolname(getatts->override_redirect),
			boolname(setatts->override_redirect));
		FAIL;
	} else
		CHECK;

	if ((vmask&CWColormap) && setatts->colormap != getatts->colormap) {
		report("colormap got 0x%x, expected 0x%x",
			getatts->colormap,
			setatts->colormap);
		FAIL;
	} else
		CHECK;

	if (fail == 0 && pass == 10)
		return(0);
	else {
		if (fail)
			return(fail);
		else
			delete("Path check error in checkatts");
	}
	return(-1);
}

>>ASSERTION Good A
Window attributes that are not specified in
.A valuemask
are set to their default values.
>>STRATEGY
Create window.
Check default values:
bit-gravity: Forget
win-gravity: NorthWest
backing-store: NotUseful
backing-planes: all ones
backing-pixel: zero
save-under: False
event-mask: empty set
do-not-propagate-mask: empty set
override-redirect: False
colormap: CopyFromParent
>>CODE
XSetWindowAttributes	atts;
XWindowAttributes	getatts;
Window	win;
int 	n;

	valuemask = 0;
	win = XCALL;

	/* For the parent colormap */
	XGetWindowAttributes(display, DRW(display), &getatts);

	atts.bit_gravity = ForgetGravity;
	atts.win_gravity = NorthWestGravity;
	atts.backing_store = NotUseful;
	atts.backing_planes = 0xffffffff;
	atts.backing_pixel = 0;
	atts.save_under = False;
	atts.event_mask = 0;
	atts.do_not_propagate_mask = 0;
	atts.override_redirect = False;
	atts.colormap = getatts.colormap;

	if (XGetWindowAttributes(display, win, &getatts) == False) {
		delete("Could not get window attributes");
		return;
	} else
		CHECK;

	n = checkatts(&atts, &getatts, (long)~0);
	if (n > 0) {
		report("There %s %d incorrect attribute%s", 
					(n>1)?"were":"was", n, (n>1)?"s":"");
		FAIL;
	} else if (n < 0) {
		/* already reported a path check error in checkatts */
		return;
	} else
		CHECK;

	CHECKPASS(2);

>>ASSERTION Good A
On a call to xname a
.S CreateNotify
event is generated on the parent window.
>>STRATEGY
Create parent window.
Select SubstructureNotifyMask on parent window.
Create window.
Select NoEventMask on parent window.
Verify that a single CreateNotify event was generated.
Verify that the returned event structure was correct.
>>CODE
XSetWindowAttributes	atts;
XCreateWindowEvent	ge;
XEvent	event;
Window	win;
int 	n;

	parent = defdraw(display, VI_WIN);

	XSelectInput(display, parent, SubstructureNotifyMask);

	trace("depth is %d", depth);
	trace("visual class is %s", displayclassname(visual->class));
	win = XCALL;

	XSelectInput(display, parent, NoEventMask);

	if (getevent(Dsp, &event) != 1) {
		report("Expecting one event");
		FAIL;
		return;
	} else
		CHECK;

	/* Set up a good event structure of what we are expecting */
	ge.type = CreateNotify;
	ge.send_event = False;
	ge.display = display;
	ge.parent  = parent;
	ge.window  = win;
	ge.x = x;
	ge.y = y;
	ge.width   = width;
	ge.height  = height;
	ge.border_width = border_width;
	ge.override_redirect = False;

	n = checkevent((XEvent*)&ge, &event);
	if (n == 0) {
		CHECK;
	} else {
		report("Event incorrect");
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
The created window is placed on top in the stacking order
with respect to siblings.
>>STRATEGY
Create a parent window.
Create two overlapping sibling windows.
Verify that second window is at top of stacking order.
Verify that first sibling is next in the stacking order.
>>CODE
Window	w1, w2;
int 	n;

	parent = defdraw(display, VI_WIN);
	if (isdeleted())
		return;
	else
		CHECK;

	trace("depth is %d", depth);
	trace("visual class is %s", displayclassname(visual->class));
	w1 = XCALL;
	w2 = XCALL;

	if ((n = stackorder(display, w1)) != 0) {
		report("Stacking order for w1 was %d, expected 0", n);
		FAIL;
	} else if ((n = stackorder(display, w2)) != 1) {
		report("Stacking order for w2 was %d, expected 1", n);
		FAIL;
	} else
		CHECK;

	XDestroyWindow(display, w1);
	XDestroyWindow(display, w2);
	CHECKPASS(2);

>>ASSERTION Good A
The created window is not displayed.
>>STRATEGY
Create window to use as parent.
Set background to other than W_BG.
Create window with xname.
Verify that parent window is still clear.
>>CODE
XVisualInfo	*vp;
Window	win;

	for (resetvinf(VI_WIN); nextvinf(&vp); ) {
		parent = (Window)makedrawable(display, vp);

		attributes->background_pixel = W_FG;
		valuemask = CWBackPixel;
		win = XCALL;

		if (checkclear(display, parent))
			CHECK;
		else {
			report("Created window was visible");
			FAIL;
		}
		XDestroyWindow(display, win);
	}
	CHECKPASS(nvinf());

>>ASSERTION Good A
When
.A class
is
.S CopyFromParent ,
then the class is taken from the parent window.
>>STRATEGY
Create InputOutput window to use as parent.
Create window with class CopyFromParent.
Verify that class of created window is InputOutput.
Create InputOnly window to use as parent.
Create window with class CopyFromParent.
Verify that class of created window is InputOnly.
>>CODE
Status	s;
Window	win;
XWindowAttributes	atts;

	class = CopyFromParent;
	/*
	 * Have to set depth and border_width to zero as well,
	 * otherwise BadMatch errors will occur.
	 */
	depth = 0;
	border_width = 0;
	parent = defdraw(display, VI_WIN);
	win = XCALL;

	s = XGetWindowAttributes(display, win, &atts);
	if (s == False) {
		delete("XGetWindowAttributes failed");
		return;
	} else
		CHECK;

	if (atts.class != InputOutput) {
		report("Class was %s, expecting InputOutput", classname(atts.class));
		FAIL;
	} else
		CHECK;

	XDestroyWindow(display, win);

	/* Now Input Only */
	parent = iponlywin(display);
	win = XCALL;

	s = XGetWindowAttributes(display, win, &atts);
	if (s == False) {
		delete("XGetWindowAttributes failed");
		return;
	} else
		CHECK;

	if (atts.class != InputOnly) {
		report("Class was %s, expecting InputOnly", classname(atts.class));
		FAIL;
	} else
		CHECK;

	XDestroyWindow(display, win);
	CHECKPASS(4);

>>ASSERTION Good A
When
.A depth
is
.S CopyFromParent
and
.A class
is
.S InputOutput ,
then the depth is taken from the parent window.
>>STRATEGY
Create InputOutput window to use as parent.
Create window with depth CopyFromParent.
Verify that depth of created window is same as the parent.
>>CODE
Status	s;
Window	win;
XWindowAttributes	atts;
int 	parentdepth;

	depth = CopyFromParent;
	parent = defdraw(display, VI_WIN);
	win = XCALL;

	parentdepth = getdepth(display, parent);

	s = XGetWindowAttributes(display, win, &atts);
	if (s == False) {
		delete("XGetWindowAttributes failed");
		return;
	} else
		CHECK;

	if (atts.depth != parentdepth) {
		report("Depth was %d, expecting %d", atts.depth, parentdepth);
		FAIL;
	} else
		CHECK;

	XDestroyWindow(display, win);
	CHECKPASS(2);

>>ASSERTION Good A
When
.A visual
is
.S CopyFromParent ,
then the visual is taken from the parent window.
>>STRATEGY
Create window to use as parent.
Create window with visual CopyFromParent.
Verify that visual of created window is same as the parent.
>>CODE
Status	s;
Window	win;
XWindowAttributes	atts;
XVisualInfo	*vp;

	depth = CopyFromParent;
	visual = CopyFromParent;
	for (resetvinf(VI_WIN); nextvinf(&vp); ) {
		parent = makewin(display, vp);

		win = XCALL;

		s = XGetWindowAttributes(display, win, &atts);
		if (s == False) {
			delete("XGetWindowAttributes failed");
			return;
		} else
			CHECK;

		if (atts.visual != vp->visual) {
			report("Visual was not same as parent");
			FAIL;
		} else
			CHECK;

		XDestroyWindow(display, win);
	}

	CHECKPASS(2*nvinf());

>>ASSERTION Good A
The window is located such that
the upper left outer corner is at the
co-ordinate specified by
.A x
and
.A y
relative to the inside of the border of the parent window.
>>STRATEGY
Create window with border and background pixel W_FG.
Map created window.
Verify position by direct check with checkarea.
>>CODE
Window	win;
struct	area	area;

	border_width = 5;
	parent = defdraw(display, VI_WIN);
	attributes->border_pixel = W_FG;
	attributes->background_pixel = W_FG;
	valuemask = CWBackPixel|CWBorderPixel;

	win = XCALL;

	XMapWindow(display, win);
	if (isdeleted())
		return;

	setarea(&area, x, y, width+2*border_width, height+2*border_width);

	if (checkarea(display, parent, &area, W_FG, W_BG, CHECK_ALL))
		CHECK;
	else {
		report("Window created in wrong position or with wrong size");
		FAIL;
	}

	XDestroyWindow(display, win);
	CHECKPASS(1);
	
>>INCLUDE commattr.mc
>>ASSERTION Bad A
When
.A class
is
.S InputOutput
and the specified visual type and depth are not supported for the screen,
then a
.S BadMatch
error occurs.
>>STRATEGY
Find depth not supported by screen.
Set depth to the unsupported depth.
Set visual to a supported type
(doesn't seem possible to test unsupported visual portably)
Set class to InputOutput.
Attempt to create window.
Verify that BadMatch error occurs.
>>CODE BadMatch
XVisualInfo	*vp;
int 	supported;

	for (depth = 1; ; depth++) {
		supported = 0;
		for (resetvinf(VI_WIN); nextvinf(&vp); ) {
			if (vp->depth == depth)
				supported = 1;
		}
		if (!supported)
			break;
	}

	class = InputOutput;

	(void) XCALL;

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;	/* Already reported */

>>ASSERTION Bad A
When
.A class
is
.S InputOutput
and the parent window has class
.S InputOnly ,
then a
.S BadMatch
error occurs.
>>STRATEGY
Create input only window with iponlywin().
Set class to InputOutput.
Create window with the input only window as parent.
Verify that a BadMatch error occurs.
>>CODE BadMatch

	parent = iponlywin(display);
	class = InputOutput;

	(void) XCALL;

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;

>>ASSERTION Bad A
When
.A class
is
.S InputOnly
and the depth is not zero,
then a
.S BadMatch
error occurs.
>>STRATEGY
Set class to InputOnly.
Set depth to 1.
Set border_width to 0 to avoid BadMatch error due to border width.
Call xname.
Verify that BadMatch error occurs.
>>CODE BadMatch

	class = InputOnly;
	depth = 1;
	border_width = 0;

	(void) XCALL;

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;
	
>>ASSERTION Bad B 1
When
.A class
is
.S InputOnly
and the specified visual type is not supported by the screen, then a
.S BadMatch
error occurs.
>>ASSERTION Bad A
When the
.A width
or
.A height
is zero, then a
.S BadValue
error occurs.
>>STRATEGY
Set width and height in turn to be zero.
Call xname.
Verify that a BadValue error occurs.
>>CODE BadValue

	width = 0;
	height = 10;

	(void) XCALL;

	if (geterr() == BadValue)
		CHECK;
	else
		FAIL;

	width = 10;
	height = 0;

	(void) XCALL;

	if (geterr() == BadValue)
		CHECK;
	else
		FAIL;

	CHECKPASS(2);
>>ASSERTION Bad B 1
When the specified visual type is invalid, then a
.S BadValue
error occurs.
>>ASSERTION Bad A
.ER BadValue class InputOutput InputOnly CopyFromParent
>>ASSERTION Bad B 3
.ER BadAlloc