From: Bastian Dehn Date: Sun, 26 Oct 2025 09:04:00 +0000 (+0100) Subject: add test for cropping mode X-Git-Tag: v1.1.17^2~18 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=97f81f778297e1f99f5a4078458e07219f8aa41a;p=sane-kds-s2000w-net.git add test for cropping mode --- diff --git a/tests/kds_s2000w_net_set_opt_tests.c b/tests/kds_s2000w_net_set_opt_tests.c index 9b28906..232dbf3 100644 --- a/tests/kds_s2000w_net_set_opt_tests.c +++ b/tests/kds_s2000w_net_set_opt_tests.c @@ -517,6 +517,43 @@ void kds_s2000w_net_set_invalid_option_int_word_list_test(void** state) set_value = NULL; } +void kds_s2000w_net_set_option_cropping_mode_and_deps(void** state) +{ + int32_t* info = malloc(sizeof(int32_t)); + if (info == NULL) + return; + + response_t** responses = (response_t**) *state; + handler_t* h = kds_s2000w_handler_init(); + h->profile = PROFILE_FULL; + *info = 0; + + will_return(mock_response, responses[0]); + will_return(__wrap_kds_s2000w_client_get_option, 0); + will_return(mock_response, responses[1]); + will_return(__wrap_kds_s2000w_client_set_option, 0); + will_return(mock_response, responses[1]); + will_return(__wrap_kds_s2000w_client_set_option, 0); + expect_function_call(__wrap_kds_s2000w_client_get_option); + expect_function_call(__wrap_kds_s2000w_client_set_option); + expect_function_call(__wrap_kds_s2000w_client_set_option); + + SANE_Status status = sane_kds_s2000w_net_control_option(h, 7, SANE_ACTION_SET_VALUE, "Automatic", info); + + json_object* config = json_object_object_get(h->scanner_config, "Configuration"); + json_object* value_object = json_object_object_get(config, CROPPING_MODE); + const char* value = json_object_get_string(value_object); + + assert_int_equal(status, SANE_STATUS_GOOD); + assert_string_equal(value, "Automatic"); + assert_int_equal(*info, SANE_INFO_RELOAD_OPTIONS); + + kds_s2000w_handler_free(h); + h = NULL; + free(info); + info = NULL; +} + int main() { const struct CMUnitTest net_tests[] = { @@ -530,7 +567,8 @@ int main() cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_int_word_list_test, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_string_test, setup_default_option, teardown_default_option), cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_int_test, setup_default_option, teardown_default_option), - cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_int_word_list_test, setup_default_option, teardown_default_option) + cmocka_unit_test_setup_teardown(kds_s2000w_net_set_invalid_option_int_word_list_test, setup_default_option, teardown_default_option), + cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_cropping_mode_and_deps, setup_default_option, teardown_default_option) }; return cmocka_run_group_tests(net_tests, NULL, NULL);