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
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
|
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.
$Header: /cvs/xtest/xtest/xts5/tset/Xlib5/XGetWindowProperty/XGetWindowProperty.m,v 1.3 2005-11-03 08:43:39 jmichael Exp $
Copyright (c) 2001 The Open Group
Copyright (c) Applied Testing and Technology, Inc. 1995
All Rights Reserved.
>># Project: VSW5
>>#
>># File: xts5/tset/Xlib5/XGetWindowProperty/XGetWindowProperty.m
>>#
>># Description:
>># Tests for XGetWindowProperty()
>>#
>># Modifications:
>># $Log: gtwdwprprt.m,v $
>># Revision 1.3 2005-11-03 08:43:39 jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.2 2005/04/21 09:40:42 ajosey
>># resync to VSW5.1.5
>>#
>># Revision 8.2 2005/01/21 10:48:22 gwc
>># Updated copyright notice
>>#
>># Revision 8.1 2001/10/04 09:44:52 vsx
>># req.4.W.00157: fix incorrect comments about 32 bit longs
>>#
>># Revision 8.0 1998/12/23 23:26:46 mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0 1998/10/30 22:45:03 mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0 1998/03/02 05:19:00 tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0 1998/01/26 03:15:31 tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.1 1996/05/09 00:34:19 andy
>># Corrected Xatom include
>>#
>># Revision 4.0 1995/12/15 08:48:39 tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1 1995/12/15 00:47:26 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 XGetWindowProperty Xlib5
int
Display *display = Dsp;
Window w = defwin(display);
Atom property = XA_COPYRIGHT;
long long_offset = 2;
long long_length = 2;
Bool delete_prop = False;
Atom req_type = XA_STRING;
Atom *actual_type_return = &actual_type;
int *actual_format_return = &actual_format;
unsigned long *nitems_return = &nitems;
unsigned long *bytes_after_return = &bytes_after;
unsigned char **prop_return = ∝
>>EXTERN
#include "X11/Xatom.h"
static Atom actual_type;
static int actual_format;
static unsigned long nitems;
static unsigned long bytes_after;
static unsigned char *prop;
static void
set_vars()
{
actual_type = 0;
actual_format = -1;
nitems = -1;
bytes_after = -1;
prop = (unsigned char *)NULL;
}
static int
check_values( ex_actual_type, ex_actual_format, ex_nitems, ex_bytes_after )
Atom ex_actual_type;
int ex_actual_format;
unsigned long ex_nitems;
unsigned long ex_bytes_after;
{
int fail;
int pass;
fail=0;
pass=0;
#ifdef TESTING_CHECK
ex_actual_type = XA_RESOLUTION;
ex_actual_format = 6;
ex_nitems=256;
ex_bytes_after=256;
#endif
if (actual_type != ex_actual_type) {
FAIL;
report("%s returned an incorrect actual_type_return",
TestName);
report("Expected actual_type_return: %u (%s)", ex_actual_type,
(ex_actual_type==None?"None":atomname(ex_actual_type)));
report("Returned actual_type_return: %u (%s)",
actual_type, atomname(actual_type));
} else
pass++;
if (actual_format != ex_actual_format) {
FAIL;
report("%s returned an incorrect actual_format_return",
TestName);
report("Expected actual_format_return: %d", ex_actual_format);
report("Returned actual_format_return: %d", actual_format);
} else
pass++;
if (nitems != ex_nitems) {
FAIL;
report("%s returned an incorrect nitems_return",
TestName);
report("Expected nitems_return: %d", ex_nitems);
report("Returned nitems_return: %d", nitems);
} else
pass++;
if (bytes_after != ex_bytes_after) {
FAIL;
report("%s returned an incorrect bytes_after_return",
TestName);
report("Expected bytes_after_return: %d", ex_bytes_after);
report("Returned bytes_after_return: %d", bytes_after);
} else
pass++;
return((fail==0 && pass==4?1:0));
}
>>ASSERTION Good A
A successful call to xname returns
.A Success
and the actual type of the property, the actual format of the property,
the number of 8-bit, 16-bit, or 32-bit items transferred,
the number of bytes remaining to be read in the property,
and a pointer to the data actually returned.
>>STRATEGY
Create a window with a property.
Call xname to obtain the property information.
Verify that the returned information was correct.
>>CODE
int ret;
unsigned char cbuf[5];
char *data = "a tested property";
/* Create a window with a property. */
XChangeProperty(display, w, property, XA_STRING, 8,
PropModeReplace,(unsigned char *)data, strlen(data));
/* Call xname to obtain the property information. */
set_vars();
long_offset = 3;
long_length = 1;
delete_prop = False;
ret = XCALL;
/* Verify that the returned information was correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))", TestName,
ret, Success);
} else
CHECK;
if (check_values( XA_STRING, 8, (unsigned long)4, (unsigned long)1 )) {
CHECK;
} else
FAIL;
(void) strncpy((char *)cbuf, &(data[12]), 4);
cbuf[4] = '\0';
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an incorrect prop_return",
TestName);
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
} else
if (strncmp((char *)prop, (char *)cbuf, 5) != 0) {
FAIL;
report("%s returned an incorrect prop_return",
TestName);
report("Expected prop_return: '%s'", cbuf);
report("Returned prop_return: '%s'", prop);
} else
CHECK;
CHECKPASS(3);
>>ASSERTION Good A
>># Test for both delete True/False
>># Ensure no PropertyNotify events were generated. -stuart.
When the specified
.A property
does not exist for the specified window
.A w ,
then a call to xname returns
.S None
to
.A actual_type_return ,
zero to
.A actual_format_return
and
.A bytes_after_return ,
the
.A nitems_return
argument is empty, and the
.A delete
argument is ignored.
>>STRATEGY
Create a window with PropertyChangeMask events selected and no properties.
For delete_prop of True and False:
Call xname to obtain the property information.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
>>CODE
int mode;
int ret;
XEvent ev;
/* Create a window with PropertyChangeMask events selected and no properties. */
XDeleteProperty(display, w, property); /* ENSURE property is nuked. */
XSync(display,True);
XSelectInput(display, w, PropertyChangeMask);
/* For delete_prop of True and False: */
for(mode=0; mode<2; mode++) {
/* Call xname to obtain the property information. */
delete_prop = (mode==0?True:False);
trace("delete_prop is %s", boolname(delete_prop));
set_vars();
long_offset = 3;
long_length = 1;
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( None, 0,
(unsigned long)0, (unsigned long)0 ) ) {
CHECK;
} else
FAIL;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
#ifdef TESTING
ret++;
ev.type = PropertyNotify;
#endif
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
}
CHECKPASS(2*3);
>>ASSERTION Good A
>># Ensure the last item by ensuring no PropertyNotify events were
>># generated. Test for both delete True and False. -stuart.
When the specified
.A property
exists for the specified window
.A w
and the type does not match the specified
.A req_type ,
then a call to xname returns the actual property type to
.A actual_type_return ,
the actual property format to
.A actual_format_return ,
and the property length in bytes to
.A bytes_after_return ,
the
.A nitems_return
argument is empty, and the
.A delete
argument is ignored.
>>STRATEGY
Create a window with a property and PropertyChangeMask events selected.
For delete_prop of True and False:
Call xname to obtain the property information.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
>>CODE
int mode;
int ret;
char *data = "a tested property";
XEvent ev;
/* Create a window with a property and PropertyChangeMask events selected. */
XChangeProperty(display, w, property, XA_STRING, 8,
PropModeReplace,(unsigned char *)data, strlen(data));
XSync(display,True);
XSelectInput(display, w, PropertyChangeMask);
/* For delete_prop of True and False: */
for(mode=0; mode<2; mode++) {
/* Call xname to obtain the property information. */
delete_prop = (mode==0?True:False);
trace("delete_prop is %s", boolname(delete_prop));
set_vars();
long_offset = 3;
long_length = 1;
req_type = XA_INTEGER;
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_STRING, 8,
(unsigned long)0, (unsigned long)strlen(data) ) ) {
CHECK;
} else
FAIL;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
#ifdef TESTING
ret++;
ev.type = PropertyNotify;
#endif
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
}
CHECKPASS(2*3);
>>ASSERTION Good A
>># Ensure a) No PropertyNotify events generated
>># b) That the property can be referenced again.
>># c) tested for req_type of type and AnyPropertyType
>># Test this by using long_offset and long_length to test different
>># values for bytes_after_return and nitems_return. -stuart.
>># There might be a better way of expressing the assertion...
When the specified
.A property
exists for the specified window
.A w ,
.A req_type
is set to the type of the property or
.S AnyPropertyType ,
and
.A delete
is set to
.S False ,
then a call to xname returns the actual
.A property
type to
.A actual_type_return ,
the actual
.A property
format to
.A actual_format_return ,
the number of trailing unread bytes in the
.A property
in
.A bytes_after_return ,
the number of 8/16/32 bit items in
.A nitems_return ,
the data is placed in
.A prop_return ,
where the data is sourced from four times
.A long_offset
bytes into the
.A property ,
and is the minimum of the remaining bytes
left in the
.A property
and four times
.A long_length
bytes long, and the
.A property
is not deleted.
>>STRATEGY
Create a window with testable properties.
For req_type is the required type and AnyPropertyType:
Call xname to obtain the property information of a STRING property,
with delete False.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
Call xname to obtain the property information of an INTEGER property,
with delete False.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
>>CODE
int ret;
int mode;
char *cdata = "a tested property";
>># Note that this _must_ be an array of longs, even if longs are 64 bit
unsigned long idata[4];
XEvent ev;
/* Create a window with testable properties. */
XChangeProperty(display, w, XA_COPYRIGHT, XA_STRING, 8,
PropModeReplace, (unsigned char *)cdata, strlen(cdata));
for( ret=0; ret<4; ret++ )
idata[ret] = ret;
XChangeProperty(display, w, XA_NOTICE, XA_INTEGER, 32,
PropModeReplace, (unsigned char *)idata, 4);
XSync(display, True);
XSelectInput(display, w, PropertyChangeMask);
/* For req_type is the required type and AnyPropertyType: */
for(mode=0; mode<2 ;mode++) {
trace("Calling %s to obtain string information", TestName);
/* Call xname to obtain the property information of a STRING property, */
/* with delete False. */
set_vars();
property = XA_COPYRIGHT;
long_length = 2; /* Attempt to read 8 bytes from */
long_offset = 4; /* 16 bytes into the property. */
/* We expect only one byte to be returned. */
trace("req_type is %s", (mode==0?"STRING":"AnyPropertyType"));
req_type=(mode==0?XA_STRING:AnyPropertyType);
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_STRING, 8,
(unsigned long)1, (unsigned long)0 ) ) {
CHECK;
} else
FAIL;
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
} else
if (strncmp((char *)prop, "y", 1) != 0) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: 'y'");
report("Returned prop_return: '%s'", prop);
} else
CHECK;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
trace("Calling %s to obtain integer information", TestName);
/* Call xname to obtain the property information of an INTEGER property, */
/* with delete False. */
set_vars();
property = XA_NOTICE;
long_length = 1; /* Attempt to read 4 bytes from */
long_offset = 1; /* 4 bytes into the property. */
/* We expect one integer to be returned. */
trace("req_type is %s", (mode==0?"INTEGER":"AnyPropertyType"));
req_type=(mode==0?XA_INTEGER:AnyPropertyType);
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_INTEGER, 32,
(unsigned long)1, (unsigned long)8 ) ) {
CHECK;
} else
FAIL;
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
} else
if ( *(unsigned long *)prop != idata[1] ) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: %u", idata[1]);
report("Returned prop_return: %u",
*(unsigned long*)prop);
} else
CHECK;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
}
CHECKPASS(2*8);
>>ASSERTION Good A
>># NEW, NON_MIT_REVIEWED ASSERTION
When the specified
.A property
exists for the specified window
.A w ,
.A req_type
is set to the type of the property or
.S AnyPropertyType ,
and
.A delete
is set to
.S True ,
and on a call to xname the number of unread bytes in the
.A property
returned to
.A bytes_after_return
is non-zero, then
the actual
.A property
type is returned to
.A actual_type_return ,
the actual
.A property
format to
.A actual_format_return ,
the number of trailing unread bytes in the
.A property
in
.A bytes_after_return ,
the number of 8/16/32 bit items in
.A nitems_return ,
the data is placed in
.A prop_return ,
where the data is sourced from four times
.A long_offset
bytes into the
.A property ,
and is the minimum of the remaining bytes
left in the
.A property
and four times
.A long_length
bytes long, and the
.A property
is not deleted.
>>STRATEGY
Create a window with testable properties.
For req_type is the required type and AnyPropertyType:
Call xname to obtain the property information of a STRING property,
with delete True.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
Call xname to obtain the property information of an INTEGER property,
with delete True.
Verify that the returned values were correct.
Verify that no PropertyNotify events were generated.
>>CODE
int ret;
int mode;
char *cdata = "a tested property";
>># Note that this _must_ be an array of longs, even if longs are 64 bit
unsigned long idata[4];
XEvent ev;
/* Create a window with testable properties. */
XChangeProperty(display, w, XA_COPYRIGHT, XA_STRING, 8,
PropModeReplace, (unsigned char *)cdata, strlen(cdata));
for( ret=0; ret<4; ret++ )
idata[ret] = ret;
XChangeProperty(display, w, XA_NOTICE, XA_INTEGER, 32,
PropModeReplace, (unsigned char *)idata, 4);
XSync(display, True);
XSelectInput(display, w, PropertyChangeMask);
/* For req_type is the required type and AnyPropertyType: */
for(mode=0; mode<2 ;mode++) {
trace("Calling %s to obtain string information", TestName);
/* Call xname to obtain the property information of a STRING property, */
/* with delete True. */
set_vars();
property = XA_COPYRIGHT;
long_length = 1; /* Attempt to read 4 bytes from */
long_offset = 1; /* 4 bytes into the property. */
/* We expect 4 bytes to be returned. */
trace("req_type is %s", (mode==0?"STRING":"AnyPropertyType"));
req_type=(mode==0?XA_STRING:AnyPropertyType);
delete_prop=True;
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_STRING, 8,
(unsigned long)4, (unsigned long)9 ) ) {
CHECK;
} else
FAIL;
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
} else
if (strncmp((char *)prop, "sted", 1) != 0) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: 'sted'");
report("Returned prop_return: '%s'", prop);
} else
CHECK;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
trace("Calling %s to obtain integer information", TestName);
/* Call xname to obtain the property information of an INTEGER property, */
/* with delete True. */
set_vars();
property = XA_NOTICE;
long_length = 1; /* Attempt to read 4 bytes from */
long_offset = 1; /* 4 bytes into the property. */
/* We expect one integer to be returned. */
trace("req_type is %s", (mode==0?"INTEGER":"AnyPropertyType"));
req_type=(mode==0?XA_INTEGER:AnyPropertyType);
delete_prop = True;
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_INTEGER, 32,
(unsigned long)1, (unsigned long)8 ) ) {
CHECK;
} else
FAIL;
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
} else
if ( *(unsigned long *)prop != idata[1] ) {
FAIL;
report("%s returned an unexpected prop_return");
report("Expected prop_return: %u", idata[1]);
report("Returned prop_return: %u",
*(unsigned long *)prop);
} else
CHECK;
/* Verify that no PropertyNotify events were generated. */
ret = getevent(display, &ev);
if (ret != 0) {
FAIL;
report("%s caused %d unexpected event%s", TestName,
ret, (ret==1?"":"s"));
do {
report("event %s returned", eventname(ev.type));
} while(getevent(display, &ev) != 0) ;
} else
CHECK;
}
CHECKPASS(2*8);
>>ASSERTION Good A
When the specified
.A property
exists for the specified window
.A w ,
.A req_type
is set to the type of the property or
.S AnyPropertyType ,
.A delete
is set to
.S True ,
and on a call to xname the number of unread bytes in the
.A property
returned to
.A bytes_after_return
is zero, then the property is deleted from the window
.A w
and a
.S PropertyNotify
event is generated on the specified window
.A w .
>>STRATEGY
Create a window with PropertyChangeMask events selected.
For req_type is the required type and AnyPropertyType:
Create a property on the window.
Call xname to obtain the property information,
with delete True.
Verify that the returned values were correct.
Verify that a single PropertyNotify event was generated.
Verify that the property has been deleted.
>>CODE
int mode;
int ret;
char *data="a tested property";
XEvent ev;
/* Create a window with PropertyChangeMask events selected. */
XSelectInput(display, w, PropertyChangeMask);
/* For req_type is the required type and AnyPropertyType: */
for(mode=0; mode<2 ;mode++) {
/* Create a property on the window. */
XChangeProperty(display, w, XA_COPYRIGHT, XA_STRING, 8,
PropModeReplace, (unsigned char *)data, strlen(data));
XSync(display,True);
/* Call xname to obtain the property information, */
/* with delete True. */
set_vars();
delete_prop = True;
req_type=(mode==0?XA_STRING:AnyPropertyType);
long_offset = 3;
long_length = 2;
trace("delete_prop is %s", boolname(delete_prop));
trace("req_type is %s", (mode==0?"STRING":"AnyPropertyType"));
ret = XCALL;
XSync(display, False);
/* Verify that the returned values were correct. */
if (ret != Success) {
FAIL;
report("%s returned %d (expecting Success (%d))",
TestName, ret, Success);
} else
CHECK;
if ( check_values( XA_STRING, 8,
(unsigned long)5, (unsigned long)0 ) ) {
CHECK;
} else
FAIL;
/* Verify that a single PropertyNotify event was generated. */
ret = getevent(display, &ev);
if (ret != 1 || ev.type != PropertyNotify) {
FAIL;
report("%s caused %d events", TestName, ret);
report("Expecting a single PropertyNotify event");
while(ret != 0) {
report("Returned: %s event",
eventname(ev.type));
ret = getevent(display, &ev);
}
} else {
XEvent good;
good.type = PropertyNotify;
good.xproperty.type = PropertyNotify;
good.xproperty.display = display;
good.xproperty.serial = 0; /* Can't know */
good.xproperty.send_event = False;
good.xproperty.display = display;
good.xproperty.window = w;
good.xproperty.atom = XA_COPYRIGHT;
good.xproperty.time = 0 ; /* Can't know */
good.xproperty.state = PropertyDelete;
if (checkevent(&good, &ev) != 0) {
FAIL;
} else
CHECK;
}
/* Verify that the property has been deleted. */
delete_prop=False;
ret = XCALL;
if ((ret != Success) || !check_values(None, 0,
(unsigned long)0, (unsigned long)0) ) {
FAIL;
report("Property was not deleted.");
} else
CHECK;
}
CHECKPASS(2*4);
>>ASSERTION Good A
A call to xname always allocates one extra byte in
.A prop_return
and sets it to ASCII
.A NULL .
>>STRATEGY
Create a window with a property.
Call xname to obtain property information.
Verify that prop_return contained an ASCII NULL.
>>CODE
int ret;
char *data = "a tested property";
/* Create a window with a property. */
XChangeProperty(display, w, property, XA_STRING, 8, PropModeReplace,
(unsigned char *)data, strlen(data));
/* Call xname to obtain property information. */
set_vars();
long_offset=1;
long_length=0;
ret = XCALL;
if (ret != Success) {
delete("%s returned %d when expecting %d", ret, Success);
return;
} else
CHECK;
if (!check_values( XA_STRING, 8,
(unsigned long)0, (unsigned long)13 )) {
delete("%s returned unexpected values");
} else
CHECK;
/* Verify that prop_return contained an ASCII NULL. */
if (prop == (unsigned char *)NULL) {
FAIL;
report("%s returned an unexpected prop_return", TestName);
report("Expected prop_return: unsigned char * pointer");
report("Returned prop_return: NULL pointer");
return;
} else
CHECK;
if (*prop != (unsigned char)'\0') {
FAIL;
report("%s did not allocate an ASCII NULL character beyond");
report("the prop_return data.");
} else
CHECK;
CHECKPASS(4);
>>ASSERTION Bad A
.ER BadWindow
>>ASSERTION Bad A
.ER BadAtom
>>ASSERTION Bad A
When xname is called with
.A long_offset
such that the offset lies beyond the end of the
.A property ,
then a
.S BadValue
error occurs.
>>STRATEGY
Create a window with a property and PropertyChangeMask events selected.
Call xname with a long_offset beyond the property end.
Verify that a BadValue error occurred.
>>CODE BadValue
char *data = "a tested property";
/* Create a window with a property and PropertyChangeMask events selected. */
XChangeProperty(display, w, property, XA_STRING, 8,
PropModeReplace,(unsigned char *)data, strlen(data));
seterrdef();
/* Call xname with a long_offset beyond the property end. */
long_offset=5;
long_length=0;
XCALL;
/* Verify that a BadValue error occurred. */
if (geterr() != BadValue) {
FAIL;
report("%s did not generate a BadValue when long_offset was",
TestName);
report("beyond the length of the property");
} else
CHECK;
CHECKPASS(1);
|