From: Bastian Dehn Date: Sun, 16 Feb 2025 17:47:06 +0000 (+0100) Subject: add option descriptor image offset x X-Git-Tag: v1.1.0^2~4^2~7 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=0c0b5b1874a75cef6c39dc444ca7b5ca5b52bd9a;p=sane-kds-s2000w-net.git add option descriptor image offset x --- diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index 878ecaf..859a5d9 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -4,7 +4,7 @@ #include "kds_s2000w_option_descriptors.h" #include "kds_s2000w_debug.h" -#define MAX_OPTION_COUNT 39 +#define MAX_OPTION_COUNT 40 SANE_Option_Descriptor* descriptor_array = NULL; @@ -895,7 +895,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_max_document_length() SANE_Option_Descriptor _kds_s2000w_option_descriptor_document_feeder_timeout() { - kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_max_document_length"); + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_document_feeder_timeout"); SANE_Range* constraint = malloc(sizeof(SANE_Range)); constraint->min = 0; @@ -919,7 +919,7 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_document_feeder_timeout() SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_contrast() { - kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_max_document_length"); + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_color_contrast"); SANE_Range* constraint = malloc(sizeof(SANE_Range)); constraint->min = -50; @@ -941,6 +941,30 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_color_contrast() return descriptor; } +SANE_Option_Descriptor _kds_s2000w_option_descriptor_image_offset_x() +{ + kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_image_offset_x"); + + SANE_Range* constraint = malloc(sizeof(SANE_Range)); + constraint->min = 0; + constraint->max = 75; + constraint->quant = 1; + + SANE_Option_Descriptor descriptor = { + "image-offset-x", + "Image offset x", + "Image offset x", + 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"); @@ -984,7 +1008,8 @@ void kds_s2000w_option_descriptors_init() descriptor_array[35] = _kds_s2000w_option_descriptor_max_document_length(); descriptor_array[36] = _kds_s2000w_option_descriptor_document_feeder_timeout(); descriptor_array[37] = _kds_s2000w_option_descriptor_color_contrast(); - descriptor_array[38] = _kds_s2000w_option_descriptor_config_reset(); + descriptor_array[38] = _kds_s2000w_option_descriptor_image_offset_x(); + descriptor_array[39] = _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 1e52ebb..1bf25a8 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 39 +#define MAX_OPTION_COUNT 40 int setup(void** state) { @@ -687,6 +687,23 @@ void kds_s2000w_option_get_descriptor_thirdyeight_test() { SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(38); + assert_string_equal("image-offset-x", option->name); + assert_string_equal("Image offset x", option->title); + assert_string_equal("Image offset x", 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, 0); + assert_int_equal(option->constraint.range->max, 75); + assert_int_equal(option->constraint.range->quant, 1); +} + +void kds_s2000w_option_get_descriptor_thirdynine_test() +{ + SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(39); + 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 08823e5..a8d800e 100644 --- a/tests/kds_s2000w_option_descriptor_tests.h +++ b/tests/kds_s2000w_option_descriptor_tests.h @@ -47,6 +47,7 @@ void kds_s2000w_option_get_descriptor_thirdyfive_test(); void kds_s2000w_option_get_descriptor_thirdysix_test(); void kds_s2000w_option_get_descriptor_thirdyseven_test(); void kds_s2000w_option_get_descriptor_thirdyeight_test(); +void kds_s2000w_option_get_descriptor_thirdynine_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 diff --git a/tests/kds_s2000w_option_descriptor_tests_run.c b/tests/kds_s2000w_option_descriptor_tests_run.c index 160e0fd..f207587 100644 --- a/tests/kds_s2000w_option_descriptor_tests_run.c +++ b/tests/kds_s2000w_option_descriptor_tests_run.c @@ -42,6 +42,7 @@ int main() cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdysix_test, setup, teardown), cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdyseven_test, setup, teardown), cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdyeight_test, setup, teardown), + cmocka_unit_test_setup_teardown(kds_s2000w_option_get_descriptor_thirdynine_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), };