From 3719fb47c691b46f3e9f4c84bd65d4325abca55f Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Feb 2025 15:37:27 +0100 Subject: [PATCH] add option descriptor for color brigthness --- src/kds_s2000w_option_descriptors.c | 29 +++++++++++++++++-- tests/kds_s2000w_option_descriptor_tests.c | 19 +++++++++++- tests/kds_s2000w_option_descriptor_tests.h | 1 + .../kds_s2000w_option_descriptor_tests_run.c | 1 + 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index d058484..6f9f800 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 35 +#define MAX_OPTION_COUNT 36 SANE_Option_Descriptor* descriptor_array = NULL; @@ -844,6 +844,30 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_skip_blank_page_content() return descriptor; } +SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_brightness() +{ + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_brightness"); + + SANE_Range* constraint = malloc(sizeof(SANE_Range)); + constraint->min = -50; + constraint->max = 50; + constraint->quant = 1; + + SANE_Option_Descriptor descriptor = { + "color-brightness", + "Color brightness", + "Color brightness", + 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"); @@ -883,7 +907,8 @@ void kds_s2000w_option_descriptors_init() descriptor_array[31] = _kds_s2000w_option_descriptor_cropping_mode(); 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_config_reset(); + descriptor_array[34] = _kds_s2000w_option_descriptor_color_brightness(); + descriptor_array[35] = _kds_s2000w_option_descriptor_config_reset(); } void kds_s2000w_option_descriptors_free() diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index 39f201c..573d8a4 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 35 +#define MAX_OPTION_COUNT 36 int setup(void** state) { @@ -619,6 +619,23 @@ void kds_s2000w_option_get_descriptor_thirdyfour_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(34); + assert_string_equal("color-brightness", option->name); + assert_string_equal("Color brightness", option->title); + assert_string_equal("Color brightness", 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, -50); + assert_int_equal(option->constraint.range->max, 50); + assert_int_equal(option->constraint.range->quant, 1); +} + +void kds_s2000w_option_get_descriptor_thirdyfive_test() +{ + SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(35); + 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 4f83d67..1fb133f 100644 --- a/tests/kds_s2000w_option_descriptor_tests.h +++ b/tests/kds_s2000w_option_descriptor_tests.h @@ -43,5 +43,6 @@ 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_thirdyfour_test(); +void kds_s2000w_option_get_descriptor_thirdyfive_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 724bdeb..90a3de0 100644 --- a/tests/kds_s2000w_option_descriptor_tests_run.c +++ b/tests/kds_s2000w_option_descriptor_tests_run.c @@ -38,6 +38,7 @@ int main() 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_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_over_max_options_test, setup, teardown), }; -- 2.39.5