From f32b8003e53a858d21ef4b5b67d6669301092110 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Feb 2025 08:58:13 +0100 Subject: [PATCH] add option descriptor for edge fill --- src/kds_s2000w_option_descriptors.c | 33 +++++++++++++++++-- tests/kds_s2000w_option_descriptor_tests.c | 20 ++++++++++- tests/kds_s2000w_option_descriptor_tests.h | 2 ++ .../kds_s2000w_option_descriptor_tests_run.c | 2 ++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index ebba09a..1bd3617 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -3,7 +3,7 @@ #include "kds_s2000w_option_descriptors.h" #include "kds_s2000w_debug.h" -#define MAX_OPTION_COUNT 26 +#define MAX_OPTION_COUNT 27 SANE_Option_Descriptor* descriptor_array = NULL; @@ -30,6 +30,7 @@ SANE_String_Const* constraint_color_sharpen = NULL; SANE_String_Const* constraint_multifeed_sensitivity = NULL; SANE_String_Const* constraint_multifeed_response = NULL; SANE_String_Const* constraint_post_scan_rotation = NULL; +SANE_String_Const* constraint_edge_fill = NULL; SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group() { @@ -600,6 +601,31 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_post_scan_rotation() return descriptor; } +SANE_Option_Descriptor _kds_s2000w_option_descriptor_edge_fill() +{ + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_post_scan_rotation"); + + constraint_edge_fill = malloc(sizeof(SANE_String_Const*) * 4); + constraint_edge_fill[0] = "None"; + constraint_edge_fill[1] = "Automatic"; + constraint_edge_fill[2] = "AutomaticIncludeTears"; + constraint_edge_fill[3] = NULL; + + SANE_Option_Descriptor descriptor = { + "edge-fill", + "Edge Fill", + "Edge Fill", + SANE_TYPE_STRING, + SANE_UNIT_NONE, + sizeof(SANE_String_Const*) * 4, + SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, + SANE_CONSTRAINT_STRING_LIST, + {.string_list = constraint_edge_fill} + }; + + return descriptor; +} + void kds_s2000w_option_descriptors_init() { kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors"); @@ -630,7 +656,8 @@ void kds_s2000w_option_descriptors_init() descriptor_array[22] = _kds_s2000w_option_descriptor_multifeed_sensitivity(); descriptor_array[23] = _kds_s2000w_option_descriptor_multifeed_response(); descriptor_array[24] = _kds_s2000w_option_descriptor_post_scan_rotation(); - descriptor_array[25] = _kds_s2000w_option_descriptor_config_reset(); + descriptor_array[25] = _kds_s2000w_option_descriptor_edge_fill(); + descriptor_array[26] = _kds_s2000w_option_descriptor_config_reset(); } void kds_s2000w_option_descriptors_free() @@ -665,6 +692,8 @@ void kds_s2000w_option_descriptors_free() constraint_multifeed_response = NULL; free(constraint_post_scan_rotation); constraint_post_scan_rotation = NULL; + free(constraint_edge_fill); + constraint_edge_fill = NULL; free(descriptor_array); descriptor_array = NULL; } diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index abaf57e..ce423ca 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -4,7 +4,7 @@ #include "kds_s2000w_client_mock.h" #include "../src/kds_s2000w_option_descriptors.h" -#define MAX_OPTION_COUNT 26 +#define MAX_OPTION_COUNT 27 int setup(void** state) { @@ -459,6 +459,24 @@ void kds_s2000w_option_get_descriptor_twentyfive_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(25); + assert_string_equal("edge-fill", option->name); + assert_string_equal("Edge Fill", option->title); + assert_string_equal("Edge Fill", 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*) * 4, 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("None", option->constraint.string_list[0]); + assert_string_equal("Automatic", option->constraint.string_list[1]); + assert_string_equal("AutomaticIncludeTears", option->constraint.string_list[2]); + assert_null(option->constraint.string_list[3]); +} + +void kds_s2000w_option_get_descriptor_twentysix_test() +{ + SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(26); + assert_string_equal("config-reset", option->name); assert_string_equal("reset config", option->title); assert_string_equal("load default configuration from scanner", option->desc); diff --git a/tests/kds_s2000w_option_descriptor_tests.h b/tests/kds_s2000w_option_descriptor_tests.h index 6136353..a4d1382 100644 --- a/tests/kds_s2000w_option_descriptor_tests.h +++ b/tests/kds_s2000w_option_descriptor_tests.h @@ -33,5 +33,7 @@ void kds_s2000w_option_get_descriptor_twentyone_test(); void kds_s2000w_option_get_descriptor_twentytwo_test(); void kds_s2000w_option_get_descriptor_twentythree_test(); void kds_s2000w_option_get_descriptor_twentyfour_test(); +void kds_s2000w_option_get_descriptor_twentyfive_test(); +void kds_s2000w_option_get_descriptor_twentysix_test(); void kds_s2000w_option_get_descriptor_over_max_options_test(); #endif \ No newline at end of file diff --git a/tests/kds_s2000w_option_descriptor_tests_run.c b/tests/kds_s2000w_option_descriptor_tests_run.c index 958baab..ccb25b2 100644 --- a/tests/kds_s2000w_option_descriptor_tests_run.c +++ b/tests/kds_s2000w_option_descriptor_tests_run.c @@ -28,6 +28,8 @@ int main() cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentytwo_test, setup, teardown), cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentythree_test, setup, teardown), cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentyfour_test, setup, teardown), + cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentyfive_test, setup, teardown), + cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_twentysix_test, setup, teardown), cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_over_max_options_test, setup, teardown) }; -- 2.39.5