]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add test color brightness mode
authorBastian Dehn <hhaalo@arcor.de>
Sun, 26 Oct 2025 09:16:52 +0000 (10:16 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 26 Oct 2025 09:16:52 +0000 (10:16 +0100)
tests/kds_s2000w_net_set_opt_tests.c

index 5d5d66904b4f7a22160a026e0d16e2283f99e403..4230e5c01c273a4004211237f850c00aa910b6ec 100644 (file)
@@ -702,6 +702,43 @@ void kds_s2000w_net_set_option_color_balance_mode_and_deps(void** state)
        info = NULL;
 }
 
+void kds_s2000w_net_set_option_color_auto_brightness_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, 21, 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, COLOR_AUTO_BRIGHTNESS_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[] = {
@@ -720,7 +757,8 @@ int main()
                cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_cropping_image_and_deps, setup_default_option, teardown_default_option),
                cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_fourground_boldness_mode_and_deps, setup_default_option, teardown_default_option),
                cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_background_smoothing_mode_and_deps, setup_default_option, teardown_default_option),
-               cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_color_balance_mode_and_deps, setup_default_option, teardown_default_option)
+               cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_color_balance_mode_and_deps, setup_default_option, teardown_default_option),
+               cmocka_unit_test_setup_teardown(kds_s2000w_net_set_option_color_auto_brightness_mode_and_deps, setup_default_option, teardown_default_option)
        };
 
        return cmocka_run_group_tests(net_tests, NULL, NULL);