From 363f927b3afbf1c33d112275d78f3de0578a03b1 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Wed, 1 May 2024 08:25:39 +0200 Subject: [PATCH] remove depth option --- src/kds_s2000w_handler_opts.c | 76 ++++++++++-------------- src/kds_s2000w_option_descriptors.c | 54 ++++++----------- src/kds_s2000w_option_descriptors.h | 2 +- tests/kds_s2000w_net_get_opt_tests.c | 59 +++++++----------- tests/kds_s2000w_net_get_opt_tests.h | 5 +- tests/kds_s2000w_net_get_opt_tests_run.c | 5 +- 6 files changed, 75 insertions(+), 126 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 2eb991a..3691d85 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -6,7 +6,7 @@ #include "kds_s2000w_debug.h" #define AUTOSTART_ALWAYS_ON 1 -#define COUNT_CUSTOM_OPTIONS 2 +#define COUNT_CUSTOM_OPTIONS 1 void _write_string_value(json_object* value_object, void* value) { @@ -103,68 +103,63 @@ void kds_s2000w_handler_get_option(handler* h, int option, void* value, int* inf value_object = json_object_object_get(config, "ScanSide"); _write_string_value(value_object, value); break; - case 6: - int depth = h->current_metadata->depth; - int* int_value = (int*) value; - *int_value = depth; - break; - case 8: + case 7: value_object = json_object_object_get(config, "SkipBlankPages"); _write_int_value(value_object, value); break; - case 9: + case 8: value_object = json_object_object_get(config, "ColorDropOut"); _write_string_value(value_object, value); break; - case 10: + case 9: value_object = json_object_object_get(config, "ColorDropOutAggressiveness"); _write_int_value(value_object, value); break; - case 11: + case 10: value_object = json_object_object_get(config, "ColorAutoBrightnessMode"); _write_string_value(value_object, value); break; - case 12: + case 11: value_object = json_object_object_get(config, "ColorBalanceMode"); _write_string_value(value_object, value); break; - case 13: + case 12: value_object = json_object_object_get(config, "ColorBalanceAggressiveness"); _write_int_value(value_object, value); break; - case 14: + case 13: value_object = json_object_object_get(config, "ColorBalanceRed"); _write_int_value(value_object, value); break; - case 15: + case 14: value_object = json_object_object_get(config, "ColorBalanceGreen"); _write_int_value(value_object, value); break; - case 16: + case 15: value_object = json_object_object_get(config, "ColorBalanceBlue"); _write_int_value(value_object, value); break; - case 17: + case 16: value_object = json_object_object_get(config, "ForegroundBoldnessMode"); _write_string_value(value_object, value); break; - case 18: + case 17: value_object = json_object_object_get(config, "ForegroundBoldnessAggressiveness"); _write_int_value(value_object, value); break; - case 19: + case 18: value_object = json_object_object_get(config, "BackgroundSmoothingMode"); _write_string_value(value_object, value); break; - case 20: + case 19: value_object = json_object_object_get(config, "BackgroundSmoothingAggressiveness"); _write_int_value(value_object, value); break; - case 21: + case 20: value_object = json_object_object_get(config, "BinarizationContrast"); _write_int_value(value_object, value); break; - case 22: + case 21: value_object = json_object_object_get(config, "MaxDocumentLength"); _write_int_value(value_object, value); break; @@ -246,75 +241,68 @@ void kds_s2000w_handler_set_option(handler* h, int option, void* value, int* inf _write_string_value_to_json(value_object, value); value_object = NULL; break; - case 6: - int* int_value = (int*) value; - h->current_metadata->depth = *int_value; - if (info != NULL) - *info = RELOAD_PARAMS; - - break; - case 8: + case 7: value_object = json_object_object_get(config, "SkipBlankPages"); _write_int_value_to_json(value_object, value); value_object = NULL; break; - case 9: + case 8: value_object = json_object_object_get(config, "ColorDropOut"); _write_string_value_to_json(value_object, value); break; - case 10: + case 9: value_object = json_object_object_get(config, "ColorDropOutAggressiveness"); _write_int_value_to_json(value_object, value); break; - case 11: + case 10: value_object = json_object_object_get(config, "ColorAutoBrightnessMode"); _write_string_value_to_json(value_object, value); break; - case 12: + case 11: value_object = json_object_object_get(config, "ColorBalanceMode"); _write_string_value_to_json(value_object, value); break; - case 13: + case 12: value_object = json_object_object_get(config, "ColorBalanceAggressiveness"); _write_int_value_to_json(value_object, value); break; - case 14: + case 13: value_object = json_object_object_get(config, "ColorBalanceRed"); _write_int_value_to_json(value_object, value); break; - case 15: + case 14: value_object = json_object_object_get(config, "ColorBalanceGreen"); _write_int_value_to_json(value_object, value); break; - case 16: + case 15: value_object = json_object_object_get(config, "ColorBalanceBlue"); _write_int_value_to_json(value_object, value); break; - case 17: + case 16: value_object = json_object_object_get(config, "ForegroundBoldnessMode"); _write_string_value_to_json(value_object, value); break; - case 18: + case 17: value_object = json_object_object_get(config, "ForegroundBoldnessAggressiveness"); _write_int_value_to_json(value_object, value); break; - case 19: + case 18: value_object = json_object_object_get(config, "BackgroundSmoothingMode"); _write_string_value_to_json(value_object, value); break; - case 20: + case 19: value_object = json_object_object_get(config, "BackgroundSmoothingAggressiveness"); _write_int_value_to_json(value_object, value); break; - case 21: + case 20: value_object = json_object_object_get(config, "BinarizationContrast"); _write_int_value_to_json(value_object, value); break; - case 22: + case 21: value_object = json_object_object_get(config, "MaxDocumentLength"); _write_int_value_to_json(value_object, value); break; - case 23: + case 22: resp = kds_s2000w_client_response_init(); kds_s2000w_client_get_capabilities(resp); capabilities = json_tokener_parse(resp->data); diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index 69b00e6..a2bb6bd 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -6,7 +6,6 @@ SANE_Option_Descriptor descriptor_array[MAX_OPTION_COUNT]; SANE_Word constraint_dpi[] = {2, 200, 300}; -SANE_Word constraint_depth[] = {2, 1, 8}; SANE_Range constraint_binarization_contrast = {-50, 50, 1}; SANE_Range constraint_background_smoothing_aggressivness = {-10, 10, 1}; SANE_Range constraint_color_drop_out_aggressiveness_range = {-10, 10, 1}; @@ -482,24 +481,6 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_config_reset() return descriptor; } -SANE_Option_Descriptor _kds_s2000w_option_descriptor_depth() -{ - debug_printf(ALL, "kds_s2000w_option_descriptor_depth"); - SANE_Option_Descriptor descriptor; - - descriptor.name = SANE_NAME_BIT_DEPTH; - descriptor.title = SANE_TITLE_BIT_DEPTH; - descriptor.desc = SANE_DESC_BIT_DEPTH; - descriptor.cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; - descriptor.constraint_type = SANE_CONSTRAINT_WORD_LIST; - descriptor.constraint.word_list = constraint_depth; - descriptor.type = SANE_TYPE_INT; - descriptor.unit = SANE_UNIT_NONE; - descriptor.size = sizeof(SANE_Int); - - return descriptor; -} - void kds_s2000w_option_descriptor_init_option_descriptors() { debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors"); @@ -510,24 +491,23 @@ void kds_s2000w_option_descriptor_init_option_descriptors() descriptor_array[3] = _kds_s2000w_option_descriptor_color_mode(); descriptor_array[4] = _kds_s2000w_option_descriptor_dpi(); descriptor_array[5] = _kds_s2000w_option_descriptor_scanside(); - descriptor_array[6] = _kds_s2000w_option_descriptor_depth(); - descriptor_array[7] = _kds_s2000w_option_descriptor_geometry_group(); - descriptor_array[8] = _kds_s2000w_option_descriptor_skip_blank_pages(); - descriptor_array[9] = _kds_s2000w_option_descriptor_color_drop(); - descriptor_array[10] = _kds_s2000w_option_descriptor_color_drop_out_aggressiveness(); - descriptor_array[11] = _kds_s2000w_option_descriptor_color_auto_brightness_mode(); - descriptor_array[12] = _kds_s2000w_option_descriptor_color_balance_mode(); - descriptor_array[13] = _kds_s2000w_option_descriptor_color_balancea_agressiveness(); - descriptor_array[14] = _kds_s2000w_option_descriptor_color_balance_red(); - descriptor_array[15] = _kds_s2000w_option_descriptor_color_balance_green(); - descriptor_array[16] = _kds_s2000w_option_descriptor_color_balance_blue(); - descriptor_array[17] = _kds_s2000w_option_descriptor_foreground_boldness_mode(); - descriptor_array[18] = _kds_s2000w_option_descriptor_foreground_boldness_aggressiveness(); - descriptor_array[19] = _kds_s2000w_option_descriptor_background_smoothing_mode(); - descriptor_array[20] = _kds_s2000w_option_descriptor_background_smoothing_aggressiveness(); - descriptor_array[21] = _kds_s2000w_option_descriptor_binarization_contrast(); - descriptor_array[22] = _kds_s2000w_option_descriptor_max_document_length(); - descriptor_array[23] = _kds_s2000w_option_descriptor_config_reset(); + descriptor_array[6] = _kds_s2000w_option_descriptor_geometry_group(); + descriptor_array[7] = _kds_s2000w_option_descriptor_skip_blank_pages(); + descriptor_array[8] = _kds_s2000w_option_descriptor_color_drop(); + descriptor_array[9] = _kds_s2000w_option_descriptor_color_drop_out_aggressiveness(); + descriptor_array[10] = _kds_s2000w_option_descriptor_color_auto_brightness_mode(); + descriptor_array[11] = _kds_s2000w_option_descriptor_color_balance_mode(); + descriptor_array[12] = _kds_s2000w_option_descriptor_color_balancea_agressiveness(); + descriptor_array[13] = _kds_s2000w_option_descriptor_color_balance_red(); + descriptor_array[14] = _kds_s2000w_option_descriptor_color_balance_green(); + descriptor_array[15] = _kds_s2000w_option_descriptor_color_balance_blue(); + descriptor_array[16] = _kds_s2000w_option_descriptor_foreground_boldness_mode(); + descriptor_array[17] = _kds_s2000w_option_descriptor_foreground_boldness_aggressiveness(); + descriptor_array[18] = _kds_s2000w_option_descriptor_background_smoothing_mode(); + descriptor_array[19] = _kds_s2000w_option_descriptor_background_smoothing_aggressiveness(); + descriptor_array[20] = _kds_s2000w_option_descriptor_binarization_contrast(); + descriptor_array[21] = _kds_s2000w_option_descriptor_max_document_length(); + descriptor_array[22] = _kds_s2000w_option_descriptor_config_reset(); } void kds_s2000w_option_descriptor_free_option_descriptors() diff --git a/src/kds_s2000w_option_descriptors.h b/src/kds_s2000w_option_descriptors.h index 0c3cf97..cede6bd 100644 --- a/src/kds_s2000w_option_descriptors.h +++ b/src/kds_s2000w_option_descriptors.h @@ -2,7 +2,7 @@ #define KDS_S2000W_OPTION_DESCRIPTORS_H #include -#define MAX_OPTION_COUNT 24 +#define MAX_OPTION_COUNT 23 void kds_s2000w_option_descriptor_init_option_descriptors(); void kds_s2000w_option_descriptor_free_option_descriptors(); diff --git a/tests/kds_s2000w_net_get_opt_tests.c b/tests/kds_s2000w_net_get_opt_tests.c index 5e7c327..76d8eec 100644 --- a/tests/kds_s2000w_net_get_opt_tests.c +++ b/tests/kds_s2000w_net_get_opt_tests.c @@ -111,18 +111,18 @@ void sane_kds_s2000w_net_control_get_option_five(void** state) h = NULL; } -void sane_kds_s2000w_net_control_get_option_six(void** state) +void sane_kds_s2000w_net_control_get_option_seven(void** state) { response* resp = (response*) *state; will_return(mock_response, resp); will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - int value = 0; + int value = -1; - _sane_kds_s2000w_net_control_option(h, 6, SANE_ACTION_GET_VALUE, &value, NULL); + _sane_kds_s2000w_net_control_option(h, 7, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 8); + assert_int_equal(value, 0); free_handler(h); h = NULL; @@ -135,11 +135,11 @@ void sane_kds_s2000w_net_control_get_option_eight(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - int value = -1; + char value[50] = {0}; _sane_kds_s2000w_net_control_option(h, 8, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 0); + assert_string_equal(value, "None"); free_handler(h); h = NULL; @@ -152,11 +152,11 @@ void sane_kds_s2000w_net_control_get_option_nine(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - char value[50] = {0}; + int value = -1; _sane_kds_s2000w_net_control_option(h, 9, SANE_ACTION_GET_VALUE, &value, NULL); - assert_string_equal(value, "None"); + assert_int_equal(value, 0); free_handler(h); h = NULL; @@ -169,11 +169,11 @@ void sane_kds_s2000w_net_control_get_option_ten(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - int value = -1; + char value[50] = {0}; _sane_kds_s2000w_net_control_option(h, 10, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 0); + assert_string_equal(value, "Automatic"); free_handler(h); h = NULL; @@ -203,17 +203,17 @@ void sane_kds_s2000w_net_control_get_option_twelve(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - char value[50] = {0}; + int value = -1; _sane_kds_s2000w_net_control_option(h, 12, SANE_ACTION_GET_VALUE, &value, NULL); - assert_string_equal(value, "Automatic"); + assert_int_equal(value, 0); free_handler(h); h = NULL; } -void sane_kds_s2000w_net_control_get_option_thirteen(void** state) +void sane_kds_s2000w_net_control_get_option_thirdteen(void** state) { response* resp = (response*) *state; will_return(mock_response, resp); @@ -271,11 +271,11 @@ void sane_kds_s2000w_net_control_get_option_sixteen(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - int value = -1; + char value[50] = {0}; _sane_kds_s2000w_net_control_option(h, 16, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 0); + assert_string_equal(value, "None"); free_handler(h); h = NULL; @@ -288,11 +288,11 @@ void sane_kds_s2000w_net_control_get_option_seventeen(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - char value[50] = {0}; + int value = -1; _sane_kds_s2000w_net_control_option(h, 17, SANE_ACTION_GET_VALUE, &value, NULL); - assert_string_equal(value, "None"); + assert_int_equal(value, 0); free_handler(h); h = NULL; @@ -305,11 +305,11 @@ void sane_kds_s2000w_net_control_get_option_eightteen(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - int value = -1; + char value[50] = {0}; _sane_kds_s2000w_net_control_option(h, 18, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 0); + assert_string_equal(value, "None"); free_handler(h); h = NULL; @@ -322,11 +322,11 @@ void sane_kds_s2000w_net_control_get_option_nineteen(void** state) will_return(__wrap_kds_s2000w_client_get_option, 0); expect_function_call(__wrap_kds_s2000w_client_get_option); handler* h = init_handler(); - char value[50] = {0}; + int value = -1; _sane_kds_s2000w_net_control_option(h, 19, SANE_ACTION_GET_VALUE, &value, NULL); - assert_string_equal(value, "None"); + assert_int_equal(value, 0); free_handler(h); h = NULL; @@ -360,23 +360,6 @@ void sane_kds_s2000w_net_control_get_option_twentyone(void** state) _sane_kds_s2000w_net_control_option(h, 21, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 0); - - free_handler(h); - h = NULL; -} - -void sane_kds_s2000w_net_control_get_option_twentytwo(void** state) -{ - response* resp = (response*) *state; - will_return(mock_response, resp); - will_return(__wrap_kds_s2000w_client_get_option, 0); - expect_function_call(__wrap_kds_s2000w_client_get_option); - handler* h = init_handler(); - int value = -1; - - _sane_kds_s2000w_net_control_option(h, 22, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 140); free_handler(h); diff --git a/tests/kds_s2000w_net_get_opt_tests.h b/tests/kds_s2000w_net_get_opt_tests.h index 293fd40..84fa4e2 100644 --- a/tests/kds_s2000w_net_get_opt_tests.h +++ b/tests/kds_s2000w_net_get_opt_tests.h @@ -11,13 +11,13 @@ void sane_kds_s2000w_net_control_get_option_two(void** state); void sane_kds_s2000w_net_control_get_option_three(void** state); void sane_kds_s2000w_net_control_get_option_four(void** state); void sane_kds_s2000w_net_control_get_option_five(void** state); -void sane_kds_s2000w_net_control_get_option_six(void** state); +void sane_kds_s2000w_net_control_get_option_seven(void** state); void sane_kds_s2000w_net_control_get_option_eight(void** state); void sane_kds_s2000w_net_control_get_option_nine(void** state); void sane_kds_s2000w_net_control_get_option_ten(void** state); void sane_kds_s2000w_net_control_get_option_eleven(void** state); void sane_kds_s2000w_net_control_get_option_twelve(void** state); -void sane_kds_s2000w_net_control_get_option_thirteen(void** state); +void sane_kds_s2000w_net_control_get_option_thirdteen(void** state); void sane_kds_s2000w_net_control_get_option_fourteen(void** state); void sane_kds_s2000w_net_control_get_option_fifteen(void** state); void sane_kds_s2000w_net_control_get_option_sixteen(void** state); @@ -26,6 +26,5 @@ void sane_kds_s2000w_net_control_get_option_eightteen(void** state); void sane_kds_s2000w_net_control_get_option_nineteen(void** state); void sane_kds_s2000w_net_control_get_option_twenty(void** state); void sane_kds_s2000w_net_control_get_option_twentyone(void** state); -void sane_kds_s2000w_net_control_get_option_twentytwo(void** state); #endif \ No newline at end of file diff --git a/tests/kds_s2000w_net_get_opt_tests_run.c b/tests/kds_s2000w_net_get_opt_tests_run.c index afa1041..f9c93e3 100644 --- a/tests/kds_s2000w_net_get_opt_tests_run.c +++ b/tests/kds_s2000w_net_get_opt_tests_run.c @@ -65,13 +65,13 @@ int main() cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_three, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_four, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_five, setup_default_get_option, teardown_default_get_option), - cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_six, setup_default_get_option, teardown_default_get_option), + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_seven, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_eight, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_nine, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_ten, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_eleven, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twelve, setup_default_get_option, teardown_default_get_option), - cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirteen, setup_default_get_option, teardown_default_get_option), + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdteen, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_fourteen, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_fifteen, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_sixteen, setup_default_get_option, teardown_default_get_option), @@ -80,7 +80,6 @@ int main() cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_nineteen, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twenty, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twentyone, setup_default_get_option, teardown_default_get_option), - cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twentytwo, setup_default_get_option, teardown_default_get_option), }; return cmocka_run_group_tests(net_tests, NULL, NULL); -- 2.39.5