blob: e137213caf2d91b761ad17ba31b01731457ea21f [file] [log] [blame]
Kristian Høgsberg3018b442012-04-27 15:02:56 -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>
24#include <stdio.h>
25#include <sys/socket.h>
26#include <assert.h>
27#include <unistd.h>
28
29#include <string.h>
30
31#include "test-runner.h"
32
33static void
34handle_surface(struct test_client *client)
35{
36 uint32_t id;
37 struct wl_resource *resource;
38 struct weston_surface *surface;
39 struct weston_layer *layer = client->data;
Philipp Brüschweiler468262b2012-08-14 14:46:38 +020040 struct wl_list *seat_list;
41 struct weston_seat *seat;
Kristian Høgsberg3018b442012-04-27 15:02:56 -040042
43 assert(sscanf(client->buf, "surface %u", &id) == 1);
44 fprintf(stderr, "got surface id %u\n", id);
45 resource = wl_client_get_object(client->client, id);
46 assert(resource);
47 assert(strcmp(resource->object.interface->name, "wl_surface") == 0);
48
49 surface = (struct weston_surface *) resource;
50
51 weston_surface_configure(surface, 100, 100, 200, 200);
52 weston_surface_assign_output(surface);
53 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
54 wl_list_insert(&layer->surface_list, &surface->layer_link);
55 weston_surface_damage(surface);
56
Philipp Brüschweiler468262b2012-08-14 14:46:38 +020057 seat_list = &client->compositor->seat_list;
58 assert(wl_list_length(seat_list) == 1);
59 seat = container_of(seat_list->next, struct weston_seat, link);
Kristian Høgsberg3018b442012-04-27 15:02:56 -040060 client->compositor->focus = 1; /* Make it work even if pointer is
61 * outside X window. */
Daniel Stone37816df2012-05-16 18:45:18 +010062 notify_motion(seat, 100,
Ander Conselvan de Oliveira6d2030d2012-05-15 14:32:05 +030063 wl_fixed_from_int(150), wl_fixed_from_int(150));
Kristian Høgsberg3018b442012-04-27 15:02:56 -040064
65 test_client_send(client, "bye\n");
66}
67
68TEST(event_test)
69{
70 struct test_client *client;
71 struct weston_layer *layer;
72
Jan Arne Petersen6f83d0d2012-08-21 18:28:48 +020073 client = test_client_launch(compositor, "test-client");
Kristian Høgsberg3018b442012-04-27 15:02:56 -040074 client->terminate = 1;
75
76 test_client_send(client, "create-surface\n");
77 client->handle = handle_surface;
78
79 layer = malloc(sizeof *layer);
80 assert(layer);
81 weston_layer_init(layer, &compositor->cursor_layer.link);
82 client->data = layer;
83}