summaryrefslogtreecommitdiff
path: root/xc/test/xsuite/xtest/tset/CH07/chngpntrcn/chngpntrcn.m
blob: aca17c2d601fb6760db574a6939911d513979a30 (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
/*
 
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: chngpntrcn.m,v 1.5 92/06/11 17:11:58 rws Exp $
 */
>>TITLE XChangePointerControl CH07
void

Display	*display = Dsp;
Bool	do_accel = False;
Bool	do_threshold = False;
int 	accel_numerator;
int 	accel_denominator;
int 	threshold;
>>EXTERN

static int 	oan, oad;
static int 	othresh;

/*
 * Save the original pointer values for restoring at the end of the test.
 */
>>SET startup saveold
static void
saveold()
{
	startup();
	if(Dsp)
		XGetPointerControl(Dsp, &oan, &oad, &othresh);
}

>>SET cleanup restorepoint
static void
restorepoint()
{
	if(Dsp)
		XChangePointerControl(Dsp, True, True, oan, oad, othresh);
	cleanup();
}

>>ASSERTION Good A
When
.A do_accel
is
.S True ,
then the acceleration of the pointer is set to the fraction
.A accel_numerator
over
.A accel_denominator .
>>STRATEGY
Set do_accel to True.
Set numerator and denominator values.
Call xname.
Verify that acceleration values have been set.
>>CODE
int 	newnum, newden, newthresh;

	do_accel = True;
	accel_numerator = 12;
	accel_denominator = 11;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newnum == accel_numerator)
		CHECK;
	else {
		report("accel_numerator was %d, expecting %d", newnum, accel_numerator);
		FAIL;
	}
	if (newden == accel_denominator)
		CHECK;
	else {
		report("accel_denominator was %d, expecting %d", newden, accel_denominator);
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
When
.A do_threshold
is
.S True ,
then the threshold
is set to the value in the
.A threshold
argument.
>># the acceleration only takes effect for pointer motions of more than
>># .A threshold
>># pixels at once and only applies to the number of pixels moved over the
>># threshold value.
>>STRATEGY
Set do_threshold to True.
Set value for threshold.
Call xname.
Verify that threshold value is set correctly.
>>CODE
int 	newnum, newden, newthresh;

	do_threshold = True;
	threshold = 43;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newthresh == threshold)
		CHECK;
	else {
		report("threshold was %d, expecting %d", newthresh, threshold);
		FAIL;
	}

	CHECKPASS(1);
>>ASSERTION Good A
When
.A threshold
is \-1, then the threshold is set to the default.
>>STRATEGY
Set do_threshold to True.
Set threshold to -1.
Call xname.
Obtain default value for threshold.
Set threshold to new value. 
Call xname.
Verify that threshold value is set correctly.
Set threshold to -1.
Call xname.
Verify that threshold value is set to default value.
>>CODE
int 	newnum, newden, newthresh;
int 	defnum, defden, defthresh;

	do_threshold = True;
	threshold = -1;

	XCALL;

	XGetPointerControl(display, &defnum, &defden, &defthresh);

	threshold = defthresh + 1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newthresh == threshold)
		CHECK;
	else {
		report("When setting a non-default threshold value,");
		delete("threshold was %d, expecting %d", newthresh, threshold);
		return;
	}

	threshold = -1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newthresh == defthresh)
		CHECK;
	else {
		report("When setting default threshold value,");
		report("threshold was %d, expecting %d", newthresh, defthresh);
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
When
.A accel_numerator
is \-1, then the numerator of the acceleration
is set to the default.
>>STRATEGY
Set do_accel to True.
Set numerator to -1.
Call xname.
Obtain default value for numerator.
Set numerator to new value. 
Call xname.
Verify that numerator value is set correctly.
Set numerator to -1.
Call xname.
Verify that numerator value is set to default value.
>>CODE
int 	newnum, newden, newthresh;
int 	defnum, defden, defthresh;

	do_accel = True;
	accel_numerator = -1;
	accel_denominator = 11;

	XCALL;

	XGetPointerControl(display, &defnum, &defden, &defthresh);

	accel_numerator = defnum + 1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newnum == accel_numerator)
		CHECK;
	else {
		report("When setting a non-default numerator value,");
		report("accel_numerator was %d, expecting %d", newnum, accel_numerator);
		FAIL;
	}

	accel_numerator = -1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newnum == defnum)
		CHECK;
	else {
		report("When setting default numerator value,");
		report("accel_numerator was %d, expecting %d", newnum, defnum);
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
When
.A accel_denominator
is \-1, then the denominator of the acceleration is set to the default.
>>STRATEGY
Set do_accel to True.
Set denominator to -1.
Call xname.
Obtain default value for denominator.
Set denominator to new value. 
Call xname.
Verify that denominator value is set correctly.
Set denominator to -1.
Call xname.
Verify that denominator value is set to default value.
>>CODE
int 	newnum, newden, newthresh;
int 	defnum, defden, defthresh;

	do_accel = True;
	accel_numerator = 12;
	accel_denominator = -1;

	XCALL;

	XGetPointerControl(display, &defnum, &defden, &defthresh);

	accel_denominator = defden + 1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newden == accel_denominator)
		CHECK;
	else {
		report("When setting a non-default denominator value,");
		report("accel_denominator was %d, expecting %d", newden, accel_denominator);
		FAIL;
	}

	accel_denominator = -1;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newden == defden)
		CHECK;
	else {
		report("When setting default denominator value,");
		report("accel_denominator was %d, expecting %d", newden, defden);
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
When the value of the
.A do_accel
or
.A do_threshold
arguments are
.S False ,
then the corresponding parameter is not changed.
>>STRATEGY
Get old values of parameters.
Call xname with do_accel and do_threshold False.
Verify no change to parameters.
>>CODE
int 	oldnum, oldden, oldthresh;
int 	newnum, newden, newthresh;

	XGetPointerControl(display, &oldnum, &oldden, &oldthresh);

	accel_numerator = oldnum+4;
	accel_denominator = oldden+5;
	threshold = oldthresh+2;

	do_accel = False;
	do_threshold = False;

	XCALL;

	XGetPointerControl(display, &newnum, &newden, &newthresh);

	if (newnum == oldnum)
		CHECK;
	else {
		report("accel_numerator was changed when do_accel was False");
		FAIL;
	}
	if (newden == oldden)
		CHECK;
	else {
		report("accel_denominator was changed when do_accel was False");
		FAIL;
	}
	if (newthresh == oldthresh)
		CHECK;
	else {
		report("threshold was changed when do_threshold was False");
		FAIL;
	}

	CHECKPASS(3);
>>ASSERTION Good A
When
.A threshold
is a negative number other than \-1, then a
.S BadValue
error occurs.
>>STRATEGY
Set do_threshold to True.
Set threshold to negative value other than -1.
Verify BadValue error.
>>CODE BadValue

	do_threshold = True;
	threshold = -3;

	XCALL;

	if (geterr() == BadValue)
		PASS;
>>ASSERTION Good A
When
.A accel_numerator
or
.A accel_denominator
are negative numbers other than \-1, then a
.S BadValue
error occurs.
>>STRATEGY
Set do_accel to True.
Set accel parameters to invalid values.
Verify BadValue error.
>>CODE BadValue

	do_accel = True;

	accel_denominator = 3;
	accel_numerator = -3;

	XCALL;

	if (geterr() == BadValue)
		CHECK;

	accel_denominator = -3;
	accel_numerator = 2;

	XCALL;

	if (geterr() == BadValue)
		CHECK;

	CHECKPASS(2);
>>ASSERTION Good A
When the
.A accel_denominator
argument is zero, then a
.S BadValue
error occurs.
>>STRATEGY
Set do_accel to True.
Set accel_denominator to zero.
Verify that a BadValue error occurs.
>>CODE BadValue

	do_accel = True;
	accel_denominator = 0;
	accel_numerator = 1;

	XCALL;

	if (geterr() == BadValue)
		PASS;
>>ASSERTION Bad A
.ER Value do_accel True False
>>ASSERTION Bad A
.ER Value do_threshold True False