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
|
use warnings;
use strict;
use Test::More tests => 20;
use Image::Sane ':all'; # For enums
use Glib qw(TRUE FALSE); # To get TRUE and FALSE
BEGIN { use_ok('Gscan2pdf::Scanner::Options') }
#########################
my $filename = 'scanners/test';
SKIP: {
skip 'source tree not available', 19 unless -r $filename;
my $output = do { local ( @ARGV, $/ ) = $filename; <> };
my $options = Gscan2pdf::Scanner::Options->new_from_data($output);
my @that = (
{
'index' => 0,
},
{
'cap' => 0,
'max_values' => 0,
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 1,
'desc' => '',
'title' => 'Scan Mode',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'mode',
'val' => 'Gray',
'index' => 2,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Selects the scan mode (e.g., lineart, monochrome, or color).',
'type' => SANE_TYPE_STRING,
'constraint' => [ 'Gray', 'Color' ],
'title' => 'Mode',
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'depth',
'val' => '8',
'index' => 3,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Number of bits per sample, typical values are 1 for "line-art" and 8 for multibit scans.',
'type' => SANE_TYPE_INT,
'constraint' => [ '1', '8', '16' ],
'title' => 'Depth',
'constraint_type' => SANE_CONSTRAINT_WORD_LIST
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'hand-scanner',
'val' => '0',
'index' => 4,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Simulate a hand-scanner. Hand-scanners do not know the image height a priori. Instead, they return a height of -1. Setting this option allows to test whether a frontend can handle this correctly. This option also enables a fixed width of 11 cm.',
'title' => 'Hand scanner',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => '37',
'max_values' => '1',
'name' => 'three-pass',
'unit' => SANE_UNIT_NONE,
'index' => 5,
'desc' =>
'Simulate a three-pass scanner. In color mode, three frames are transmitted.',
'title' => 'Three pass',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => '37',
'max_values' => '1',
'name' => 'three-pass-order',
'index' => 6,
'unit' => SANE_UNIT_NONE,
'desc' => 'Set the order of frames in three-pass color mode.',
'title' => 'Three pass order',
'type' => SANE_TYPE_STRING,
'constraint' => [ 'RGB', 'RBG', 'GBR', 'GRB', 'BRG', 'BGR' ],
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'resolution',
'val' => '50',
'index' => 7,
'unit' => SANE_UNIT_DPI,
'desc' => 'Sets the resolution of the scanned image.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '1',
'max' => '1200',
'quant' => '1'
},
'title' => 'Resolution',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'source',
'val' => 'Flatbed',
'index' => 8,
'unit' => SANE_UNIT_NONE,
'desc' =>
'If Automatic Document Feeder is selected, the feeder will be \'empty\' after 10 scans.',
'type' => SANE_TYPE_STRING,
'constraint' => [ 'Flatbed', 'Automatic Document Feeder' ],
'title' => 'Source',
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => '0',
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 9,
'desc' => '',
'title' => 'Special Options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'test-picture',
'val' => 'Solid black',
'index' => 10,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Select the kind of test picture. Available options: Solid black: fills the whole scan with black. Solid white: fills the whole scan with white. Color pattern: draws various color test patterns depending on the mode. Grid: draws a black/white grid with a width and height of 10 mm per square.',
'type' => SANE_TYPE_STRING,
'constraint' =>
[ 'Solid black', 'Solid white', 'Color pattern', 'Grid' ],
'title' => 'Test picture',
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => '37',
'max_values' => '1',
'name' => 'invert-endianess',
'unit' => SANE_UNIT_NONE,
'index' => 11,
'desc' =>
'Exchange upper and lower byte of image data in 16 bit modes. This option can be used to test the 16 bit modes of frontends, e.g. if the frontend uses the correct endianness.',
'title' => 'Invert endianess',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'read-limit',
'val' => '0',
'index' => 12,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Limit the amount of data transferred with each call to sane_read().',
'title' => 'Read limit',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => '37',
'max_values' => '1',
'name' => 'read-limit-size',
'index' => 13,
'unit' => SANE_UNIT_NONE,
'desc' =>
'The (maximum) amount of data transferred with each call to sane_read().',
'title' => 'Read limit size',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '1',
'max' => '65536',
'quant' => '1'
},
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'read-delay',
'val' => '0',
'index' => 14,
'unit' => SANE_UNIT_NONE,
'desc' => 'Delay the transfer of data to the pipe.',
'title' => 'Read delay',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => '37',
'max_values' => '1',
'name' => 'read-delay-duration',
'index' => 15,
'unit' => SANE_UNIT_MICROSECOND,
'desc' =>
'How long to wait after transferring each buffer of data through the pipe.',
'title' => 'Read delay duration',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '1000',
'max' => '200000',
'quant' => '1000'
},
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'read-return-value',
'val' => 'Default',
'index' => 16,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Select the return-value of sane_read(). "Default" is the normal handling for scanning. All other status codes are for testing how the frontend handles them.',
'type' => SANE_TYPE_STRING,
'constraint' => [
'Default', 'SANE_STATUS_UNSUPPORTED',
'SANE_STATUS_CANCELLED', 'SANE_STATUS_DEVICE_BUSY',
'SANE_STATUS_INVAL', 'SANE_STATUS_EOF',
'SANE_STATUS_JAMMED', 'SANE_STATUS_NO_DOCS',
'SANE_STATUS_COVER_OPEN', 'SANE_STATUS_IO_ERROR',
'SANE_STATUS_NO_MEM', 'SANE_STATUS_ACCESS_DENIED'
],
'title' => 'Read return value',
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'ppl-loss',
'val' => '0',
'index' => 17,
'unit' => SANE_UNIT_PIXEL,
'desc' =>
'The number of pixels that are wasted at the end of each line.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '-128',
'max' => '128',
'quant' => '1'
},
'title' => 'Ppl loss',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'fuzzy-parameters',
'val' => '0',
'index' => 18,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Return fuzzy lines and bytes per line when sane_parameters() is called before sane_start().',
'title' => 'Fuzzy parameters',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'non-blocking',
'val' => '0',
'index' => 19,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Use non-blocking IO for sane_read() if supported by the frontend.',
'title' => 'Non blocking',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'select-fd',
'val' => '0',
'index' => 20,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Offer a select filedescriptor for detecting if sane_read() will return data.',
'title' => 'Select fd',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'enable-test-options',
'val' => '0',
'index' => 21,
'unit' => SANE_UNIT_NONE,
'desc' =>
'Enable various test options. This is for testing the ability of frontends to view and modify all the different SANE option types.',
'title' => 'Enable test options',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'read-length-zero',
'val' => '0',
'index' => 22,
'unit' => SANE_UNIT_NONE,
'desc' =>
'sane_read() returns data \'x\' but length=0 on first call. This is helpful for testing slow device behavior that returns no data when background work is in process and zero length with SANE_STATUS_GOOD although data is NOT filled with 0.',
'title' => 'Read length zero',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '0',
'name' => 'print-options',
'unit' => SANE_UNIT_NONE,
'index' => 23,
'desc' => 'Print a list of all options.',
'title' => 'Print options',
'type' => SANE_TYPE_BUTTON,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => '0',
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 24,
'desc' => '',
'title' => 'Geometry',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => SANE_NAME_SCAN_TL_X,
'val' => '0',
'index' => 25,
'unit' => SANE_UNIT_MM,
'desc' => 'Top-left x position of scan area.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '200',
'quant' => '1'
},
'title' => 'Top-left x',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => SANE_NAME_SCAN_TL_Y,
'val' => '0',
'index' => 26,
'unit' => SANE_UNIT_MM,
'desc' => 'Top-left y position of scan area.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '200',
'quant' => '1'
},
'title' => 'Top-left y',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => SANE_NAME_SCAN_BR_X,
'val' => '80',
'index' => 27,
'unit' => SANE_UNIT_MM,
'desc' => 'Bottom-right x position of scan area.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '200',
'quant' => '1'
},
'title' => 'Bottom-right x',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => SANE_NAME_SCAN_BR_Y,
'val' => '100',
'index' => 28,
'unit' => SANE_UNIT_MM,
'desc' => 'Bottom-right y position of scan area.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '200',
'quant' => '1'
},
'title' => 'Bottom-right y',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'page-width',
'val' => '200',
'index' => 29,
'unit' => SANE_UNIT_MM,
'desc' =>
'Specifies the width of the media. Required for automatic centering of sheet-fed scans.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '300',
'quant' => '1'
},
'title' => 'Page width',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT + SANE_CAP_SOFT_SELECT,
'max_values' => '1',
'name' => 'page-height',
'val' => '200',
'index' => 30,
'unit' => SANE_UNIT_MM,
'desc' => 'Specifies the height of the media.',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '0',
'max' => '300',
'quant' => '1'
},
'title' => 'Page height',
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => 0,
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 31,
'desc' => '',
'title' => 'Bool test options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'bool-soft-select-soft-detect',
'unit' => SANE_UNIT_NONE,
'index' => 32,
'desc' =>
'(1/6) Bool test option that has soft select and soft detect (and advanced) capabilities. That\'s just a normal bool option.',
'title' => 'Bool soft select soft detect',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'bool-soft-select-soft-detect-emulated',
'unit' => SANE_UNIT_NONE,
'index' => 33,
'desc' =>
'(5/6) Bool test option that has soft select, soft detect, and emulated (and advanced) capabilities.',
'title' => 'Bool soft select soft detect emulated',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE +
SANE_CAP_AUTOMATIC,
'max_values' => '1',
'name' => 'bool-soft-select-soft-detect-auto',
'unit' => SANE_UNIT_NONE,
'index' => 34,
'desc' =>
'(6/6) Bool test option that has soft select, soft detect, and automatic (and advanced) capabilities. This option can be automatically set by the backend.',
'title' => 'Bool soft select soft detect auto',
'type' => SANE_TYPE_BOOL,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => 0,
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 35,
'desc' => '',
'title' => 'Int test options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'int',
'unit' => SANE_UNIT_NONE,
'index' => 36,
'desc' =>
'(1/6) Int test option with no unit and no constraint set.',
'title' => 'Int',
'type' => SANE_TYPE_INT,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'int-constraint-range',
'index' => 37,
'unit' => SANE_UNIT_PIXEL,
'desc' =>
'(2/6) Int test option with unit pixel and constraint range set. Minimum is 4, maximum 192, and quant is 2.',
'title' => 'Int constraint range',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '4',
'max' => '192',
'quant' => '2'
},
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'int-constraint-word-list',
'index' => 38,
'unit' => SANE_UNIT_BIT,
'desc' =>
'(3/6) Int test option with unit bits and constraint word list set.',
'title' => 'Int constraint word list',
'type' => SANE_TYPE_INT,
'constraint' => [
'-42', '-8', '0', '17',
'42', '256', '65536', '16777216',
'1073741824'
],
'constraint_type' => SANE_CONSTRAINT_WORD_LIST
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => 255,
'name' => 'int-constraint-array',
'unit' => SANE_UNIT_NONE,
'index' => 39,
'desc' =>
'(4/6) Int test option with unit mm and using an array without constraints.',
'title' => 'Int constraint array',
'type' => SANE_TYPE_INT,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => 255,
'name' => 'int-constraint-array-constraint-range',
'index' => 40,
'unit' => SANE_UNIT_DPI,
'desc' =>
'(5/6) Int test option with unit dpi and using an array with a range constraint. Minimum is 4, maximum 192, and quant is 2.',
'title' => 'Int constraint array constraint range',
'type' => SANE_TYPE_INT,
'constraint' => {
'min' => '4',
'max' => '192',
'quant' => '2'
},
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => 255,
'name' => 'int-constraint-array-constraint-word-list',
'index' => 41,
'unit' => SANE_UNIT_PERCENT,
'desc' =>
'(6/6) Int test option with unit percent and using an array with a word list constraint.',
'title' => 'Int constraint array constraint word list',
'type' => SANE_TYPE_INT,
'constraint' => [
'-42', '-8', '0', '17',
'42', '256', '65536', '16777216',
'1073741824'
],
'constraint_type' => SANE_CONSTRAINT_WORD_LIST
},
{
'cap' => 0,
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 42,
'desc' => '',
'title' => 'Fixed test options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'fixed',
'unit' => SANE_UNIT_NONE,
'index' => 43,
'desc' =>
'(1/3) Fixed test option with no unit and no constraint set.',
'title' => 'Fixed',
'type' => SANE_TYPE_FIXED,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'fixed-constraint-range',
'index' => 44,
'unit' => SANE_UNIT_MICROSECOND,
'desc' =>
'(2/3) Fixed test option with unit microsecond and constraint range set. Minimum is -42.17, maximum 32767.9999, and quant is 2.0.',
'title' => 'Fixed constraint range',
'type' => SANE_TYPE_FIXED,
'constraint' => {
'min' => '-42.17',
'max' => '32768',
'quant' => '2'
},
constraint_type => SANE_CONSTRAINT_RANGE,
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'fixed-constraint-word-list',
'index' => 45,
'unit' => SANE_UNIT_NONE,
'desc' =>
'(3/3) Fixed test option with no unit and constraint word list set.',
'title' => 'Fixed constraint word list',
'type' => SANE_TYPE_FIXED,
'constraint' => [ '-32.7', '12.1', '42', '129.5' ],
'constraint_type' => SANE_CONSTRAINT_WORD_LIST
},
{
'cap' => '0',
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 46,
'desc' => '',
'title' => 'String test options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'string',
'unit' => SANE_UNIT_NONE,
'index' => 47,
'desc' => '(1/3) String test option without constraint.',
'title' => 'String',
'type' => SANE_TYPE_STRING,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'string-constraint-string-list',
'index' => 48,
'unit' => SANE_UNIT_NONE,
'desc' => '(2/3) String test option with string list constraint.',
'title' => 'String constraint string list',
'type' => SANE_TYPE_STRING,
'constraint' => [
'First entry',
'Second entry',
'This is the very long third entry. Maybe the frontend has an idea how to display it'
],
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '1',
'name' => 'string-constraint-long-string-list',
'index' => 49,
'unit' => SANE_UNIT_NONE,
'desc' =>
'(3/3) String test option with string list constraint. Contains some more entries...',
'title' => 'String constraint long string list',
'type' => SANE_TYPE_STRING,
'constraint' => [
'First entry', 'Second entry', '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'
],
constraint_type => SANE_CONSTRAINT_STRING_LIST,
},
{
'cap' => '0',
'max_values' => '0',
'name' => '',
'unit' => SANE_UNIT_NONE,
'index' => 50,
'desc' => '',
'title' => 'Button test options',
type => SANE_TYPE_GROUP,
'constraint_type' => SANE_CONSTRAINT_NONE
},
{
'cap' => SANE_CAP_SOFT_DETECT +
SANE_CAP_SOFT_SELECT +
SANE_CAP_INACTIVE,
'max_values' => '0',
'name' => 'button',
'unit' => SANE_UNIT_NONE,
'index' => 51,
'desc' => '(1/1) Button test option. Prints some text...',
'title' => 'Button',
'type' => SANE_TYPE_BUTTON,
'constraint_type' => SANE_CONSTRAINT_NONE
},
);
is_deeply( $options->{array}, \@that, 'test' );
is( Gscan2pdf::Scanner::Options->device, 'test:0', 'device name' );
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[1], 'value'
),
undef,
'SANE_CONSTRAINT_NONE'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[2], 'Gray'
),
TRUE,
'SANE_CONSTRAINT_STRING_LIST positive'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[3], 8
),
TRUE,
'SANE_CONSTRAINT_WORD_LIST positive'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[7], 50
),
TRUE,
'SANE_CONSTRAINT_RANGE exact'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[7], 50.1
),
TRUE,
'SANE_CONSTRAINT_RANGE inexact'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[2], 'gray'
),
FALSE,
'SANE_CONSTRAINT_STRING_LIST negative'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[3], 7
),
FALSE,
'SANE_CONSTRAINT_WORD_LIST negative'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[7], 51.1
),
FALSE,
'SANE_CONSTRAINT_RANGE negative'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[4], ''
),
TRUE,
'SANE_TYPE_BOOL positive but empty string instead of 0'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[4], 1
),
FALSE,
'SANE_TYPE_BOOL negative'
);
$options->{array}[36]{val} = '20';
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[36], 20
),
TRUE,
'SANE_TYPE_INT positive'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[36], 21
),
FALSE,
'SANE_TYPE_INT negative'
);
$options->{array}[43]{val} = '20.5';
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[43], 20.5
),
TRUE,
'SANE_TYPE_FIXED positive'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[43], 21
),
FALSE,
'SANE_TYPE_FIXED negative'
);
$options->{array}[47]{val} = '20.5';
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[47], '20.5'
),
TRUE,
'SANE_TYPE_STRING positive'
);
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->{array}[47], '21'
),
FALSE,
'SANE_TYPE_STRING negative'
);
$options = [
undef,
{
'cap' => SANE_CAP_SOFT_SELECT + SANE_CAP_SOFT_DETECT,
'constraint' => {
'max' => '297.179992675781',
'min' => 0,
'quant' => 0
},
'constraint_type' => SANE_CONSTRAINT_RANGE,
'desc' => 'Top Left Y',
'index' => 14,
'max_values' => 1,
'name' => 'tl-y',
'title' => 'Top Left Y',
'type' => SANE_TYPE_FIXED,
'unit' => SANE_UNIT_MM,
'val' => 0.999984741210938
},
];
is(
Gscan2pdf::Scanner::Options::within_tolerance(
$options->[1], 1, 0.001
),
TRUE,
'SANE_CONSTRAINT_RANGE inexact with tolerance'
);
}
|