summaryrefslogtreecommitdiff
path: root/xc/test/xsuite/xtest/tset/CH07/kllclnt/kllclnt.m
blob: 677786afa15a1cd8a0f730aca1320dc65a6cc43d (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
/*
 
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.

 *
 * Copyright 1990, 1991 by UniSoft Group Limited.
 * 
 * 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.
 *
 * $XConsortium: kllclnt.m,v 1.6 94/04/17 21:06:38 rws Exp $
 */
>>TITLE XKillClient CH07
void

Display	*display = Dsp;
XID 	resource;
>>ASSERTION Good A
A call to xname forces a close-down of the client
that created the specified
.A resource .
>>STRATEGY
Create a client client1.
Create several resources using client1.
Call xname with one of these resources.
Verify that all client1's resources are destroyed and infer that client1 was
destroyed.
>>CODE
Display	*client1;
Window	win;
Pixmap	pix;
Colormap	cm;
unsigned int 	width, height;

/* We must disable resource registration here to prevent attempted
   deallocation of closed connections and deleted resources. */
	regdisable(); 
	client1 = opendisplay();
	if (client1 == 0) {
		delete("Could not open display");
		regenable();
		return;
	}

	win = defwin(client1);
	pix = XCreatePixmap(client1, DRW(display), 2, 3,
		DefaultDepth(client1, DefaultScreen(client1)));
	cm = makecolmap(client1, DefaultVisual(client1, DefaultScreen(client1)), AllocNone);

	regenable();

	XSync(client1, False);
	if (isdeleted())
		return;

	resource = (XID) cm;
	XCALL;

	CATCH_ERROR(Dsp);
	getsize(Dsp, win, &width, &height);
	if (GET_ERROR(Dsp) == BadDrawable)
		CHECK;
	else {
		report("Window was not destroyed");
		FAIL;
	}

	reseterr();
	getsize(Dsp, pix, &width, &height);
	if (GET_ERROR(Dsp) == BadDrawable)
		CHECK;
	else {
		report("Pixmap was not destroyed");
		FAIL;
	}
	RESTORE_ERROR(Dsp);

	CHECKPASS(2);
>>ASSERTION Good A
When the client that created the resource has already terminated in
either
.S RetainPermanent
or
.S RetainTemporary
mode, then all the resources of that client
are destroyed.
>>STRATEGY
Create a connection, client1.
Create resources for client1.
Set close-down mode to RetainPermanent.
Close client1 connection with XCloseDisplay.
Check client1 resources still exist.
Call xname with one of the client1 resources.
Verify that all client1 resources are destroyed.
>>EXTERN

#define	N_RES	4	

>>CODE
Display	*client1;
Window	w[N_RES];
XWindowAttributes	atts;
int 	i;

/* We must disable resource registration here to prevent attempted
   deallocation of closed connections and deleted resources. */
	regdisable(); 

	client1 = opendisplay();
	if (client1 == 0) {
		delete("Could not open display");
		regenable();
		return;
	}

	w[0] = defwin(client1);
	w[1] = defwin(client1);
	w[2] = defwin(client1);
	w[3] = defwin(client1);
	regenable();

	XSetCloseDownMode(client1, RetainPermanent);
	XCloseDisplay(client1);

	CATCH_ERROR(Dsp);
	for (i = 0; i < N_RES; i++) {
		if (XGetWindowAttributes(Dsp, w[i], &atts) == False) {
			delete("RetainPermanent windows were destroyed");
			return;
		}
	}
	RESTORE_ERROR(Dsp);

	resource = w[2];
	XCALL;

	CATCH_ERROR(Dsp);
	for (i = 0; i < N_RES; i++) {
		if (XGetWindowAttributes(Dsp, w[i], &atts) == True) {
			report("RetainPermanent window was not destroyed");
			FAIL;
		} else
			CHECK;
	}
	RESTORE_ERROR(Dsp);

	CHECKPASS(N_RES);

>>ASSERTION Good A
When a
.A resource
of
.S AllTemporary
is specified, then the resources of all clients that have terminated in
.S RetainTemporary
mode are destroyed.
>>STRATEGY
Open connection client1.
Open connextion client2.
Make resources for both clients.
Set close-down mode of RetainTemporary for both.
Close both clients with XCloseDisplay.
Call xname with ID AllTemporary.
Verify that all clients 1 and 2 resources are destroyed.
>>CODE
XWindowAttributes	atts;
Display	*client1;
Display	*client2;
Window	w1;
Window	w2;

/* We must disable resource registration here to prevent attempted
   deallocation of closed connections and deleted resources. */
	regdisable(); 

	if ((client1 = opendisplay()) == NULL) {
		delete("Could not open display");
		regenable();
		return;
	}
	if ((client2 = opendisplay()) == NULL) {
		delete("Could not open display");
		regenable();
		return;
	}

	w1 = defwin(client1);
	w2 = defwin(client2);

	regenable();

	XSetCloseDownMode(client1, RetainTemporary);
	XSetCloseDownMode(client2, RetainTemporary);

	XCloseDisplay(client1);
	XCloseDisplay(client2);

	resource = AllTemporary;
	XCALL;

	CATCH_ERROR(Dsp);
	if (XGetWindowAttributes(Dsp, w1, &atts) == True) {
		report("RetainTemporary window was not destroyed");
		FAIL;
	} else
		CHECK;
	if (XGetWindowAttributes(Dsp, w2, &atts) == True) {
		report("RetainTemporary window was not destroyed");
		FAIL;
	} else
		CHECK;
	RESTORE_ERROR(Dsp);

	CHECKPASS(2);
>>ASSERTION Bad A
When the specified
.A resource
is not valid, then a
.S BadValue
error occurs.
>>STRATEGY
Get bad id using badwin().
Call xname with this value.
Verify that a BadValue error occurs.
>>CODE BadValue

	resource = badwin(Dsp);
	XCALL;

	if (geterr() == BadValue)
		PASS;