2012-09-28 17:39:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
2012-09-28 17:39:32 +04:00
|
|
|
*
|
2015-06-12 01:39:40 +03:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2012-09-28 17:39:32 +04:00
|
|
|
*/
|
|
|
|
|
2014-04-07 15:40:35 +04:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-09-28 17:39:32 +04:00
|
|
|
#include <linux/input.h>
|
2014-11-20 04:18:34 +03:00
|
|
|
|
2012-12-08 01:50:34 +04:00
|
|
|
#include "weston-test-client-helper.h"
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2012-12-08 01:50:34 +04:00
|
|
|
TEST(simple_button_test)
|
2012-09-28 17:39:32 +04:00
|
|
|
{
|
2012-12-08 01:50:34 +04:00
|
|
|
struct client *client;
|
|
|
|
struct pointer *pointer;
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2015-03-26 13:56:10 +03:00
|
|
|
client = create_client_and_test_surface(100, 100, 100, 100);
|
2012-12-08 01:50:34 +04:00
|
|
|
assert(client);
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2012-12-08 01:50:34 +04:00
|
|
|
pointer = client->input->pointer;
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2012-12-08 01:50:34 +04:00
|
|
|
assert(pointer->button == 0);
|
|
|
|
assert(pointer->state == 0);
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_move_pointer(client->test->weston_test, 150, 150);
|
2012-12-12 16:26:41 +04:00
|
|
|
client_roundtrip(client);
|
2012-12-08 01:50:34 +04:00
|
|
|
assert(pointer->x == 50);
|
|
|
|
assert(pointer->y == 50);
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_send_button(client->test->weston_test, BTN_LEFT,
|
2012-12-08 01:50:34 +04:00
|
|
|
WL_POINTER_BUTTON_STATE_PRESSED);
|
2012-12-12 16:26:41 +04:00
|
|
|
client_roundtrip(client);
|
2012-12-08 01:50:34 +04:00
|
|
|
assert(pointer->button == BTN_LEFT);
|
|
|
|
assert(pointer->state == WL_POINTER_BUTTON_STATE_PRESSED);
|
2012-09-28 17:39:32 +04:00
|
|
|
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_send_button(client->test->weston_test, BTN_LEFT,
|
2012-12-08 01:50:34 +04:00
|
|
|
WL_POINTER_BUTTON_STATE_RELEASED);
|
2012-12-12 16:26:41 +04:00
|
|
|
client_roundtrip(client);
|
2012-12-08 01:50:34 +04:00
|
|
|
assert(pointer->button == BTN_LEFT);
|
|
|
|
assert(pointer->state == WL_POINTER_BUTTON_STATE_RELEASED);
|
2012-09-28 17:39:32 +04:00
|
|
|
}
|