]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
check status for ending scan in cancel method
authorBastian Dehn <hhaalo@arcor.de>
Thu, 26 Dec 2024 18:06:33 +0000 (19:06 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 26 Dec 2024 18:06:33 +0000 (19:06 +0100)
src/kds_s2000w_net.c
tests/kds_s2000w_net_tests.c

index 1e54a43b13df7e353826afc2bfa95915c43c51ce..e23cd2edc17547b30ff0ff389afd5233dd53f00e 100644 (file)
@@ -126,6 +126,8 @@ void _sane_kds_s2000w_net_cancel(SANE_Handle handle)
 
        handler* h = (handler*) handle;
 
+       kds_s2000w_net_handler_get_current_scan_status(h);
+
        if (h->current_scan_status->complete_scanned > 0) {
                reset_handler(h);
                return;
index a852ceecb37c42691b9a3ba310d3dfa0c8001645..a8e1e2a5d71a49bd1883138754a45390b75abaf0 100644 (file)
@@ -326,11 +326,29 @@ void sane_kds_s2000w_net_start_two_pages_per_feeder(void** state)
 
 void sane_kds_s2000w_net_cancel()
 {
+       response* resp_status = kds_s2000w_client_response_init();
+       resp_status->data = realloc(resp_status->data, 205);
+       const char* status = "{ \
+               \"Status\": { \
+                       \"NumImagesScanned\": 2, \
+                       \"NumImagesStored\": 2, \
+                       \"State\": \"Scanning\", \
+                       \"ErrorNum\": 0, \
+                       \"LastError\": \"Status: 200 Success\", \
+                       \"PaperDetected\": \"0\", \
+                       \"PercentAvailable\": 99 \
+               }}\0";
+       memcpy(resp_status->data, status, 205);
+       resp_status->code = 200;
+       resp_status->size = 205;
+       will_return(mock_response, resp_status);
+       will_return(__wrap_kds_s2000w_client_status_session, 0);
        response* resp = kds_s2000w_client_response_init();
        resp->code = 200;
        resp->size = 0;
        will_return(mock_response, resp);
        will_return(__wrap_kds_s2000w_client_stop_scan, 0);
+       expect_function_call(__wrap_kds_s2000w_client_status_session);
        expect_function_call(__wrap_kds_s2000w_client_stop_scan);
        handler* h = init_handler();
        h->current_scan_status->available_images = 1;
@@ -341,6 +359,8 @@ void sane_kds_s2000w_net_cancel()
 
        kds_s2000w_client_response_free(resp);
        resp = NULL;
+       kds_s2000w_client_response_free(resp_status);
+       resp_status = NULL;
        free_handler(h);
        h = NULL;
 }