]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option image width
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 18:14:02 +0000 (19:14 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 18:14:02 +0000 (19:14 +0100)
src/kds_s2000w_handler_opts.c
tests/kds_s2000w_net_get_opt_tests.c
tests/kds_s2000w_net_get_opt_tests.h
tests/kds_s2000w_net_get_opt_tests_run.c

index 20b1e5de68e215a4d716be856fd4f588dfdde4cc..b456e6417ef4da4110b34c1a3d73f0de1ae59840 100644 (file)
@@ -6,7 +6,7 @@
 #include "kds_s2000w_debug.h"
 
 #define AUTOSTART_ON 1
-#define OPTION_COUNT 41
+#define OPTION_COUNT 42
 
 void _kds_s2000w_handler_opts_write_string_value(json_object* value_object, void* value)
 {
@@ -290,6 +290,10 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value
                        value_object = json_object_object_get(config, "ImageOffsetY");
                        _kds_s2000w_handler_opts_write_int_value(value_object, value);
                        break;
+               case 40:
+                       value_object = json_object_object_get(config, "ImageWidth");
+                       _kds_s2000w_handler_opts_write_int_value(value_object, value);
+                       break;
                default:
                        break;
        }
@@ -477,6 +481,10 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                        _kds_s2000w_handler_opts_write_int_value_to_json(value_object, value);
                        break;
                case 40:
+                       value_object = json_object_object_get(config, "ImageWidth");
+                       _kds_s2000w_handler_opts_write_int_value_to_json(value_object, value);
+                       break;
+               case 41:
                        _kds_s2000w_handler_opts_set_option_to_default(h);
                        _kds_s2000w_handler_opts_set_autostart_on(h);
 
index 95e7eea5b17edf4ac0682ca2b858fa50244acc2a..1e9eccbe53940e48b26925566d793c2360702058 100644 (file)
@@ -7,6 +7,8 @@
 #include "../src/kds_s2000w_net.h"
 #include "../src/kds_s2000w_handler.h"
 
+#define MAX_OPTION_COUNT 42
+
 void sane_kds_s2000w_net_control_get_option_zero_test(void** state)
 {
        response* resp = (response*) *state;
@@ -21,7 +23,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, 41);
+       assert_int_equal(value, MAX_OPTION_COUNT);
 
        kds_s2000w_handler_free(h);
        h = NULL;
@@ -579,6 +581,21 @@ void sane_kds_s2000w_net_control_get_option_thirdynine_test(void** state)
 
        assert_int_equal(value, 0);
 
+       kds_s2000w_handler_free(h);
+       h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_fourty_test(void** state)
+{
+       handler* h = kds_s2000w_handler_init();
+       response* resp = (response*) *state;
+       h->current_scanner_config = json_tokener_parse(resp->data);
+       uint32_t value = -1;
+
+       sane_kds_s2000w_net_control_option(h, 40, SANE_ACTION_GET_VALUE, &value, NULL);
+
+       assert_int_equal(value, 10);
+
        kds_s2000w_handler_free(h);
        h = NULL;
 }
\ No newline at end of file
index 9de7f962840469d3b036698c7c12add5acd9010d..e8daec14add41271301484e295a40791e43e034c 100644 (file)
@@ -44,5 +44,6 @@ void sane_kds_s2000w_net_control_get_option_thirdysix_test(void** state);
 void sane_kds_s2000w_net_control_get_option_thirdyseven_test(void** state);
 void sane_kds_s2000w_net_control_get_option_thirdyeight_test(void** state);
 void sane_kds_s2000w_net_control_get_option_thirdynine_test(void** state);
+void sane_kds_s2000w_net_control_get_option_fourty_test(void** state);
 
 #endif
\ No newline at end of file
index adc63b9426a46775043d0a26317561018c7bdce3..d58a5d5e93f7cdcff263170e5ff7ff42b43d30eb 100644 (file)
@@ -54,10 +54,14 @@ int setup_default_get_option(void** state)
                        \"JpegQuality\": \"Good\", \
                        \"HoleFill\": 0, \
                        \"CroppingMode\": \"AutomaticStraighten\", \
-                       \"CroppingImage\": \"EntireDocument\" \
+                       \"CroppingImage\": \"EntireDocument\", \
+                       \"ImageOffsetX\": 0, \
+                       \"ImageOffsetY\": 0, \
+                       \"ImageWidth\": 10, \
+                       \"ImageHeight\": 10 \
                } \
        }";
-       resp->size = 1416;
+       resp->size = 1503;
        resp->data = malloc(resp->size);
        memcpy(resp->data, responsedata, resp->size);
        resp->code = 200;
@@ -113,7 +117,8 @@ int main()
                cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdysix_test, setup_default_get_option, teardown_default_get_option),
                cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyseven_test, setup_default_get_option, teardown_default_get_option),
                cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyeight_test, setup_default_get_option, teardown_default_get_option),
-               cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdynine_test, setup_default_get_option, teardown_default_get_option)
+               cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdynine_test, setup_default_get_option, teardown_default_get_option),
+               cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_fourty_test, setup_default_get_option, teardown_default_get_option)
        };
 
        return cmocka_run_group_tests(net_tests, NULL, NULL);