]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option descriptor for max document length
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 14:58:09 +0000 (15:58 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 14:58:09 +0000 (15:58 +0100)
src/kds_s2000w_option_descriptors.c
tests/kds_s2000w_option_descriptor_tests.c
tests/kds_s2000w_option_descriptor_tests.h
tests/kds_s2000w_option_descriptor_tests_run.c

index 6f9f800d4aab7df9e7bc7388ae41f2552235f0f6..974286ad3033b1903b9966ed0912f91fd9abdfd4 100644 (file)
@@ -3,7 +3,7 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_debug.h"
 
-#define MAX_OPTION_COUNT 36
+#define MAX_OPTION_COUNT 37
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
@@ -868,6 +868,30 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_brightness()
        return descriptor;
 }
 
+SANE_Option_Descriptor _kds_s2000w_option_descriptor_max_document_length()
+{
+       kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_max_document_length");
+
+       SANE_Range* constraint = malloc(sizeof(SANE_Range));
+       constraint->min = 25;
+       constraint->max = 400;
+       constraint->quant = 1;
+
+       SANE_Option_Descriptor descriptor = {
+               "max-document-length",
+               "Max document length",
+               "Max document length",
+               SANE_TYPE_INT,
+               SANE_UNIT_NONE,
+               sizeof(SANE_Int),
+               SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
+               SANE_CONSTRAINT_RANGE,
+               {.range = constraint}
+       };
+
+       return descriptor;
+}
+
 void kds_s2000w_option_descriptors_init()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors");
@@ -908,7 +932,8 @@ void kds_s2000w_option_descriptors_init()
        descriptor_array[32] = _kds_s2000w_option_descriptor_cropping_image();
        descriptor_array[33] = _kds_s2000w_option_descriptor_skip_blank_page_content();
        descriptor_array[34] = _kds_s2000w_option_descriptor_color_brightness();
-       descriptor_array[35] = _kds_s2000w_option_descriptor_config_reset();
+       descriptor_array[35] = _kds_s2000w_option_descriptor_max_document_length();
+       descriptor_array[36] = _kds_s2000w_option_descriptor_config_reset();
 }
 
 void kds_s2000w_option_descriptors_free()
index 573d8a4412f2d63bc018c19c22fed1f688bbf7e8..1d2e3751dbe02d58d38ca64f78769d6d5028d6d0 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_client_mock.h"
 #include "../src/kds_s2000w_option_descriptors.h"
 
-#define MAX_OPTION_COUNT 36
+#define MAX_OPTION_COUNT 37
 
 int setup(void** state)
 {
@@ -636,6 +636,23 @@ void kds_s2000w_option_get_descriptor_thirdyfive_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(35);
 
+       assert_string_equal("max-document-length", option->name);
+       assert_string_equal("Max document length", option->title);
+       assert_string_equal("Max document length", option->desc);
+       assert_int_equal(SANE_TYPE_INT, option->type);
+       assert_int_equal(SANE_UNIT_NONE, option->unit);
+       assert_int_equal(sizeof(SANE_Int), option->size);
+       assert_int_equal(SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, option->cap);
+       assert_int_equal(SANE_CONSTRAINT_RANGE, option->constraint_type);
+       assert_int_equal(option->constraint.range->min, 25);
+       assert_int_equal(option->constraint.range->max, 400);
+       assert_int_equal(option->constraint.range->quant, 1);
+}
+
+void kds_s2000w_option_get_descriptor_thirdysix_test()
+{
+       SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(36);
+
        assert_string_equal("config-reset", option->name);
        assert_string_equal("reset config", option->title);
        assert_string_equal("load default configuration from scanner", option->desc);
index 1fb133f08fa8f323ad503303b58eb1496b56929c..f08c7675e07b61ccbdc85402b1180777021eb106 100644 (file)
@@ -44,5 +44,6 @@ void kds_s2000w_option_get_descriptor_thirdytwo_test();
 void kds_s2000w_option_get_descriptor_thirdythree_test();
 void kds_s2000w_option_get_descriptor_thirdyfour_test();
 void kds_s2000w_option_get_descriptor_thirdyfive_test();
+void kds_s2000w_option_get_descriptor_thirdysix_test();
 void kds_s2000w_option_get_descriptor_over_max_options_test();
 #endif
\ No newline at end of file
index 90a3de00a3aa979f037c4507ac5948d1c6751d05..eaac382fc0d153571bae29d19a6c8d110fa233d0 100644 (file)
@@ -39,6 +39,7 @@ int main()
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdythree_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdyfour_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdyfive_test, setup, teardown),
+               cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdysix_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_over_max_options_test, setup, teardown),
        };