]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option descriptor for image height
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 18:20:10 +0000 (19:20 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 18:20:10 +0000 (19:20 +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 d9045b6f9fa32af11a1cc826463c8b598585b61e..9add6449500231bcc0f57197d708ea0327bb72a0 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_debug.h"
 
-#define MAX_OPTION_COUNT 42
+#define MAX_OPTION_COUNT 43
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
@@ -1013,6 +1013,30 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_width()
        return descriptor;
 }
 
+SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_height()
+{
+       kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_height");
+
+       SANE_Range* constraint = malloc(sizeof(SANE_Range));
+       constraint->min = 10;
+       constraint->max = 400;
+       constraint->quant = 1;
+
+       SANE_Option_Descriptor descriptor = {
+               "image-height",
+               "Image height",
+               "Image height",
+               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");
@@ -1059,7 +1083,8 @@ void kds_s2000w_option_descriptors_init()
        descriptor_array[38] = _kds_s2000w_option_descriptor_image_offset_x();
        descriptor_array[39] = _kds_s2000w_option_descriptor_image_offset_y();
        descriptor_array[40] = _kds_s2000w_option_descriptor_image_width();
-       descriptor_array[41] = _kds_s2000w_option_descriptor_config_reset();
+       descriptor_array[41] = _kds_s2000w_option_descriptor_image_height();
+       descriptor_array[42] = _kds_s2000w_option_descriptor_config_reset();
 }
 
 void kds_s2000w_option_descriptors_free()
index 345247f1c2902ad8ffb5da482fea7ddf6c44b8a4..54d618125993c6d34cf213d0358e980d3d1709d7 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_client_mock.h"
 #include "../src/kds_s2000w_option_descriptors.h"
 
-#define MAX_OPTION_COUNT 42
+#define MAX_OPTION_COUNT 43
 
 int setup(void** state)
 {
@@ -738,6 +738,23 @@ void kds_s2000w_option_get_descriptor_fourtyone_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(41);
 
+       assert_string_equal("image-height", option->name);
+       assert_string_equal("Image height", option->title);
+       assert_string_equal("Image height", 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, 10);
+       assert_int_equal(option->constraint.range->max, 400);
+       assert_int_equal(option->constraint.range->quant, 1);
+}
+
+void kds_s2000w_option_get_descriptor_fourtytwo_test()
+{
+       SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(42);
+
        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 85ae7ed6619499b0a29768f8d6beb7e424fba979..14682d944ace02627ce02da0891d51ace98df4ba 100644 (file)
@@ -50,6 +50,7 @@ void kds_s2000w_option_get_descriptor_thirdyeight_test();
 void kds_s2000w_option_get_descriptor_thirdynine_test();
 void kds_s2000w_option_get_descriptor_fourty_test();
 void kds_s2000w_option_get_descriptor_fourtyone_test();
+void kds_s2000w_option_get_descriptor_fourtytwo_test();
 void kds_s2000w_option_get_descriptor_get_by_name_test();
 void kds_s2000w_option_get_descriptor_over_max_options_test();
 #endif
\ No newline at end of file
index a75d79b6d7e81dfdfdd32c02792088055d063be5..05fb2f58e720209ac407acb38f8a6c599037d836 100644 (file)
@@ -45,6 +45,7 @@ int main()
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdynine_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_fourty_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_fourtyone_test, setup, teardown),
+               cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_fourtytwo_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_get_by_name_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_over_max_options_test, setup, teardown),
        };