blob: 623163e28ae42f39cdbf3e086908344be4c73f4f [file] [log] [blame]
Kristian Høgsberg915b7f82012-04-26 10:08:01 -04001/*
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>
Kristian Høgsbergdd909212012-04-27 11:15:58 -040024#include <stdarg.h>
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040025#include <stdio.h>
26#include <assert.h>
Kristian Høgsbergdd909212012-04-27 11:15:58 -040027#include <unistd.h>
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040028
29#include "test-runner.h"
30
Kristian Høgsbergdd909212012-04-27 11:15:58 -040031
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040032struct context {
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040033 struct weston_compositor *compositor;
Kristian Høgsbergdd909212012-04-27 11:15:58 -040034 struct test_client *client;
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040035 struct wl_listener compositor_destroy_listener;
36 int status;
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040037 int done;
38};
39
40static void
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040041compositor_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",
Kristian Høgsbergdd909212012-04-27 11:15:58 -040048 context->client->status, context->client->done);
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040049
Kristian Høgsbergdd909212012-04-27 11:15:58 -040050 assert(context->client->status == 0);
51 assert(context->client->done);
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040052}
53
Kristian Høgsbergdd909212012-04-27 11:15:58 -040054
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040055TEST(client_test)
56{
57 struct context *context;
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040058
59 context = malloc(sizeof *context);
60 assert(context);
61 context->compositor = compositor;
62 context->done = 0;
Kristian Høgsbergdd909212012-04-27 11:15:58 -040063 context->client = test_client_launch(compositor);
64 context->client->terminate = 1;
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040065
66 context->compositor_destroy_listener.notify = compositor_destroy;
67 wl_signal_add(&compositor->destroy_signal,
68 &context->compositor_destroy_listener);
Kristian Høgsbergdd909212012-04-27 11:15:58 -040069
70 test_client_send(context->client, "bye\n");
Kristian Høgsberg915b7f82012-04-26 10:08:01 -040071}