2012-10-02 02:21:16 +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-10-02 02:21:16 +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-10-02 02:21:16 +04:00
|
|
|
*/
|
|
|
|
|
2014-11-20 04:18:33 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2016-07-19 14:16:27 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-12-08 01:50:32 +04:00
|
|
|
#include "weston-test-client-helper.h"
|
2012-10-02 02:21:16 +04:00
|
|
|
|
2012-12-08 01:50:32 +04:00
|
|
|
TEST(simple_keyboard_test)
|
2012-10-02 02:21:16 +04:00
|
|
|
{
|
2012-12-08 01:50:32 +04:00
|
|
|
struct client *client;
|
|
|
|
struct surface *expect_focus = NULL;
|
|
|
|
struct keyboard *keyboard;
|
|
|
|
uint32_t expect_key = 0;
|
|
|
|
uint32_t expect_state = 0;
|
|
|
|
|
2015-03-26 13:56:10 +03:00
|
|
|
client = create_client_and_test_surface(10, 10, 1, 1);
|
2012-12-08 01:50:32 +04:00
|
|
|
assert(client);
|
|
|
|
|
|
|
|
keyboard = client->input->keyboard;
|
|
|
|
|
2015-08-06 23:12:19 +03:00
|
|
|
while (1) {
|
2012-12-08 01:50:32 +04:00
|
|
|
assert(keyboard->key == expect_key);
|
|
|
|
assert(keyboard->state == expect_state);
|
|
|
|
assert(keyboard->focus == expect_focus);
|
|
|
|
|
|
|
|
if (keyboard->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
|
|
|
expect_state = WL_KEYBOARD_KEY_STATE_RELEASED;
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_send_key(client->test->weston_test,
|
|
|
|
expect_key, expect_state);
|
2012-12-08 01:50:32 +04:00
|
|
|
} else if (keyboard->focus) {
|
|
|
|
expect_focus = NULL;
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_activate_surface(
|
|
|
|
client->test->weston_test, NULL);
|
2012-12-08 01:50:32 +04:00
|
|
|
} else if (expect_key < 10) {
|
|
|
|
expect_key++;
|
|
|
|
expect_focus = client->surface;
|
|
|
|
expect_state = WL_KEYBOARD_KEY_STATE_PRESSED;
|
2015-02-24 18:32:14 +03:00
|
|
|
weston_test_activate_surface(
|
|
|
|
client->test->weston_test,
|
|
|
|
expect_focus->wl_surface);
|
|
|
|
weston_test_send_key(client->test->weston_test,
|
|
|
|
expect_key, expect_state);
|
2012-12-08 01:50:32 +04:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2012-12-12 07:00:50 +04:00
|
|
|
|
2012-12-12 16:26:41 +04:00
|
|
|
client_roundtrip(client);
|
2012-10-02 02:21:16 +04:00
|
|
|
}
|
|
|
|
}
|