blob: afa6320fdddff925862346320245c941e4dae492 [file] [log] [blame]
U. Artie Eoff58990ca2012-09-28 06:39:32 -07001/*
2 * Copyright © 2012 Intel Corporation
3 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07004 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
U. Artie Eoff58990ca2012-09-28 06:39:32 -070011 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070012 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
U. Artie Eoff58990ca2012-09-28 06:39:32 -070024 */
25
Andrew Wedgbury9cd661e2014-04-07 12:40:35 +010026#include "config.h"
27
U. Artie Eoff58990ca2012-09-28 06:39:32 -070028#include <linux/input.h>
Bryce Harringtona7680262014-11-19 17:18:34 -080029
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080030#include "weston-test-client-helper.h"
U. Artie Eoff58990ca2012-09-28 06:39:32 -070031
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080032TEST(simple_button_test)
U. Artie Eoff58990ca2012-09-28 06:39:32 -070033{
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080034 struct client *client;
35 struct pointer *pointer;
U. Artie Eoff58990ca2012-09-28 06:39:32 -070036
Pekka Paalanen4ac06ff2015-03-26 12:56:10 +020037 client = create_client_and_test_surface(100, 100, 100, 100);
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080038 assert(client);
U. Artie Eoff58990ca2012-09-28 06:39:32 -070039
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080040 pointer = client->input->pointer;
U. Artie Eoff58990ca2012-09-28 06:39:32 -070041
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080042 assert(pointer->button == 0);
43 assert(pointer->state == 0);
U. Artie Eoff58990ca2012-09-28 06:39:32 -070044
Derek Foremanf6a65922015-02-24 09:32:14 -060045 weston_test_move_pointer(client->test->weston_test, 150, 150);
Pekka Paalanenf2aa64f2012-12-12 14:26:41 +020046 client_roundtrip(client);
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080047 assert(pointer->x == 50);
48 assert(pointer->y == 50);
U. Artie Eoff58990ca2012-09-28 06:39:32 -070049
Derek Foremanf6a65922015-02-24 09:32:14 -060050 weston_test_send_button(client->test->weston_test, BTN_LEFT,
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080051 WL_POINTER_BUTTON_STATE_PRESSED);
Pekka Paalanenf2aa64f2012-12-12 14:26:41 +020052 client_roundtrip(client);
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080053 assert(pointer->button == BTN_LEFT);
54 assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED);
U. Artie Eoff58990ca2012-09-28 06:39:32 -070055
Derek Foremanf6a65922015-02-24 09:32:14 -060056 weston_test_send_button(client->test->weston_test, BTN_LEFT,
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080057 WL_POINTER_BUTTON_STATE_RELEASED);
Pekka Paalanenf2aa64f2012-12-12 14:26:41 +020058 client_roundtrip(client);
U. Artie Eoff0a7d5882012-12-07 13:50:34 -080059 assert(pointer->button == BTN_LEFT);
60 assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED);
U. Artie Eoff58990ca2012-09-28 06:39:32 -070061}