U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
| 3 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 4 | * 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 Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 11 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 12 | * 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 Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 24 | */ |
| 25 | |
Andrew Wedgbury | 9cd661e | 2014-04-07 12:40:35 +0100 | [diff] [blame] | 26 | #include "config.h" |
| 27 | |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 28 | #include <linux/input.h> |
Bryce Harrington | a768026 | 2014-11-19 17:18:34 -0800 | [diff] [blame] | 29 | |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 30 | #include "weston-test-client-helper.h" |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 31 | |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 32 | TEST(simple_button_test) |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 33 | { |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 34 | struct client *client; |
| 35 | struct pointer *pointer; |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 36 | |
Pekka Paalanen | 4ac06ff | 2015-03-26 12:56:10 +0200 | [diff] [blame] | 37 | client = create_client_and_test_surface(100, 100, 100, 100); |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 38 | assert(client); |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 39 | |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 40 | pointer = client->input->pointer; |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 41 | |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 42 | assert(pointer->button == 0); |
| 43 | assert(pointer->state == 0); |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 44 | |
Derek Foreman | f6a6592 | 2015-02-24 09:32:14 -0600 | [diff] [blame] | 45 | weston_test_move_pointer(client->test->weston_test, 150, 150); |
Pekka Paalanen | f2aa64f | 2012-12-12 14:26:41 +0200 | [diff] [blame] | 46 | client_roundtrip(client); |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 47 | assert(pointer->x == 50); |
| 48 | assert(pointer->y == 50); |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 49 | |
Derek Foreman | f6a6592 | 2015-02-24 09:32:14 -0600 | [diff] [blame] | 50 | weston_test_send_button(client->test->weston_test, BTN_LEFT, |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 51 | WL_POINTER_BUTTON_STATE_PRESSED); |
Pekka Paalanen | f2aa64f | 2012-12-12 14:26:41 +0200 | [diff] [blame] | 52 | client_roundtrip(client); |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 53 | assert(pointer->button == BTN_LEFT); |
| 54 | assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED); |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 55 | |
Derek Foreman | f6a6592 | 2015-02-24 09:32:14 -0600 | [diff] [blame] | 56 | weston_test_send_button(client->test->weston_test, BTN_LEFT, |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 57 | WL_POINTER_BUTTON_STATE_RELEASED); |
Pekka Paalanen | f2aa64f | 2012-12-12 14:26:41 +0200 | [diff] [blame] | 58 | client_roundtrip(client); |
U. Artie Eoff | 0a7d588 | 2012-12-07 13:50:34 -0800 | [diff] [blame] | 59 | assert(pointer->button == BTN_LEFT); |
| 60 | assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED); |
U. Artie Eoff | 58990ca | 2012-09-28 06:39:32 -0700 | [diff] [blame] | 61 | } |