From e6ee329973d73fa12e8e99f4456363467d47a7ba Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Feb 2025 11:09:31 +0100 Subject: [PATCH] add option cropping mode --- src/kds_s2000w_handler_opts.c | 10 +++++++++- tests/kds_s2000w_net_get_opt_tests.c | 17 ++++++++++++++++- tests/kds_s2000w_net_get_opt_tests.h | 1 + tests/kds_s2000w_net_get_opt_tests_run.c | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 7aef458..74d813d 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -5,7 +5,7 @@ #include "kds_s2000w_debug.h" #define AUTOSTART_ON 1 -#define OPTION_COUNT 32 +#define OPTION_COUNT 33 void _kds_s2000w_handler_opts_write_string_value(json_object* value_object, void* value) { @@ -237,6 +237,10 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value value_object = json_object_object_get(config, "HoleFill"); _kds_s2000w_handler_opts_write_int_value(value_object, value); break; + case 31: + value_object = json_object_object_get(config, "CroppingMode"); + _kds_s2000w_handler_opts_write_string_value(value_object, value); + break; default: break; } @@ -386,6 +390,10 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value value_object = NULL; break; case 31: + value_object = json_object_object_get(config, "CroppingMode"); + _kds_s2000w_handler_opts_write_string_value_to_json(value_object, value); + break; + case 32: _kds_s2000w_handler_opts_set_option_to_default(h); _kds_s2000w_handler_opts_set_autostart_on(h); diff --git a/tests/kds_s2000w_net_get_opt_tests.c b/tests/kds_s2000w_net_get_opt_tests.c index a23b5e7..84399c8 100644 --- a/tests/kds_s2000w_net_get_opt_tests.c +++ b/tests/kds_s2000w_net_get_opt_tests.c @@ -21,7 +21,7 @@ void sane_kds_s2000w_net_control_get_option_zero_test(void** state) sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 32); + assert_int_equal(value, 33); kds_s2000w_handler_free(h); h = NULL; @@ -444,6 +444,21 @@ void sane_kds_s2000w_net_control_get_option_thirdy_test(void** state) assert_int_equal(value, 0); + kds_s2000w_handler_free(h); + h = NULL; +} + +void sane_kds_s2000w_net_control_get_option_thirdyone_test(void** state) +{ + handler* h = kds_s2000w_handler_init(); + response* resp = (response*) *state; + h->current_scanner_config = json_tokener_parse(resp->data); + char value[50] = {0}; + + sane_kds_s2000w_net_control_option(h, 31, SANE_ACTION_GET_VALUE, &value, NULL); + + assert_string_equal(value, "AutomaticStraighten"); + kds_s2000w_handler_free(h); h = NULL; } \ No newline at end of file diff --git a/tests/kds_s2000w_net_get_opt_tests.h b/tests/kds_s2000w_net_get_opt_tests.h index 1510b4e..ad55d2e 100644 --- a/tests/kds_s2000w_net_get_opt_tests.h +++ b/tests/kds_s2000w_net_get_opt_tests.h @@ -35,5 +35,6 @@ void sane_kds_s2000w_net_control_get_option_twentyseven_test(void** state); void sane_kds_s2000w_net_control_get_option_twentyeight_test(void** state); void sane_kds_s2000w_net_control_get_option_twentynine_test(void** state); void sane_kds_s2000w_net_control_get_option_thirdy_test(void** state); +void sane_kds_s2000w_net_control_get_option_thirdyone_test(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 36bcbba..abe677e 100644 --- a/tests/kds_s2000w_net_get_opt_tests_run.c +++ b/tests/kds_s2000w_net_get_opt_tests_run.c @@ -104,7 +104,8 @@ int main() cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twentyseven_test, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twentyeight_test, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_twentynine_test, setup_default_get_option, teardown_default_get_option), - cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdy_test, setup_default_get_option, teardown_default_get_option) + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdy_test, setup_default_get_option, teardown_default_get_option), + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyone_test, setup_default_get_option, teardown_default_get_option) }; return cmocka_run_group_tests(net_tests, NULL, NULL); -- 2.39.5