toytoolkit: Don't draw shadows for maximized windows.
[profile/ivi/weston.git] / tests / client-test.c
1 /*
2  * Copyright © 2012 Intel Corporation
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of the copyright holders not be used in
9  * advertising or publicity pertaining to distribution of the software
10  * without specific, written prior permission.  The copyright holders make
11  * no representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  *
14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <assert.h>
27 #include <unistd.h>
28
29 #include "test-runner.h"
30
31
32 struct context {
33         struct weston_compositor *compositor;
34         struct test_client *client;
35         struct wl_listener compositor_destroy_listener;
36         int status;
37         int done;
38 };
39
40 static void
41 compositor_destroy(struct wl_listener *listener, void *data)
42 {
43         struct context *context =
44                 container_of(listener, struct context,
45                              compositor_destroy_listener);
46
47         fprintf(stderr, "notify compositor destroy, status %d, done %d\n",
48                 context->client->status, context->client->done);
49
50         assert(context->client->status == 0);
51         assert(context->client->done);
52 }
53
54
55 TEST(client_test)
56 {
57         struct context *context;
58
59         context = malloc(sizeof *context);
60         assert(context);
61         context->compositor = compositor;
62         context->done = 0;
63         context->client = test_client_launch(compositor, "test-client");
64         context->client->terminate = 1;
65
66         context->compositor_destroy_listener.notify = compositor_destroy;
67         wl_signal_add(&compositor->destroy_signal,
68                       &context->compositor_destroy_listener);
69
70         test_client_send(context->client, "bye\n");
71 }