wayland/tests
Marek Chalupa 85d08e8bd6 tests: add test-compositor
This patch introduces a set of functions that can create a display
and clients for tests.
On server side the user can use functions:
  display_create()
  display_destroy()
  create_client()
  display_run()
  display_resume()
and on client side the user can use:
  client_connect()
  client_disconnect()
  stop_display()

The stop_display() and display_resume() are functions that serve as a barrier
and also allow the display to take some action after the display_run() was called,
because after the display is stopped, it can run arbitrary code until it calls
display_resume().

client_connect() function connects to wayland display and creates a proxy to
test_compositor global object, so it can ask for stopping the display later
using stop_display().

An example:

  void
  client_main()
  {
        /* or client can use wl_display_connect(NULL)
         * and do all the stuff manually */
        struct client *c = client_connect();

        /* do some stuff, ... */

        /* stop the display so that it can
         * do some other stuff */
        stop_display(c, 1);

        /* ... */

        client_disconnect(c);
  }

  TEST(dummy_tst)
  {
       struct display *d = display_create();

       /* set up the display */
       wl_global_create(d->wl_display, ...);

       /* ... */

       create_client(d, client_main);
       display_run();

       /* if we are here, the display has been stopped
        * and we can do some code, i. e. create another global or so */
       wl_global_create(d->wl_display, ...);

       /* ... */

       display_resume(d); /* resume display and clients */

       display_destroy(d);
  }

v2:
  added/changed message in few asserts that were not clear
  fixed codying style issues and typo
  client_create_with_name: fixed a condition in an assert
  get_socket_name: use also pid
  check_error: fix errno -> err

[Pekka Paalanen: added test-compositor.h to SOURCES, added
WL_HIDE_DEPRECATED to get rid of deprecated defs and lots of warnings,
fixed one unchecked return value from write().]

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-22 12:34:33 +03:00
..
array-test.c array-test: assert wl_array_add result is not NULL 2014-01-15 10:46:08 -08:00
client-test.c server: Make wl_object and wl_resource opaque structs 2013-07-02 15:52:47 -04:00
connection-test.c connection-test: check malloc result 2014-05-06 14:59:33 -07:00
display-test.c server: Make wl_object and wl_resource opaque structs 2013-07-02 15:52:47 -04:00
event-loop-test.c tests: fix event_loop_timer_updates 2014-08-19 14:34:50 +03:00
exec-fd-leak-checker.c tests: support testing fd inheritance over exec 2012-04-20 15:06:27 +03:00
fixed-benchmark.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
fixed-test.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
list-test.c tests: fix make check for out-of-tree builds 2012-06-30 19:58:37 +00:00
map-test.c Update tests for wl_map changes and add a map_flags test 2013-06-05 17:55:14 -04:00
message-test.c tests: Add message version sanity test 2014-05-09 14:32:04 -07:00
os-wrappers-test.c os-wrappers-test: assert closure is not NULL before invoking it 2014-01-15 10:46:08 -08:00
queue-test.c tests: remove unnecessary lines from queue-test 2014-08-21 14:44:51 +03:00
resources-test.c resources-test: Don't send invalid event 2014-01-20 15:07:55 -08:00
sanity-test.c tests: ensure sanity leak check tests pass when leak checks are disabled. 2012-08-29 14:10:24 -04:00
signal-test.c tests: add unit tests for wl_signal 2013-09-21 11:37:38 -07:00
socket-test.c tests: add tests for bug in adding socket 2014-08-07 16:04:17 +03:00
test-compositor.c tests: add test-compositor 2014-08-22 12:34:33 +03:00
test-compositor.h tests: add test-compositor 2014-08-22 12:34:33 +03:00
test-helpers.c tests: support testing fd inheritance over exec 2012-04-20 15:06:27 +03:00
test-runner.c tests: extended message when leak in test is detected 2013-09-21 11:36:33 -07:00
test-runner.h tests: support testing fd inheritance over exec 2012-04-20 15:06:27 +03:00