]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
b86bc4cf | 2 | * "$Id: testraster.c 6158 2006-12-17 01:44:21Z mike $" |
ef416fc2 | 3 | * |
4 | * Raster test program routines for the Common UNIX Printing System (CUPS). | |
5 | * | |
6 | * Copyright 1997-2005 by Easy Software Products. | |
7 | * | |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Easy Software Products and are protected by Federal | |
10 | * copyright law. Distribution and use rights for the CUPS Raster source | |
11 | * files are outlined in the GNU Library General Public License, located | |
12 | * in the "pstoraster" directory. If this file is missing or damaged | |
13 | * please contact Easy Software Products at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636 USA | |
19 | * | |
20 | * Voice: (301) 373-9600 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * This code and any derivative of it may be used and distributed | |
25 | * freely under the terms of the GNU General Public License when | |
26 | * used with GNU Ghostscript or its derivatives. Use of the code | |
27 | * (or any derivative of it) with software other than GNU | |
28 | * GhostScript (or its derivatives) is governed by the CUPS license | |
29 | * agreement. | |
30 | * | |
31 | * This file is subject to the Apple OS-Developed Software exception. | |
32 | * | |
33 | * Contents: | |
34 | * | |
b86bc4cf | 35 | * main() - Test the raster functions. |
36 | * print_changes() - Print differences in the page header. | |
ef416fc2 | 37 | */ |
38 | ||
39 | /* | |
40 | * Include necessary headers... | |
41 | */ | |
42 | ||
b86bc4cf | 43 | #include "image-private.h" |
ef416fc2 | 44 | #include <stdlib.h> |
45 | #include <cups/string.h> | |
46 | ||
47 | ||
48 | /* | |
b86bc4cf | 49 | * Test PS commands and header... |
50 | */ | |
51 | ||
52 | static const char *test_code = | |
53 | "<<" | |
54 | "/MediaClass(Media Class)" | |
55 | "/MediaColor((Media Color))" | |
56 | "/MediaType(Media\\\\Type)" | |
57 | "/OutputType<416263>" | |
58 | "/AdvanceDistance 1000" | |
59 | "/AdvanceMedia 1" | |
60 | "/Collate false" | |
61 | "/CutMedia 2" | |
62 | "/Duplex true" | |
63 | "/HWResolution[100 200]" | |
64 | "/InsertSheet true" | |
65 | "/Jog 3" | |
66 | "/LeadingEdge 1" | |
67 | "/ManualFeed true" | |
68 | "/MediaPosition 8#777" | |
69 | "/MediaWeight 16#fe01" | |
70 | "/MirrorPrint true" | |
71 | "/NegativePrint true" | |
72 | "/NumCopies 1" | |
73 | "/Orientation 1" | |
74 | "/OutputFaceUp true" | |
75 | "/PageSize[612 792.1]" | |
76 | "/Separations true" | |
77 | "/TraySwitch true" | |
78 | "/Tumble true" | |
79 | "/cupsMediaType 2" | |
80 | "/cupsColorOrder 1" | |
81 | "/cupsColorSpace 1" | |
82 | "/cupsCompression 1" | |
83 | "/cupsRowCount 1" | |
84 | "/cupsRowFeed 1" | |
85 | "/cupsRowStep 1" | |
86 | "/cupsBorderlessScalingFactor 1.001" | |
87 | "/cupsInteger0 1" | |
88 | "/cupsInteger1 2" | |
89 | "/cupsInteger2 3" | |
90 | "/cupsInteger3 4" | |
91 | "/cupsInteger4 5" | |
92 | "/cupsInteger5 6" | |
93 | "/cupsInteger6 7" | |
94 | "/cupsInteger7 8" | |
95 | "/cupsInteger8 9" | |
96 | "/cupsInteger9 10" | |
97 | "/cupsInteger10 11" | |
98 | "/cupsInteger11 12" | |
99 | "/cupsInteger12 13" | |
100 | "/cupsInteger13 14" | |
101 | "/cupsInteger14 15" | |
102 | "/cupsInteger15 16" | |
103 | "/cupsReal0 1.1" | |
104 | "/cupsReal1 2.1" | |
105 | "/cupsReal2 3.1" | |
106 | "/cupsReal3 4.1" | |
107 | "/cupsReal4 5.1" | |
108 | "/cupsReal5 6.1" | |
109 | "/cupsReal6 7.1" | |
110 | "/cupsReal7 8.1" | |
111 | "/cupsReal8 9.1" | |
112 | "/cupsReal9 10.1" | |
113 | "/cupsReal10 11.1" | |
114 | "/cupsReal11 12.1" | |
115 | "/cupsReal12 13.1" | |
116 | "/cupsReal13 14.1" | |
117 | "/cupsReal14 15.1" | |
118 | "/cupsReal15 16.1" | |
119 | "/cupsString0(1)" | |
120 | "/cupsString1(2)" | |
121 | "/cupsString2(3)" | |
122 | "/cupsString3(4)" | |
123 | "/cupsString4(5)" | |
124 | "/cupsString5(6)" | |
125 | "/cupsString6(7)" | |
126 | "/cupsString7(8)" | |
127 | "/cupsString8(9)" | |
128 | "/cupsString9(10)" | |
129 | "/cupsString10(11)" | |
130 | "/cupsString11(12)" | |
131 | "/cupsString12(13)" | |
132 | "/cupsString13(14)" | |
133 | "/cupsString14(15)" | |
134 | "/cupsString15(16)" | |
135 | "/cupsMarkerType(Marker Type)" | |
136 | "/cupsRenderingIntent(Rendering Intent)" | |
137 | "/cupsPageSizeName(Letter)" | |
138 | "/cupsPreferredBitsPerColor 17" | |
139 | ">> setpagedevice"; | |
140 | ||
141 | static cups_page_header2_t test_header = | |
142 | { | |
143 | "Media Class", /* MediaClass */ | |
144 | "(Media Color)", /* MediaColor */ | |
145 | "Media\\Type", /* MediaType */ | |
146 | "Abc", /* OutputType */ | |
147 | 1000, /* AdvanceDistance */ | |
148 | CUPS_ADVANCE_FILE, /* AdvanceMedia */ | |
149 | CUPS_FALSE, /* Collate */ | |
150 | CUPS_CUT_JOB, /* CutMedia */ | |
151 | CUPS_TRUE, /* Duplex */ | |
152 | { 100, 200 }, /* HWResolution */ | |
153 | { 0, 0, 0, 0 }, /* ImagingBoundingBox */ | |
154 | CUPS_TRUE, /* InsertSheet */ | |
155 | CUPS_JOG_SET, /* Jog */ | |
156 | CUPS_EDGE_RIGHT, /* LeadingEdge */ | |
157 | { 0, 0 }, /* Margins */ | |
158 | CUPS_TRUE, /* ManualFeed */ | |
159 | 0777, /* MediaPosition */ | |
160 | 0xfe01, /* MediaWeight */ | |
161 | CUPS_TRUE, /* MirrorPrint */ | |
162 | CUPS_TRUE, /* NegativePrint */ | |
163 | 1, /* NumCopies */ | |
164 | CUPS_ORIENT_90, /* Orientation */ | |
165 | CUPS_TRUE, /* OutputFaceUp */ | |
166 | { 612, 792 }, /* PageSize */ | |
167 | CUPS_TRUE, /* Separations */ | |
168 | CUPS_TRUE, /* TraySwitch */ | |
169 | CUPS_TRUE, /* Tumble */ | |
170 | 0, /* cupsWidth */ | |
171 | 0, /* cupsHeight */ | |
172 | 2, /* cupsMediaType */ | |
173 | 0, /* cupsBitsPerColor */ | |
174 | 0, /* cupsBitsPerPixel */ | |
175 | 0, /* cupsBytesPerLine */ | |
176 | CUPS_ORDER_BANDED, /* cupsColorOrder */ | |
177 | CUPS_CSPACE_RGB, /* cupsColorSpace */ | |
178 | 1, /* cupsCompression */ | |
179 | 1, /* cupsRowCount */ | |
180 | 1, /* cupsRowFeed */ | |
181 | 1, /* cupsRowStep */ | |
182 | 0, /* cupsNumColors */ | |
183 | 1.001, /* cupsBorderlessScalingFactor */ | |
184 | { 612.0, 792.1 }, /* cupsPageSize */ | |
185 | { 0.0, 0.0, 0.0, 0.0 }, /* cupsImagingBBox */ | |
186 | { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, | |
187 | /* cupsInteger[16] */ | |
188 | { 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, 12.1, 13.1, | |
189 | 14.1, 15.1, 16.1 }, /* cupsReal[16] */ | |
190 | { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", | |
191 | "14", "15", "16" }, /* cupsString[16] */ | |
192 | "Marker Type", /* cupsMarkerType */ | |
193 | "Rendering Intent", /* cupsRenderingIntent */ | |
194 | "Letter" /* cupsPageSizeName */ | |
195 | }; | |
196 | ||
197 | ||
198 | /* | |
199 | * Local functions... | |
200 | */ | |
201 | ||
202 | static void print_changes(cups_page_header2_t *header, | |
203 | cups_page_header2_t *expected); | |
204 | ||
205 | ||
206 | /* | |
207 | * 'main()' - Test the raster functions. | |
ef416fc2 | 208 | */ |
209 | ||
210 | int /* O - Exit status */ | |
211 | main(void) | |
212 | { | |
213 | int page, x, y; /* Looping vars */ | |
214 | FILE *fp; /* Raster file */ | |
215 | cups_raster_t *r; /* Raster stream */ | |
b86bc4cf | 216 | cups_page_header2_t header, /* Page header */ |
217 | expected; /* Expected page header */ | |
ef416fc2 | 218 | unsigned char data[2048]; /* Raster data */ |
b86bc4cf | 219 | int preferred_bits; /* Preferred bits */ |
220 | int errors; /* Number of errors */ | |
221 | ||
222 | ||
223 | errors = 0; | |
224 | ||
225 | /* | |
226 | * Test PS exec code... | |
227 | */ | |
228 | ||
229 | fputs("_cupsRasterExecPS(\"setpagedevice\"): ", stdout); | |
230 | fflush(stdout); | |
231 | ||
232 | memset(&header, 0, sizeof(header)); | |
233 | header.Collate = CUPS_TRUE; | |
234 | preferred_bits = 0; | |
235 | ||
236 | if (_cupsRasterExecPS(&header, &preferred_bits, test_code)) | |
237 | { | |
238 | puts("FAIL (error from function)"); | |
239 | errors ++; | |
240 | } | |
241 | else if (preferred_bits != 17 || memcmp(&header, &test_header, sizeof(header))) | |
242 | { | |
243 | puts("FAIL (bad header)"); | |
244 | ||
245 | if (preferred_bits != 17) | |
246 | printf(" cupsPreferredBitsPerColor %d, expected 17\n", | |
247 | preferred_bits); | |
248 | ||
249 | print_changes(&test_header, &header); | |
250 | errors ++; | |
251 | } | |
252 | else | |
253 | puts("PASS"); | |
254 | ||
255 | fputs("_cupsRasterExecPS(\"roll\"): ", stdout); | |
256 | fflush(stdout); | |
257 | ||
258 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
259 | "792 612 0 0 0\n" | |
260 | "pop pop pop\n" | |
261 | "<</PageSize[5 -2 roll]/ImagingBBox null>>" | |
262 | "setpagedevice\n")) | |
263 | { | |
264 | puts("FAIL (error from function)"); | |
265 | errors ++; | |
266 | } | |
267 | else if (header.PageSize[0] != 792 || header.PageSize[1] != 612) | |
268 | { | |
269 | printf("FAIL (PageSize [%d %d], expected [792 612])\n", header.PageSize[0], | |
270 | header.PageSize[1]); | |
271 | errors ++; | |
272 | } | |
273 | else | |
274 | puts("PASS"); | |
275 | ||
276 | fputs("_cupsRasterExecPS(\"dup index\"): ", stdout); | |
277 | fflush(stdout); | |
278 | ||
279 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
280 | "true false dup\n" | |
281 | "<</Collate 4 index" | |
282 | "/Duplex 5 index" | |
283 | "/Tumble 6 index>>setpagedevice\n" | |
284 | "pop pop pop")) | |
285 | { | |
286 | puts("FAIL (error from function)"); | |
287 | errors ++; | |
288 | } | |
289 | else | |
290 | { | |
291 | if (!header.Collate) | |
292 | { | |
293 | printf("FAIL (Collate false, expected true)\n"); | |
294 | errors ++; | |
295 | } | |
296 | ||
297 | if (header.Duplex) | |
298 | { | |
299 | printf("FAIL (Duplex true, expected false)\n"); | |
300 | errors ++; | |
301 | } | |
302 | ||
303 | if (header.Tumble) | |
304 | { | |
305 | printf("FAIL (Tumble true, expected false)\n"); | |
306 | errors ++; | |
307 | } | |
308 | ||
309 | if(header.Collate && !header.Duplex && !header.Tumble) | |
310 | puts("PASS"); | |
311 | } | |
312 | ||
313 | #if 0 | |
314 | fputs("_cupsRasterExecPS(\"\"): ", stdout); | |
315 | fflush(stdout); | |
316 | ||
317 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
318 | "")) | |
319 | { | |
320 | puts("FAIL (error from function)"); | |
321 | errors ++; | |
322 | } | |
323 | else if (header.) | |
324 | { | |
325 | printf("FAIL ()\n"); | |
326 | errors ++; | |
327 | } | |
328 | else | |
329 | puts("PASS"); | |
330 | ||
331 | fputs("_cupsRasterExecPS(\"\"): ", stdout); | |
332 | fflush(stdout); | |
333 | ||
334 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
335 | "")) | |
336 | { | |
337 | puts("FAIL (error from function)"); | |
338 | errors ++; | |
339 | } | |
340 | else if (header.) | |
341 | { | |
342 | printf("FAIL ()\n"); | |
343 | errors ++; | |
344 | } | |
345 | else | |
346 | puts("PASS"); | |
347 | ||
348 | fputs("_cupsRasterExecPS(\"\"): ", stdout); | |
349 | fflush(stdout); | |
350 | ||
351 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
352 | "")) | |
353 | { | |
354 | puts("FAIL (error from function)"); | |
355 | errors ++; | |
356 | } | |
357 | else if (header.) | |
358 | { | |
359 | printf("FAIL ()\n"); | |
360 | errors ++; | |
361 | } | |
362 | else | |
363 | puts("PASS"); | |
364 | ||
365 | fputs("_cupsRasterExecPS(\"\"): ", stdout); | |
366 | fflush(stdout); | |
367 | ||
368 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
369 | "")) | |
370 | { | |
371 | puts("FAIL (error from function)"); | |
372 | errors ++; | |
373 | } | |
374 | else if (header.) | |
375 | { | |
376 | printf("FAIL ()\n"); | |
377 | errors ++; | |
378 | } | |
379 | else | |
380 | puts("PASS"); | |
381 | ||
382 | fputs("_cupsRasterExecPS(\"\"): ", stdout); | |
383 | fflush(stdout); | |
384 | ||
385 | if (_cupsRasterExecPS(&header, &preferred_bits, | |
386 | "")) | |
387 | { | |
388 | puts("FAIL (error from function)"); | |
389 | errors ++; | |
390 | } | |
391 | else if (header.) | |
392 | { | |
393 | printf("FAIL ()\n"); | |
394 | errors ++; | |
395 | } | |
396 | else | |
397 | puts("PASS"); | |
398 | #endif /* 0 */ | |
399 | ||
400 | /* | |
401 | * Test writing... | |
402 | */ | |
ef416fc2 | 403 | |
b86bc4cf | 404 | fputs("cupsRasterOpen(CUPS_RASTER_WRITE): ", stdout); |
405 | fflush(stdout); | |
ef416fc2 | 406 | |
407 | if ((fp = fopen("test.raster", "wb")) == NULL) | |
408 | { | |
b86bc4cf | 409 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 410 | return (1); |
411 | } | |
412 | ||
413 | if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_WRITE)) == NULL) | |
414 | { | |
b86bc4cf | 415 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 416 | fclose(fp); |
417 | return (1); | |
418 | } | |
419 | ||
b86bc4cf | 420 | puts("PASS"); |
421 | ||
ef416fc2 | 422 | for (page = 0; page < 4; page ++) |
423 | { | |
424 | memset(&header, 0, sizeof(header)); | |
425 | header.cupsWidth = 256; | |
426 | header.cupsHeight = 256; | |
427 | header.cupsBytesPerLine = 256; | |
428 | ||
429 | if (page & 1) | |
430 | { | |
431 | header.cupsBytesPerLine *= 2; | |
432 | header.cupsColorSpace = CUPS_CSPACE_CMYK; | |
433 | header.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
b86bc4cf | 434 | header.cupsNumColors = 4; |
ef416fc2 | 435 | } |
436 | else | |
437 | { | |
438 | header.cupsColorSpace = CUPS_CSPACE_K; | |
439 | header.cupsColorOrder = CUPS_ORDER_BANDED; | |
b86bc4cf | 440 | header.cupsNumColors = 1; |
ef416fc2 | 441 | } |
442 | ||
443 | if (page & 2) | |
444 | { | |
445 | header.cupsBytesPerLine *= 2; | |
446 | header.cupsBitsPerColor = 16; | |
447 | header.cupsBitsPerPixel = (page & 1) ? 64 : 16; | |
448 | } | |
449 | else | |
450 | { | |
451 | header.cupsBitsPerColor = 8; | |
452 | header.cupsBitsPerPixel = (page & 1) ? 32 : 8; | |
453 | } | |
454 | ||
b86bc4cf | 455 | if (cupsRasterWriteHeader2(r, &header)) |
456 | puts("cupsRasterWriteHeader2: PASS"); | |
457 | else | |
458 | { | |
459 | puts("cupsRasterWriteHeader2: FAIL"); | |
460 | errors ++; | |
461 | } | |
ef416fc2 | 462 | |
b86bc4cf | 463 | fputs("cupsRasterWritePixels: ", stdout); |
464 | fflush(stdout); | |
ef416fc2 | 465 | |
b86bc4cf | 466 | memset(data, 0, header.cupsBytesPerLine); |
ef416fc2 | 467 | for (y = 0; y < 64; y ++) |
b86bc4cf | 468 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) |
469 | break; | |
ef416fc2 | 470 | |
b86bc4cf | 471 | if (y < 64) |
472 | { | |
473 | puts("FAIL"); | |
474 | errors ++; | |
475 | } | |
476 | else | |
477 | { | |
478 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
479 | data[x] = x; | |
ef416fc2 | 480 | |
b86bc4cf | 481 | for (y = 0; y < 64; y ++) |
482 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
483 | break; | |
ef416fc2 | 484 | |
b86bc4cf | 485 | if (y < 64) |
486 | { | |
487 | puts("FAIL"); | |
488 | errors ++; | |
489 | } | |
490 | else | |
491 | { | |
492 | memset(data, 255, header.cupsBytesPerLine); | |
493 | for (y = 0; y < 64; y ++) | |
494 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
495 | break; | |
496 | ||
497 | if (y < 64) | |
498 | { | |
499 | puts("FAIL"); | |
500 | errors ++; | |
501 | } | |
502 | else | |
503 | { | |
504 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
505 | data[x] = x / 4; | |
506 | ||
507 | for (y = 0; y < 64; y ++) | |
508 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
509 | break; | |
510 | ||
511 | if (y < 64) | |
512 | { | |
513 | puts("FAIL"); | |
514 | errors ++; | |
515 | } | |
516 | else | |
517 | puts("PASS"); | |
518 | } | |
519 | } | |
520 | } | |
ef416fc2 | 521 | } |
522 | ||
523 | cupsRasterClose(r); | |
524 | fclose(fp); | |
525 | ||
b86bc4cf | 526 | /* |
527 | * Test reading... | |
528 | */ | |
529 | ||
530 | fputs("cupsRasterOpen(CUPS_RASTER_READ): ", stdout); | |
531 | fflush(stdout); | |
532 | ||
ef416fc2 | 533 | if ((fp = fopen("test.raster", "rb")) == NULL) |
534 | { | |
b86bc4cf | 535 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 536 | return (1); |
537 | } | |
538 | ||
539 | if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_READ)) == NULL) | |
540 | { | |
b86bc4cf | 541 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 542 | fclose(fp); |
543 | return (1); | |
544 | } | |
545 | ||
b86bc4cf | 546 | puts("PASS"); |
547 | ||
ef416fc2 | 548 | for (page = 0; page < 4; page ++) |
549 | { | |
b86bc4cf | 550 | memset(&expected, 0, sizeof(expected)); |
551 | expected.cupsWidth = 256; | |
552 | expected.cupsHeight = 256; | |
553 | expected.cupsBytesPerLine = 256; | |
ef416fc2 | 554 | |
b86bc4cf | 555 | if (page & 1) |
ef416fc2 | 556 | { |
b86bc4cf | 557 | expected.cupsBytesPerLine *= 2; |
558 | expected.cupsColorSpace = CUPS_CSPACE_CMYK; | |
559 | expected.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
560 | expected.cupsNumColors = 4; | |
561 | } | |
562 | else | |
563 | { | |
564 | expected.cupsColorSpace = CUPS_CSPACE_K; | |
565 | expected.cupsColorOrder = CUPS_ORDER_BANDED; | |
566 | expected.cupsNumColors = 1; | |
ef416fc2 | 567 | } |
568 | ||
b86bc4cf | 569 | if (page & 2) |
570 | { | |
571 | expected.cupsBytesPerLine *= 2; | |
572 | expected.cupsBitsPerColor = 16; | |
573 | expected.cupsBitsPerPixel = (page & 1) ? 64 : 16; | |
574 | } | |
575 | else | |
ef416fc2 | 576 | { |
b86bc4cf | 577 | expected.cupsBitsPerColor = 8; |
578 | expected.cupsBitsPerPixel = (page & 1) ? 32 : 8; | |
579 | } | |
ef416fc2 | 580 | |
b86bc4cf | 581 | fputs("cupsRasterReadHeader2: ", stdout); |
582 | fflush(stdout); | |
ef416fc2 | 583 | |
b86bc4cf | 584 | if (!cupsRasterReadHeader2(r, &header)) |
585 | { | |
586 | puts("FAIL (read error)"); | |
587 | errors ++; | |
588 | break; | |
ef416fc2 | 589 | } |
590 | ||
b86bc4cf | 591 | if (memcmp(&header, &expected, sizeof(header))) |
ef416fc2 | 592 | { |
b86bc4cf | 593 | puts("FAIL (bad page header)"); |
594 | errors ++; | |
595 | print_changes(&header, &expected); | |
ef416fc2 | 596 | } |
597 | ||
b86bc4cf | 598 | fputs("cupsRasterReadPixels: ", stdout); |
599 | fflush(stdout); | |
600 | ||
ef416fc2 | 601 | for (y = 0; y < 64; y ++) |
602 | { | |
b86bc4cf | 603 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) |
604 | { | |
605 | puts("FAIL (read error)"); | |
606 | errors ++; | |
607 | break; | |
608 | } | |
ef416fc2 | 609 | |
b86bc4cf | 610 | if (data[0] != 0 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) |
611 | { | |
612 | printf("FAIL (raster line %d corrupt)\n", y); | |
613 | errors ++; | |
614 | break; | |
615 | } | |
616 | } | |
617 | ||
618 | if (y == 64) | |
619 | { | |
620 | for (y = 0; y < 64; y ++) | |
621 | { | |
622 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
623 | { | |
624 | puts("FAIL (read error)"); | |
625 | errors ++; | |
ef416fc2 | 626 | break; |
b86bc4cf | 627 | } |
628 | ||
629 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
630 | if (data[x] != (x & 255)) | |
631 | break; | |
ef416fc2 | 632 | |
b86bc4cf | 633 | if (x < header.cupsBytesPerLine) |
634 | { | |
635 | printf("FAIL (raster line %d corrupt)\n", y + 64); | |
636 | errors ++; | |
637 | break; | |
638 | } | |
639 | } | |
640 | ||
641 | if (y == 64) | |
642 | { | |
643 | for (y = 0; y < 64; y ++) | |
644 | { | |
645 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
646 | { | |
647 | puts("FAIL (read error)"); | |
648 | errors ++; | |
649 | break; | |
650 | } | |
651 | ||
652 | if (data[0] != 255 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) | |
653 | { | |
654 | printf("fail (raster line %d corrupt)\n", y + 128); | |
655 | errors ++; | |
656 | break; | |
657 | } | |
658 | } | |
659 | ||
660 | if (y == 64) | |
661 | { | |
662 | for (y = 0; y < 64; y ++) | |
663 | { | |
664 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
665 | { | |
666 | puts("FAIL (read error)"); | |
667 | errors ++; | |
668 | break; | |
669 | } | |
670 | ||
671 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
672 | if (data[x] != ((x / 4) & 255)) | |
673 | break; | |
674 | ||
675 | if (x < header.cupsBytesPerLine) | |
676 | { | |
677 | printf("FAIL (raster line %d corrupt)\n", y + 192); | |
678 | errors ++; | |
679 | break; | |
680 | } | |
681 | } | |
682 | ||
683 | if (y == 64) | |
684 | puts("PASS"); | |
685 | } | |
686 | } | |
ef416fc2 | 687 | } |
688 | } | |
689 | ||
690 | cupsRasterClose(r); | |
691 | fclose(fp); | |
692 | ||
b86bc4cf | 693 | return (errors > 0); |
694 | } | |
695 | ||
696 | ||
697 | ||
698 | /* | |
699 | * 'print_changes()' - Print differences in the page header. | |
700 | */ | |
701 | ||
702 | static void | |
703 | print_changes( | |
704 | cups_page_header2_t *header, /* I - Actual page header */ | |
705 | cups_page_header2_t *expected) /* I - Expected page header */ | |
706 | { | |
707 | int i; /* Looping var */ | |
708 | ||
709 | ||
710 | if (strcmp(header->MediaClass, expected->MediaClass)) | |
711 | printf(" MediaClass (%s), expected (%s)\n", header->MediaClass, | |
712 | expected->MediaClass); | |
713 | ||
714 | if (strcmp(header->MediaColor, expected->MediaColor)) | |
715 | printf(" MediaColor (%s), expected (%s)\n", header->MediaColor, | |
716 | expected->MediaColor); | |
717 | ||
718 | if (strcmp(header->MediaType, expected->MediaType)) | |
719 | printf(" MediaType (%s), expected (%s)\n", header->MediaType, | |
720 | expected->MediaType); | |
721 | ||
722 | if (strcmp(header->OutputType, expected->OutputType)) | |
723 | printf(" OutputType (%s), expected (%s)\n", header->OutputType, | |
724 | expected->OutputType); | |
725 | ||
726 | if (header->AdvanceDistance != expected->AdvanceDistance) | |
727 | printf(" AdvanceDistance %d, expected %d\n", header->AdvanceDistance, | |
728 | expected->AdvanceDistance); | |
729 | ||
730 | if (header->AdvanceMedia != expected->AdvanceMedia) | |
731 | printf(" AdvanceMedia %d, expected %d\n", header->AdvanceMedia, | |
732 | expected->AdvanceMedia); | |
733 | ||
734 | if (header->Collate != expected->Collate) | |
735 | printf(" Collate %d, expected %d\n", header->Collate, | |
736 | expected->Collate); | |
737 | ||
738 | if (header->CutMedia != expected->CutMedia) | |
739 | printf(" CutMedia %d, expected %d\n", header->CutMedia, | |
740 | expected->CutMedia); | |
741 | ||
742 | if (header->Duplex != expected->Duplex) | |
743 | printf(" Duplex %d, expected %d\n", header->Duplex, | |
744 | expected->Duplex); | |
745 | ||
746 | if (header->HWResolution[0] != expected->HWResolution[0] || | |
747 | header->HWResolution[1] != expected->HWResolution[1]) | |
748 | printf(" HWResolution [%d %d], expected [%d %d]\n", | |
749 | header->HWResolution[0], header->HWResolution[1], | |
750 | expected->HWResolution[0], expected->HWResolution[1]); | |
751 | ||
752 | if (memcmp(header->ImagingBoundingBox, expected->ImagingBoundingBox, | |
753 | sizeof(header->ImagingBoundingBox))) | |
754 | printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n", | |
755 | header->ImagingBoundingBox[0], | |
756 | header->ImagingBoundingBox[1], | |
757 | header->ImagingBoundingBox[2], | |
758 | header->ImagingBoundingBox[3], | |
759 | expected->ImagingBoundingBox[0], | |
760 | expected->ImagingBoundingBox[1], | |
761 | expected->ImagingBoundingBox[2], | |
762 | expected->ImagingBoundingBox[3]); | |
763 | ||
764 | if (header->InsertSheet != expected->InsertSheet) | |
765 | printf(" InsertSheet %d, expected %d\n", header->InsertSheet, | |
766 | expected->InsertSheet); | |
767 | ||
768 | if (header->Jog != expected->Jog) | |
769 | printf(" Jog %d, expected %d\n", header->Jog, | |
770 | expected->Jog); | |
771 | ||
772 | if (header->LeadingEdge != expected->LeadingEdge) | |
773 | printf(" LeadingEdge %d, expected %d\n", header->LeadingEdge, | |
774 | expected->LeadingEdge); | |
775 | ||
776 | if (header->Margins[0] != expected->Margins[0] || | |
777 | header->Margins[1] != expected->Margins[1]) | |
778 | printf(" Margins [%d %d], expected [%d %d]\n", | |
779 | header->Margins[0], header->Margins[1], | |
780 | expected->Margins[0], expected->Margins[1]); | |
781 | ||
782 | if (header->ManualFeed != expected->ManualFeed) | |
783 | printf(" ManualFeed %d, expected %d\n", header->ManualFeed, | |
784 | expected->ManualFeed); | |
785 | ||
786 | if (header->MediaPosition != expected->MediaPosition) | |
787 | printf(" MediaPosition %d, expected %d\n", header->MediaPosition, | |
788 | expected->MediaPosition); | |
789 | ||
790 | if (header->MediaWeight != expected->MediaWeight) | |
791 | printf(" MediaWeight %d, expected %d\n", header->MediaWeight, | |
792 | expected->MediaWeight); | |
793 | ||
794 | if (header->MirrorPrint != expected->MirrorPrint) | |
795 | printf(" MirrorPrint %d, expected %d\n", header->MirrorPrint, | |
796 | expected->MirrorPrint); | |
797 | ||
798 | if (header->NegativePrint != expected->NegativePrint) | |
799 | printf(" NegativePrint %d, expected %d\n", header->NegativePrint, | |
800 | expected->NegativePrint); | |
801 | ||
802 | if (header->NumCopies != expected->NumCopies) | |
803 | printf(" NumCopies %d, expected %d\n", header->NumCopies, | |
804 | expected->NumCopies); | |
805 | ||
806 | if (header->Orientation != expected->Orientation) | |
807 | printf(" Orientation %d, expected %d\n", header->Orientation, | |
808 | expected->Orientation); | |
809 | ||
810 | if (header->OutputFaceUp != expected->OutputFaceUp) | |
811 | printf(" OutputFaceUp %d, expected %d\n", header->OutputFaceUp, | |
812 | expected->OutputFaceUp); | |
813 | ||
814 | if (header->PageSize[0] != expected->PageSize[0] || | |
815 | header->PageSize[1] != expected->PageSize[1]) | |
816 | printf(" PageSize [%d %d], expected [%d %d]\n", | |
817 | header->PageSize[0], header->PageSize[1], | |
818 | expected->PageSize[0], expected->PageSize[1]); | |
819 | ||
820 | if (header->Separations != expected->Separations) | |
821 | printf(" Separations %d, expected %d\n", header->Separations, | |
822 | expected->Separations); | |
823 | ||
824 | if (header->TraySwitch != expected->TraySwitch) | |
825 | printf(" TraySwitch %d, expected %d\n", header->TraySwitch, | |
826 | expected->TraySwitch); | |
827 | ||
828 | if (header->Tumble != expected->Tumble) | |
829 | printf(" Tumble %d, expected %d\n", header->Tumble, | |
830 | expected->Tumble); | |
831 | ||
832 | if (header->cupsWidth != expected->cupsWidth) | |
833 | printf(" cupsWidth %d, expected %d\n", header->cupsWidth, | |
834 | expected->cupsWidth); | |
835 | ||
836 | if (header->cupsHeight != expected->cupsHeight) | |
837 | printf(" cupsHeight %d, expected %d\n", header->cupsHeight, | |
838 | expected->cupsHeight); | |
839 | ||
840 | if (header->cupsMediaType != expected->cupsMediaType) | |
841 | printf(" cupsMediaType %d, expected %d\n", header->cupsMediaType, | |
842 | expected->cupsMediaType); | |
843 | ||
844 | if (header->cupsBitsPerColor != expected->cupsBitsPerColor) | |
845 | printf(" cupsBitsPerColor %d, expected %d\n", header->cupsBitsPerColor, | |
846 | expected->cupsBitsPerColor); | |
847 | ||
848 | if (header->cupsBitsPerPixel != expected->cupsBitsPerPixel) | |
849 | printf(" cupsBitsPerPixel %d, expected %d\n", header->cupsBitsPerPixel, | |
850 | expected->cupsBitsPerPixel); | |
851 | ||
852 | if (header->cupsBytesPerLine != expected->cupsBytesPerLine) | |
853 | printf(" cupsBytesPerLine %d, expected %d\n", header->cupsBytesPerLine, | |
854 | expected->cupsBytesPerLine); | |
855 | ||
856 | if (header->cupsColorOrder != expected->cupsColorOrder) | |
857 | printf(" cupsColorOrder %d, expected %d\n", header->cupsColorOrder, | |
858 | expected->cupsColorOrder); | |
859 | ||
860 | if (header->cupsColorSpace != expected->cupsColorSpace) | |
861 | printf(" cupsColorSpace %d, expected %d\n", header->cupsColorSpace, | |
862 | expected->cupsColorSpace); | |
863 | ||
864 | if (header->cupsCompression != expected->cupsCompression) | |
865 | printf(" cupsCompression %d, expected %d\n", header->cupsCompression, | |
866 | expected->cupsCompression); | |
867 | ||
868 | if (header->cupsRowCount != expected->cupsRowCount) | |
869 | printf(" cupsRowCount %d, expected %d\n", header->cupsRowCount, | |
870 | expected->cupsRowCount); | |
871 | ||
872 | if (header->cupsRowFeed != expected->cupsRowFeed) | |
873 | printf(" cupsRowFeed %d, expected %d\n", header->cupsRowFeed, | |
874 | expected->cupsRowFeed); | |
875 | ||
876 | if (header->cupsRowStep != expected->cupsRowStep) | |
877 | printf(" cupsRowStep %d, expected %d\n", header->cupsRowStep, | |
878 | expected->cupsRowStep); | |
879 | ||
880 | if (header->cupsNumColors != expected->cupsNumColors) | |
881 | printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors, | |
882 | expected->cupsNumColors); | |
883 | ||
884 | if (header->cupsBorderlessScalingFactor != | |
885 | expected->cupsBorderlessScalingFactor) | |
886 | printf(" cupsBorderlessScalingFactor %g, expected %g\n", | |
887 | header->cupsBorderlessScalingFactor, | |
888 | expected->cupsBorderlessScalingFactor); | |
889 | ||
890 | if (header->cupsPageSize[0] != expected->cupsPageSize[0] || | |
891 | header->cupsPageSize[1] != expected->cupsPageSize[1]) | |
892 | printf(" cupsPageSize [%g %g], expected [%g %g]\n", | |
893 | header->cupsPageSize[0], header->cupsPageSize[1], | |
894 | expected->cupsPageSize[0], expected->cupsPageSize[1]); | |
895 | ||
896 | if (header->cupsImagingBBox[0] != expected->cupsImagingBBox[0] || | |
897 | header->cupsImagingBBox[1] != expected->cupsImagingBBox[1] || | |
898 | header->cupsImagingBBox[2] != expected->cupsImagingBBox[2] || | |
899 | header->cupsImagingBBox[3] != expected->cupsImagingBBox[3]) | |
900 | printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n", | |
901 | header->cupsImagingBBox[0], header->cupsImagingBBox[1], | |
902 | header->cupsImagingBBox[2], header->cupsImagingBBox[3], | |
903 | expected->cupsImagingBBox[0], expected->cupsImagingBBox[1], | |
904 | expected->cupsImagingBBox[2], expected->cupsImagingBBox[3]); | |
905 | ||
906 | for (i = 0; i < 16; i ++) | |
907 | if (header->cupsInteger[i] != expected->cupsInteger[i]) | |
908 | printf(" cupsInteger%d %d, expected %d\n", i, header->cupsInteger[i], | |
909 | expected->cupsInteger[i]); | |
910 | ||
911 | for (i = 0; i < 16; i ++) | |
912 | if (header->cupsReal[i] != expected->cupsReal[i]) | |
913 | printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i], | |
914 | expected->cupsReal[i]); | |
915 | ||
916 | for (i = 0; i < 16; i ++) | |
917 | if (strcmp(header->cupsString[i], expected->cupsString[i])) | |
918 | printf(" cupsString%d (%s), expected (%s)\n", i, | |
919 | header->cupsString[i], expected->cupsString[i]); | |
920 | ||
921 | if (strcmp(header->cupsMarkerType, expected->cupsMarkerType)) | |
922 | printf(" cupsMarkerType (%s), expected (%s)\n", header->cupsMarkerType, | |
923 | expected->cupsMarkerType); | |
924 | ||
925 | if (strcmp(header->cupsRenderingIntent, expected->cupsRenderingIntent)) | |
926 | printf(" cupsRenderingIntent (%s), expected (%s)\n", | |
927 | header->cupsRenderingIntent, | |
928 | expected->cupsRenderingIntent); | |
929 | ||
930 | if (strcmp(header->cupsPageSizeName, expected->cupsPageSizeName)) | |
931 | printf(" cupsPageSizeName (%s), expected (%s)\n", | |
932 | header->cupsPageSizeName, | |
933 | expected->cupsPageSizeName); | |
ef416fc2 | 934 | } |
935 | ||
936 | ||
937 | /* | |
b86bc4cf | 938 | * End of "$Id: testraster.c 6158 2006-12-17 01:44:21Z mike $". |
ef416fc2 | 939 | */ |