]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option descriptor for cropping image
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 10:56:22 +0000 (11:56 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 10:56:22 +0000 (11:56 +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 352e46e91cb164ce48d9f8038d6ae751a6570759..534e31a305941c9d2c894e251009fe2924c964f9 100644 (file)
@@ -3,7 +3,7 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_debug.h"
 
-#define MAX_OPTION_COUNT 33
+#define MAX_OPTION_COUNT 34
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
@@ -36,6 +36,7 @@ SANE_String_Const* constraint_transport_handling = NULL;
 SANE_String_Const* constraint_jpeg_quality = NULL;
 SANE_String_Const* constraint_document_feeder_timeout_response = NULL;
 SANE_String_Const* constraint_cropping_mode = NULL;
+SANE_String_Const* constraint_cropping_image = NULL;
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
 {
@@ -779,6 +780,30 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_mode()
        return descriptor;
 }
 
+SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_image()
+{
+       kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_cropping_image");
+
+       constraint_cropping_image = malloc(sizeof(SANE_String_Const*) * 3);
+       constraint_cropping_image[0] = "EntireDocument";
+       constraint_cropping_image[1] = "PartialDocument";
+       constraint_cropping_image[2] = NULL;
+
+       SANE_Option_Descriptor descriptor = {
+               "cropping-image",
+               "Cropping image",
+               "Cropping image",
+               SANE_TYPE_STRING,
+               SANE_UNIT_NONE,
+               sizeof(SANE_String_Const*) * 3,
+               SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
+               SANE_CONSTRAINT_STRING_LIST,
+               {.string_list = constraint_cropping_image}
+       };
+
+       return descriptor;
+}
+
 void kds_s2000w_option_descriptors_init()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors");
@@ -816,7 +841,8 @@ void kds_s2000w_option_descriptors_init()
        descriptor_array[29] = _kds_s2000w_option_descriptor_document_feeder_timeout_response();
        descriptor_array[30] = _kds_s2000w_option_descriptor_hole_fill();
        descriptor_array[31] = _kds_s2000w_option_descriptor_cropping_mode();
-       descriptor_array[32] = _kds_s2000w_option_descriptor_config_reset();
+       descriptor_array[32] = _kds_s2000w_option_descriptor_cropping_image();
+       descriptor_array[33] = _kds_s2000w_option_descriptor_config_reset();
 }
 
 void kds_s2000w_option_descriptors_free()
@@ -863,6 +889,8 @@ void kds_s2000w_option_descriptors_free()
        constraint_document_feeder_timeout_response = NULL;
        free(constraint_cropping_mode);
        constraint_cropping_mode = NULL;
+       free(constraint_cropping_image);
+       constraint_cropping_image = NULL;
        free(descriptor_array);
        descriptor_array = NULL;
 }
index 999fe3bcfba87da61e13837c189380bef2fb6329..19a3435da39cd0b6c083bbc638daffeccb4bc4e1 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_client_mock.h"
 #include "../src/kds_s2000w_option_descriptors.h"
 
-#define MAX_OPTION_COUNT 33
+#define MAX_OPTION_COUNT 34
 
 int setup(void** state)
 {
@@ -585,6 +585,23 @@ void kds_s2000w_option_get_descriptor_thirdytwo_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(32);
 
+       assert_string_equal("cropping-image", option->name);
+       assert_string_equal("Cropping image", option->title);
+       assert_string_equal("Cropping image", option->desc);
+       assert_int_equal(SANE_TYPE_STRING, option->type);
+       assert_int_equal(SANE_UNIT_NONE, option->unit);
+       assert_int_equal(sizeof(SANE_String_Const*) * 3, option->size);
+       assert_int_equal(SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, option->cap);
+       assert_int_equal(SANE_CONSTRAINT_STRING_LIST, option->constraint_type);
+       assert_string_equal("EntireDocument", option->constraint.string_list[0]);
+       assert_string_equal("PartialDocument", option->constraint.string_list[1]);
+       assert_null(option->constraint.string_list[2]);
+}
+
+void kds_s2000w_option_get_descriptor_thirdythree_test()
+{
+       SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(33);
+
        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 961d0fe0610124f8758077867848fdf4f30afd15..533b4b552c4926e056531faf0fce6a15c5f33852 100644 (file)
@@ -41,5 +41,6 @@ void kds_s2000w_option_get_descriptor_twentynine_test();
 void kds_s2000w_option_get_descriptor_thirdy_test();
 void kds_s2000w_option_get_descriptor_thirdyone_test();
 void kds_s2000w_option_get_descriptor_thirdytwo_test();
+void kds_s2000w_option_get_descriptor_thirdythree_test();
 void kds_s2000w_option_get_descriptor_over_max_options_test();
 #endif
\ No newline at end of file
index 0d162abdac38fd841d65010969d089486dfb7a60..b06608ef07287007b92fbc8f37c563a40c947718 100644 (file)
@@ -36,8 +36,8 @@ int main()
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdy_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdyone_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdytwo_test, setup, teardown),
+               cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdythree_test, setup, teardown),
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_over_max_options_test, setup, teardown),
-
        };
 
        return cmocka_run_group_tests(option_descriptor_tests, NULL, NULL);