Changeset dcac756 in mainline for uspace/lib/display/test/display.c


Ignore:
Timestamp:
2019-11-10T16:36:53Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6427f083
Parents:
38e4f42
git-author:
Jiri Svoboda <jiri@…> (2019-11-10 16:32:14)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-10 16:36:53)
Message:

Improve libdisplay tests, fix bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/test/display.c

    r38e4f42 rdcac756  
    7979        bool get_event_called;
    8080        bool set_color_called;
     81        display_srv_t *srv;
    8182} test_response_t;
    8283
     
    8788        service_id_t sid;
    8889        display_t *disp = NULL;
    89 
    90         async_set_fallback_port_handler(test_display_conn, disp);
     90        test_response_t resp;
     91
     92        async_set_fallback_port_handler(test_display_conn, &resp);
    9193
    9294        // FIXME This causes this test to be non-reentrant!
     
    322324}
    323325
     326/** Keyboard event can be delivered from server to client callback function */
     327#include <stdio.h>
     328PCUT_TEST(kbd_event_deliver)
     329{
     330        errno_t rc;
     331        service_id_t sid;
     332        display_t *disp = NULL;
     333        display_window_t *wnd;
     334        test_response_t resp;
     335        gfx_context_t *gc;
     336
     337        async_set_fallback_port_handler(test_display_conn, &resp);
     338
     339        // FIXME This causes this test to be non-reentrant!
     340        rc = loc_server_register(test_display_server);
     341        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     342
     343        rc = loc_service_register(test_display_svc, &sid);
     344        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     345
     346        rc = display_open(test_display_svc, &disp);
     347        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     348        PCUT_ASSERT_NOT_NULL(disp);
     349        PCUT_ASSERT_NOT_NULL(resp.srv);
     350
     351        wnd = NULL;
     352        resp.rc = EOK;
     353        rc = display_window_create(disp, &test_display_wnd_cb, NULL, &wnd);
     354        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     355        PCUT_ASSERT_NOT_NULL(wnd);
     356
     357        printf(" ** call display_window_get_gc\n");
     358        gc = NULL;
     359        rc = display_window_get_gc(wnd, &gc);
     360        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     361        PCUT_ASSERT_NOT_NULL(gc);
     362
     363        printf(" ** call display_srv_ev_pending\n");
     364        display_srv_ev_pending(resp.srv);
     365
     366        printf(" ** call display_window_destroy\n");
     367        rc = display_window_destroy(wnd);
     368        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     369
     370        printf(" ** call display_close\n");
     371        display_close(disp);
     372        printf(" ** call loc_service_unregister\n");
     373        rc = loc_service_unregister(sid);
     374        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     375}
     376
    324377/** Test display service connection.
    325378 *
     
    344397                srv.ops = &test_display_srv_ops;
    345398                srv.arg = arg;
     399                resp->srv = &srv;
    346400
    347401                /* Handle connection */
    348402                display_conn(icall, &srv);
     403
     404                resp->srv = NULL;
    349405        } else {
    350406                (void) wnd_id;
Note: See TracChangeset for help on using the changeset viewer.