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
|
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/Xlib7/XStoreNamedColor.m
>>#
>># Description:
>># Tests for XStoreNamedColor()
>>#
>># Modifications:
>># $Log: strnmdclr.m,v $
>># Revision 1.2 2005-11-03 08:43:44 jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2 2005/04/15 14:05:31 anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0 1998/12/23 23:27:01 mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0 1998/10/30 22:45:20 mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.1 1998/07/25 00:18:15 mar
>># req.4.W.00121: avoid undefined ANSI usage
>>#
>># Revision 6.0 1998/03/02 05:19:14 tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0 1998/01/26 03:15:45 tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0 1995/12/15 08:49:31 tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1 1995/12/15 00:48:58 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 XStoreNamedColor Xlib7
void
XStoreNamedColor(display, colormap, color, pixel, flags)
Display *display = Dsp;
Colormap colormap = DefaultColormap(display, DefaultScreen(display));
char *color = "";
unsigned long pixel;
int flags = DoRed|DoGreen|DoBlue;
>>ASSERTION Good C
>>#
>># TODO dave - Jan 17
>># The X11R4 spec is vague about whether it's the closest available or
>># or the actual values that are stored.
>># O'Reilly Vol one page 190 has a footnote saying the actual values
>># you tried to store may not be stored.
>>#
If any of the visual classes DirectColor, PseudoColor or GrayScale is supported:
A call to xname obtains the closest available RGB values for the
.A colormap
argument to those specified for the colour named
.A color
in the database, and stores those values in the read-write colourmap entry
specified by the
.M pixel
component of the
.S XColor
structure.
>>STRATEGY
For each visual class DirectColor, PseudoColor and GrayScale:
Create a colormap with alloc set to AllocAll.
Store the r,g and b colour values of XT_GOOD_COLOUR_NAME in the colourmap with XStoreNamedColor.
Obtain the rbg values of the stored color with XQueryColor.
Store those rgb values in the colormap with XStoreColor.
Obtain the stored rgb values with XQueryColor.
Verify the rgb values stored in the two cells are identical.
>>CODE
XVisualInfo *vp;
char *goodname;
XColor namedcol, testcol, storedcol;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
if( (vmask = visualsupported(display, vmask)) == 0L) {
UNSUPPORTED;
return;
}
if((goodname = tet_getvar("XT_GOOD_COLORNAME")) == (char *) 0) {
delete("XT_GOOD_COLORNAME is not defined.");
return;
}
flags = DoRed|DoGreen|DoBlue;
for(resetsupvis(vmask); nextsupvis(&vp); ) {
trace("Attempting XStoreNamedColor() for class %s, color %s", displayclassname(vp->class), goodname);
colormap = makecolmap(display, vp -> visual, AllocAll);
color = goodname;
pixel = 0L;
XCALL;
namedcol.pixel = 0L;
XQueryColor(display, colormap, &namedcol);
testcol = namedcol;
testcol.pixel = 1L;
testcol.flags = flags;
XStoreColor(display, colormap, &testcol);
storedcol.pixel = 1L;
storedcol.flags = flags;
XQueryColor(display, colormap, &storedcol);
trace("Named Color : pixel %lu, r %u g %u b %u", namedcol.pixel , namedcol.red, namedcol.green, namedcol.blue);
trace("Stored Color: pixel %lu, r %u g %u b %u", storedcol.pixel, storedcol.red, storedcol.green, storedcol.blue);
if( (namedcol.red != storedcol.red) || (namedcol.green != storedcol.green) || (namedcol.blue != storedcol.blue) ) {
report("XStoreNamedColor() return RGB values r %u g %u b %u instead of r %u g %u b %u.",
namedcol.red, namedcol.green, namedcol.blue, storedcol.red, storedcol.green, storedcol.blue);
FAIL;
} else
CHECK;
}
CHECKPASS(nsupvis());
>>ASSERTION Good A
If any of the visual classes DirectColor, PseudoColor or GrayScale is supported:
A call to xname changes the red, green and blue values
in the read-write colourmap entry in accordance with the
.A flags
argument.
>>STRATEGY
For each supported visual class DirectColor, PseudoColor and GrayScale:
Create a colormap with XCreateColormap.
Store XT_GOOD_COLOR_NAME r, g and b values in cell 0 with XStoreNamedColor.
Obtain the r,g and b values with XQueryColor.
Complement the rgb values and store the value in cell 0 with XStoreColor.
Obtain the bitwise complemented rgb values using XQueryColor.
For each possible combination DoRed, DoGreen and DoBlue in flags:
Store the bitwise complementary rgb values in the same cell with XStoreColor.
Store the XT_GOOD_COLOR_NAME values in the colourmap cell using XStoreNamedColor.
Verify that only the components of the colourcell specified by the flags value have been altered with XQueryColor.
>>CODE
XVisualInfo *vp;
int i;
char *goodname;
XColor namedcol, testcol, storedcol;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
unsigned short redval, greenval, blueval;
if( (vmask = visualsupported(display, vmask)) == 0L) {
UNSUPPORTED;
return;
}
if((goodname = tet_getvar("XT_GOOD_COLORNAME")) == (char *) 0) {
delete("XT_GOOD_COLORNAME is not defined.");
return;
}
color = goodname;
pixel = 0L;
storedcol.pixel = 0L;
testcol.pixel = 0L;
namedcol.pixel = 0L;
for(resetsupvis(vmask); nextsupvis(&vp); ) {
trace("Attempting XStoreNamedColor() for class %s, color %s", displayclassname(vp->class), goodname);
colormap = makecolmap(display, vp -> visual, AllocAll);
flags = DoRed|DoGreen|DoBlue;
XCALL;
XQueryColor(display, colormap, &namedcol);
testcol = namedcol;
testcol.red ^= 0xffff;
testcol.green ^= 0xffff;
testcol.blue ^= 0xffff;
testcol.flags = DoRed | DoGreen | DoBlue;
XStoreColor(display, colormap, &testcol);
XQueryColor(display, colormap, &testcol);
for(i=0; i<8; i++) {
flags = 0;
if(i&DoRed) {
flags |= DoRed;
redval = namedcol.red;
} else
redval = testcol.red;
if(i&DoGreen) {
flags |= DoGreen;
greenval = namedcol.green;
} else
greenval = testcol.green;
if(i&DoBlue) {
flags |= DoBlue;
blueval = namedcol.blue;
} else
blueval = testcol.blue;
XStoreColor(display, colormap, &testcol);
XCALL;
XQueryColor(display, colormap, &storedcol);
if( (redval != storedcol.red) || (greenval != storedcol.green) || (blueval != storedcol.blue) ){
report("XStoreNamedColor() RGB value r %u g %u b %u instead of r %u g %u b %u.",
storedcol.red, storedcol.green, storedcol.blue, redval, greenval, blueval);
FAIL;
}
}
if(i == 8)
CHECK;
}
CHECKPASS(nsupvis());
>>ASSERTION Good A
If any of the visual classes DirectColor, PseudoColor or GrayScale is supported:
Upper and lower case characters in the
.A color
argument refer to the same color.
>>STRATEGY
For each supported visual class:
Create a colomap with alloc set to AllocAll.
Store colour XT_GOOD_COLOR_NAME in the colourmap with XStoreNamedColor.
Obtain the stored rgb values with XQueryColor,
Store colour XT_GOOD_COLOR_NAME with alternating characters in alternating case with XStoreNamedColor.
Verify that the rgb values written by both calls was identical.
>>CODE
XVisualInfo *vp;
char *cp, *goodname, *casename;
XColor casecol, testcol;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
int i;
if( (vmask = visualsupported(display, vmask)) == 0L) {
UNSUPPORTED;
return;
}
if( (goodname = tet_getvar("XT_GOOD_COLORNAME")) == (char *) 0) {
delete("XT_GOOD_COLORNAME is not defined.");
return;
}
casename = (char *) malloc( strlen(goodname) + 1);
strcpy(casename, goodname);
for(i=0, cp=casename; *cp; i++, cp++)
if(i&1)
*cp = tolower(*cp);
else
*cp = toupper(*cp);
testcol.pixel = 0L;
casecol.pixel = 0L;
pixel = 0L;
flags = DoRed|DoGreen|DoBlue;
for(resetsupvis(vmask); nextsupvis(&vp); ) {
colormap = makecolmap(display, vp -> visual, AllocAll);
color = goodname;
XCALL;
XQueryColor(display, colormap, &testcol);
color = casename;
trace("Testing colourname %s", color);
XCALL;
XQueryColor(display, colormap, &casecol);
if((casecol.pixel != testcol.pixel) || (casecol.red != testcol.red) || (casecol.green != testcol.green) || (casecol.blue != testcol.blue)) {
report("Colour name %s pixel %lu ( r %u g %u b %u) instead of pixel %lu ( r %u g %u b %u)",
goodname, casecol.pixel, casecol.red, casecol.green, casecol.blue,
testcol.pixel, testcol.red, testcol.green, testcol.blue);
FAIL;
} else
CHECK;
}
CHECKPASS(nsupvis());
>>ASSERTION Bad A
If any of the visual classes DirectColor, PseudoColor or GrayScale is supported:
When the
.A pixel
argument is not a valid entry in the
.A colormap
argument,
then a
.S BadValue
error occurs.
>>STRATEGY
For each visual class DirectColor, PseudoColor and GrayScale:
Create a colourmap with alloc set to AllocAll.
Store the colour XT_GOOD_COLOR_NAME at pixel = colourmap_size with XStoreNamedColor.
Verify that a BadValue error is generated.
>>CODE BadValue
XVisualInfo *vp;
char *goodname;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
if( (vmask = visualsupported(display, vmask)) == 0L) {
UNSUPPORTED;
return;
}
if((goodname = tet_getvar("XT_GOOD_COLORNAME")) == (char *) 0) {
delete("XT_GOOD_COLORNAME is not defined.");
return;
}
flags = DoRed|DoGreen|DoBlue;
for(resetsupvis(vmask); nextsupvis(&vp); ) {
trace("Attempting XStoreNamedColor() for class %s, color %s", displayclassname(vp->class), goodname);
colormap = makecolmap(display, vp -> visual, AllocAll);
color = goodname;
pixel = maxsize(vp) + 1;
if (vp->class == DirectColor) {
pixel = (vp->red_mask | vp->green_mask | vp->blue_mask);
pixel |= pixel << 1;
}
trace("Pixel set to %ld", pixel);
XCALL;
if(geterr() == BadValue)
CHECK;
}
CHECKPASS(nsupvis());
>>ASSERTION Bad A
.ER BadAccess colormap-store
>>STRATEGY
For each visual class DirectColor, PseudoColor and GrayScale:
Create a colormap (r/o) with alloc set to AllocNone.
Store the color XT_GOOD_COLORNAME with XStoreNamedColor
Verify that a BadAccess error is generated.
Create a new client with XOpenDisplay.
Allocate a full red readonly cell for the new client with XAllocColor.
Store the color XT_GOOD_COLORNAME with XStoreNamedColor.
Verify that a BadAccess error occurred.
Allocate another readonly cell with XAllocColor.
Store the color XT_GOOD_COLORNAME with XStoreNamedColor.
Verify that a BadAccess error occurred.
>>CODE BadAccess
XVisualInfo *vp;
XColor testcol;
char *goodname;
Display *disp2;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
if( (vmask = visualsupported(display, vmask)) == 0L) {
UNSUPPORTED;
return;
}
if((goodname = tet_getvar("XT_GOOD_COLORNAME")) == (char *) 0) {
delete("XT_GOOD_COLORNAME is not defined.");
return;
}
color = goodname;
for(resetsupvis(vmask); nextsupvis(&vp); ) {
pixel = 0L;
colormap = makecolmap(display, vp->visual, AllocNone);
trace("Testing a colormap with no allocated cells.");
XCALL;
if(geterr() == BadAccess)
CHECK;
disp2 = opendisplay();
testcol.flags = DoRed;
testcol.red = 65535;
if(XAllocColor(disp2, colormap, &testcol) == False) {
delete("XAllocColor() failed to allocate a full red r/o cell for a second client.");
return;
} else
CHECK;
trace("Trying to write into a r/o cell allocated by another client.");
pixel = testcol.pixel;
XCALL;
if(geterr() == BadAccess)
CHECK;
testcol.red ^= 0xffff;
testcol.green ^= 0xffff;
testcol.blue ^= 0xffff;
testcol.flags = flags;
if(XAllocColor(display, colormap, &testcol) == False) {
delete("XAllocColor() failed to allocate a r/o cell with r,g,b = 0x%x,0x%x,0x%x", testcol.red, testcol.green, testcol.blue);
return;
} else
CHECK;
trace("Trying to write into a r/o cell allocated by self.");
pixel = testcol.pixel;
XCALL;
if(geterr() == BadAccess)
CHECK;
}
CHECKPASS(5*nsupvis());
>>ASSERTION Bad A
.ER BadColor
>>ASSERTION Bad A
.ER BadName colour
>>STRATEGY
For the visual classes DirectColor, PseudoColor and GrayScale :
Create a colormap with alloc set to AllocAll.
Allocate a cell with colour XT_BAD_COLORNAME
in the colourmap with XStoreNamedColor.
Verify that a BadName error occurred.
>>CODE BadName
XVisualInfo *vp;
char *badname;
unsigned long vmask = (1<<DirectColor)|(1<<PseudoColor)|(1<<GrayScale);
if( (vmask = visualsupported(display, vmask)) == 0L) {
unsupported("DirectColor, PseudoColor visual classes are not supported.");
return;
}
if( (badname = tet_getvar("XT_BAD_COLORNAME")) == (char *) 0) {
delete("XT_BAD_COLORNAME is not defined.");
return;
}
for(resetsupvis(vmask); nextsupvis(&vp); ) {
colormap = makecolmap(display, vp -> visual, AllocAll);
color = badname;
XCALL;
if(geterr() == BadName)
CHECK;
}
CHECKPASS(nsupvis());
>>ASSERTION Good D 3
When
.A rmask_return ,
.A gmask_return
and
.A bmask_return
have been returned by
a previous call to
.S XAllocColorPlanes
and a read-write colourmap entry
for a pixel value is changed by a call to xname, then the pixel value
is decomposed into three components using the masks and the
independent colourmap entries are updated.
>>ASSERTION Good D 3
If the visual class
.S DirectColor
is supported:
When the
.A colormap
argument was created with visual type
.S DirectColor
and with
.A alloc
set to
.S AllocAll ,
and a read-write colourmap entry for a pixel value is changed by a call to xname, then
the pixel value is decomposed into three components using the
.S red_mask ,
.S green_mask
and
.S blue_mask
in the visual and the independent colourmap entries are updated.
>>#HISTORY Cal Completed Written in new format and style.
>>#HISTORY Kieron Completed <Have a look>
>>#HISTORY Cal Completed Writing code.
>>#HISTORY Kieron Completed Bug-fixes and re-engineering
|