void mock_response(response* resp)
{
response* mock_resp = mock_type(response*);
+ if (mock_resp == NULL)
+ return;
+
if (mock_resp->size > 0) {
resp->data = realloc(resp->data, mock_resp->size);
memcpy(resp->data, mock_resp->data, mock_resp->size);
int __wrap_kds_s2000w_client_get_option(int64_t sessionid, response* response)
{
- response->data = realloc(response->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(response->data, responsedata, 919);
-
- response->code = 200;
- response->size = sizeof(response->data);
-
+ mock_response(response);
return mock_type(int);
}
assert_int_equal(result, SANE_STATUS_UNSUPPORTED);
}
-void sane_kds_s2000w_net_control_get_option_zero()
+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);
handler* h = init_handler();
int value = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_two()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_three()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_four()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_five()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_six()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_eight()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_nine()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_ten()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_eleven()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_twelve()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_thirteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_fourteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_fifteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_sixteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_seventeen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_eightteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_nineteen()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_twenty()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_twentyone()
+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);
handler* h = init_handler();
int option_num = 0;
h = NULL;
}
-void sane_kds_s2000w_net_control_get_option_twentytwo()
+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);
handler* h = init_handler();
int option_num = 0;
+#include <stdlib.h>
+#include <string.h>
#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 main()
{
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(sane_kds_s2000w_net_control_get_option_zero),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_two),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_three),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_four),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_five),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_six),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_eight),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_nine),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_ten),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_eleven),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_twelve),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_thirteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_fourteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_fifteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_sixteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_seventeen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_eightteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_nineteen),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_twenty),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_twentyone),
- cmocka_unit_test(sane_kds_s2000w_net_control_get_option_twentytwo),
+ 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_start),
cmocka_unit_test(sane_kds_s2000w_net_get_parameter_cancel),