MESSAGE(STATUS "find ${CMOCKA_LIBRARY}")
+ADD_EXECUTABLE("kds_s2000w_net_get_opt_tests_run"
+ "kds_s2000w_net_get_opt_tests_run.c"
+ "kds_s2000w_net_get_opt_tests.c"
+ "kds_s2000w_client_mock.c")
+ADD_DEPENDENCIES("kds_s2000w_net_get_opt_tests_run" sane-kds_s2000w_net)
+TARGET_LINK_LIBRARIES("kds_s2000w_net_get_opt_tests_run"
+ ${CMOCKA_LIBRARY}
+ sane-kds_s2000w_net)
+
ADD_EXECUTABLE("kds_s2000w_net_read_tests_run"
"kds_s2000w_net_read_tests_run.c"
"kds_s2000w_net_read_tests.c"
INCLUDE(CTest)
ENABLE_TESTING()
+ADD_TEST(NAME "kds_s2000w_net_get_opt_tests_run"
+ COMMAND "./kds_s2000w_net_get_opt_tests_run")
ADD_TEST(NAME "kds_s2000w_net_read_tests_run"
COMMAND "./kds_s2000w_net_read_tests_run")
ADD_TEST(NAME "kds_s2000w_net_tests_run"
--- /dev/null
+
+#include <stdlib.h>
+#include <sane/sane.h>
+#include <string.h>
+#include "kds_s2000w_net_tests.h"
+#include "kds_s2000w_client_mock.h"
+#include "../src/kds_s2000w_config.h"
+#include "../src/kds_s2000w_net.h"
+#include "../src/kds_s2000w_handler.h"
+#include "../src/kds_s2000w_image_converter.h"
+
+void __wrap_load_config(program_config* config, const char* config_stream)
+{
+ return;
+}
+
+void __wrap_kds_s2000w_convert_jpg_to_pnm(blobdata* in, blobdata* out)
+{
+ return;
+}
+
+void sane_kds_s2000w_net_control_get_option_zero(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;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(value, 24);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_two(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 2, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "DocumentFeeder");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_three(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 3, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "Color");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_four(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 option_num = 0;
+ int value = 0;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 4, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 200);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_five(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 5, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "Duplex");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_six(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 option_num = 0;
+ int value = 0;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 6, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 8);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_eight(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 8, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_nine(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 9, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "None");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_ten(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 10, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_eleven(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 11, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "Automatic");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_twelve(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 12, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "Automatic");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_thirteen(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 13, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_fourteen(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 14, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_fifteen(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 15, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_sixteen(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 16, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_seventeen(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 17, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "None");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_eightteen(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 18, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_nineteen(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 option_num = 0;
+ char value[50] = {0};
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 19, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_string_equal(value, "None");
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_twenty(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 20, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 0);
+
+ free_handler(h);
+ h = NULL;
+}
+
+void sane_kds_s2000w_net_control_get_option_twentyone(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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 21, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ 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 option_num = 0;
+ int value = -1;
+
+ _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
+ _sane_kds_s2000w_net_control_option(h, 22, SANE_ACTION_GET_VALUE, &value, NULL);
+
+ assert_int_equal(option_num, 24);
+ assert_int_equal(value, 140);
+
+ free_handler(h);
+ h = NULL;
+}
--- /dev/null
+#ifndef KDS_S2000W_NET_GET_OPT_TESTS_H
+#define KDS_S2000W_NET_GET_OPT_TESTS_H
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+void sane_kds_s2000w_net_control_get_option_zero(void** state);
+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_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_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);
+void sane_kds_s2000w_net_control_get_option_seventeen(void** state);
+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
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include "kds_s2000w_net_get_opt_tests.h"
+#include "kds_s2000w_client_mock.h"
+
+int setup_default_get_option(void** state)
+{
+ response* resp = kds_s2000w_client_response_init();
+ resp->data = realloc(resp->data, 919);
+ const char* responsedata = "{ \
+ \"Status\": { \
+ \"NumImagesScanned\": 0, \
+ \"NumImagesStored\": 0, \
+ \"State\": \"In Session\", \
+ \"ErrorNum\": 0, \
+ \"LastError\": \"Status: 200 Success\", \
+ \"PaperDetected\": \"0\", \
+ \"PercentAvailable\": 99 \
+ }, \
+ \"Configuration\": { \
+ \"DPI\": 200, \
+ \"ScanSide\": \"Duplex\", \
+ \"ColorMode\": \"Color\", \
+ \"SkipBlankPages\": 0, \
+ \"AutoStart\": 0, \
+ \"ColorDropOut\": \"None\", \
+ \"ColorDropOutAggressiveness\": 0, \
+ \"OutputType\": \"Images\", \
+ \"ColorAutoBrightnessMode\": \"Automatic\", \
+ \"ColorBalanceMode\": \"Automatic\", \
+ \"ColorBalanceAggressiveness\": 0, \
+ \"ColorBalanceRed\": 0, \
+ \"ColorBalanceGreen\": 0, \
+ \"ColorBalanceBlue\": 0, \
+ \"ForegroundBoldnessMode\": \"None\", \
+ \"ForegroundBoldnessAggressiveness\": 0, \
+ \"BackgroundSmoothingMode\": \"None\", \
+ \"BackgroundSmoothingAggressiveness\": 0, \
+ \"BinarizationMode\": \"iThresholding\", \
+ \"BinarizationContrast\": 0, \
+ \"MaxDocumentLength\": 140, \
+ \"ScanSource\": \"DocumentFeeder\" \
+ } \
+ }\0";
+ memcpy(resp->data, responsedata, 919);
+ resp->code = 200;
+ resp->size = 919;
+ *state = resp;
+ return 0;
+}
+
+int teardown_default_get_option(void** state)
+{
+ response* resp = (response*) *state;
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+ return 0;
+}
+
+int main()
+{
+ const struct CMUnitTest net_tests[] = {
+ cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_zero, setup_default_get_option, teardown_default_get_option),
+ cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_two, setup_default_get_option, teardown_default_get_option),
+ 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_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_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),
+ cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_seventeen, setup_default_get_option, teardown_default_get_option),
+ cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_eightteen, setup_default_get_option, teardown_default_get_option),
+ 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);
+}
\ No newline at end of file
assert_int_equal(result, SANE_STATUS_UNSUPPORTED);
}
-void sane_kds_s2000w_net_control_get_option_zero(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;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(value, 24);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_two(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 2, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "DocumentFeeder");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_three(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 3, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "Color");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_four(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 option_num = 0;
- int value = 0;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 4, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 200);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_five(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 5, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "Duplex");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_six(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 option_num = 0;
- int value = 0;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 6, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 8);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_eight(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 8, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_nine(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 9, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "None");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_ten(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 10, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_eleven(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 11, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "Automatic");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_twelve(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 12, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "Automatic");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_thirteen(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 13, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_fourteen(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 14, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_fifteen(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 15, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_sixteen(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 16, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_seventeen(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 17, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "None");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_eightteen(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 18, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_nineteen(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 option_num = 0;
- char value[50] = {0};
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 19, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_string_equal(value, "None");
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_twenty(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 20, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 0);
-
- free_handler(h);
- h = NULL;
-}
-
-void sane_kds_s2000w_net_control_get_option_twentyone(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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 21, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- 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 option_num = 0;
- int value = -1;
-
- _sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &option_num, NULL);
- _sane_kds_s2000w_net_control_option(h, 22, SANE_ACTION_GET_VALUE, &value, NULL);
-
- assert_int_equal(option_num, 24);
- assert_int_equal(value, 140);
-
- free_handler(h);
- h = NULL;
-}
void sane_kds_s2000w_net_start_cancel()
{
void kds_s2000w_net_get_devices_only_remote();
void kds_s2000w_net_set_io_mode();
void kds_s2000w_net_get_select_fd();
-void sane_kds_s2000w_net_control_get_option_zero(void** state);
-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_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_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);
-void sane_kds_s2000w_net_control_get_option_seventeen(void** state);
-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);
void sane_kds_s2000w_net_start_cancel();
void sane_kds_s2000w_net_start(void** state);
void sane_kds_s2000w_net_start_one_page_per_flatscan(void** state);
#include "kds_s2000w_net_tests.h"
#include "kds_s2000w_client_mock.h"
-int setup_default_get_option(void** state)
-{
- response* resp = kds_s2000w_client_response_init();
- resp->data = realloc(resp->data, 919);
- const char* responsedata = "{ \
- \"Status\": { \
- \"NumImagesScanned\": 0, \
- \"NumImagesStored\": 0, \
- \"State\": \"In Session\", \
- \"ErrorNum\": 0, \
- \"LastError\": \"Status: 200 Success\", \
- \"PaperDetected\": \"0\", \
- \"PercentAvailable\": 99 \
- }, \
- \"Configuration\": { \
- \"DPI\": 200, \
- \"ScanSide\": \"Duplex\", \
- \"ColorMode\": \"Color\", \
- \"SkipBlankPages\": 0, \
- \"AutoStart\": 0, \
- \"ColorDropOut\": \"None\", \
- \"ColorDropOutAggressiveness\": 0, \
- \"OutputType\": \"Images\", \
- \"ColorAutoBrightnessMode\": \"Automatic\", \
- \"ColorBalanceMode\": \"Automatic\", \
- \"ColorBalanceAggressiveness\": 0, \
- \"ColorBalanceRed\": 0, \
- \"ColorBalanceGreen\": 0, \
- \"ColorBalanceBlue\": 0, \
- \"ForegroundBoldnessMode\": \"None\", \
- \"ForegroundBoldnessAggressiveness\": 0, \
- \"BackgroundSmoothingMode\": \"None\", \
- \"BackgroundSmoothingAggressiveness\": 0, \
- \"BinarizationMode\": \"iThresholding\", \
- \"BinarizationContrast\": 0, \
- \"MaxDocumentLength\": 140, \
- \"ScanSource\": \"DocumentFeeder\" \
- } \
- }\0";
- memcpy(resp->data, responsedata, 919);
- resp->code = 200;
- resp->size = 919;
- *state = resp;
- return 0;
-}
-
-int teardown_default_get_option(void** state)
-{
- response* resp = (response*) *state;
- kds_s2000w_client_response_free(resp);
- resp = NULL;
- return 0;
-}
-
int setup_net_start(void** state)
{
response** response_list = malloc(sizeof(response*) * 3);
cmocka_unit_test(kds_s2000w_net_get_devices_only_remote),
cmocka_unit_test(kds_s2000w_net_set_io_mode),
cmocka_unit_test(kds_s2000w_net_get_select_fd),
- cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_zero, setup_default_get_option, teardown_default_get_option),
- cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_two, setup_default_get_option, teardown_default_get_option),
- 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_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_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),
- cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_seventeen, setup_default_get_option, teardown_default_get_option),
- cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_eightteen, setup_default_get_option, teardown_default_get_option),
- 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),
cmocka_unit_test(sane_kds_s2000w_net_start_cancel),
cmocka_unit_test(sane_kds_s2000w_net_get_parameter_cancel),
cmocka_unit_test(sane_kds_s2000w_net_cancel),