]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option descriptor for cropping mode
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 10:05:15 +0000 (11:05 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 10:05:15 +0000 (11:05 +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 5453cbf5f9e8c0bdcf9f97c851f905df792d6db2..352e46e91cb164ce48d9f8038d6ae751a6570759 100644 (file)
@@ -3,7 +3,7 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_debug.h"
 
-#define MAX_OPTION_COUNT 32
+#define MAX_OPTION_COUNT 33
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
@@ -35,6 +35,7 @@ SANE_String_Const* constraint_image_border = NULL;
 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_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
 {
@@ -752,6 +753,32 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_hole_fill()
        return descriptor;
 }
 
+SANE_Option_Descriptor _kds_s2000w_option_descriptor_cropping_mode()
+{
+       kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_cropping_mode");
+
+       constraint_cropping_mode = malloc(sizeof(SANE_String_Const*) * 5);
+       constraint_cropping_mode[0] = "AutomaticStraighten";
+       constraint_cropping_mode[1] = "Automatic";
+       constraint_cropping_mode[2] = "Photograph";
+       constraint_cropping_mode[3] = "Manual";
+       constraint_cropping_mode[4] = NULL;
+
+       SANE_Option_Descriptor descriptor = {
+               "cropping-mode",
+               "Cropping mode",
+               "Cropping mode",
+               SANE_TYPE_STRING,
+               SANE_UNIT_NONE,
+               sizeof(SANE_String_Const*) * 5,
+               SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
+               SANE_CONSTRAINT_STRING_LIST,
+               {.string_list = constraint_cropping_mode}
+       };
+
+       return descriptor;
+}
+
 void kds_s2000w_option_descriptors_init()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors");
@@ -788,7 +815,8 @@ void kds_s2000w_option_descriptors_init()
        descriptor_array[28] = _kds_s2000w_option_descriptor_jpeg_quality();
        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_config_reset();
+       descriptor_array[31] = _kds_s2000w_option_descriptor_cropping_mode();
+       descriptor_array[32] = _kds_s2000w_option_descriptor_config_reset();
 }
 
 void kds_s2000w_option_descriptors_free()
@@ -833,6 +861,8 @@ void kds_s2000w_option_descriptors_free()
        constraint_jpeg_quality = NULL;
        free(constraint_document_feeder_timeout_response);
        constraint_document_feeder_timeout_response = NULL;
+       free(constraint_cropping_mode);
+       constraint_cropping_mode = NULL;
        free(descriptor_array);
        descriptor_array = NULL;
 }
index 1ef82a25c9b9883fa432280b0e76ac18134da0b6..999fe3bcfba87da61e13837c189380bef2fb6329 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_client_mock.h"
 #include "../src/kds_s2000w_option_descriptors.h"
 
-#define MAX_OPTION_COUNT 32
+#define MAX_OPTION_COUNT 33
 
 int setup(void** state)
 {
@@ -566,6 +566,25 @@ void kds_s2000w_option_get_descriptor_thirdyone_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(31);
 
+       assert_string_equal("cropping-mode", option->name);
+       assert_string_equal("Cropping mode", option->title);
+       assert_string_equal("Cropping mode", 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*) * 5, 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("AutomaticStraighten", option->constraint.string_list[0]);
+       assert_string_equal("Automatic", option->constraint.string_list[1]);
+       assert_string_equal("Photograph", option->constraint.string_list[2]);
+       assert_string_equal("Manual", option->constraint.string_list[3]);
+       assert_null(option->constraint.string_list[4]);
+}
+
+void kds_s2000w_option_get_descriptor_thirdytwo_test()
+{
+       SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(32);
+
        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 c409653bdfc6cc893babecf1bace46142febccc7..961d0fe0610124f8758077867848fdf4f30afd15 100644 (file)
@@ -40,5 +40,6 @@ void kds_s2000w_option_get_descriptor_twentyeight_test();
 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_over_max_options_test();
 #endif
\ No newline at end of file
index 23c3871e2b1557cf9f0666adae8e3069d15ef1a8..0d162abdac38fd841d65010969d089486dfb7a60 100644 (file)
@@ -35,6 +35,7 @@ int main()
                cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentynine_test, setup, teardown),
                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_over_max_options_test, setup, teardown),
 
        };