[PATCH weston v1 15/17] tests: add test-suite tests
Marek Chalupa
mchqwerty at gmail.com
Fri Dec 5 05:36:48 PST 2014
Tests for test-suite itself
Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
Makefile.am | 7 +++-
tests/test-suite-test.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 1 deletion(-)
create mode 100644 tests/test-suite-test.c
diff --git a/Makefile.am b/Makefile.am
index 47c44dc..57882cd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -931,7 +931,8 @@ weston_tests = \
text.weston \
presentation.weston \
roles.weston \
- subsurface.weston
+ subsurface.weston \
+ test-suite-tests.weston
AM_TESTS_ENVIRONMENT = \
@@ -1048,6 +1049,10 @@ roles_weston_SOURCES = tests/roles-test.c
roles_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)
roles_weston_LDADD = libtest-client.la
+test_suite_tests_weston_SOURCES = tests/test-suite-test.c
+test_suite_tests_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)
+test_suite_tests_weston_LDADD = libtest-client.la
+
if ENABLE_EGL
weston_tests += buffer-count.weston
buffer_count_weston_SOURCES = tests/buffer-count-test.c
diff --git a/tests/test-suite-test.c b/tests/test-suite-test.c
new file mode 100644
index 0000000..22009c8
--- /dev/null
+++ b/tests/test-suite-test.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <time.h>
+
+#include "weston-test-client-helper.h"
+
+/* misc tests for test-suite */
+
+static void
+check_geometry(struct client *client)
+{
+ wl_test_get_geometry(client->test->wl_test, client->surface->wl_surface);
+ client_roundtrip(client);
+
+ assert(client->test->geometry.x == client->surface->x);
+ assert(client->test->geometry.y == client->surface->y);
+ assert(client->test->geometry.height == (unsigned int) client->surface->height);
+ assert(client->test->geometry.width == (unsigned int) client->surface->width);
+}
+
+static void
+move_and_check(struct client *client, int x, int y)
+{
+ move_client(client, x, y);
+ check_geometry(client);
+ assert(client->test->geometry.x == x);
+ assert(client->test->geometry.y == y);
+}
+
+static void
+move_client_tst(struct client *client)
+{
+ int x, y, i;
+
+ check_geometry(client);
+
+ move_and_check(client, 100, 100);
+ move_and_check(client, 200, 250);
+ move_and_check(client, 500, 500);
+ move_and_check(client, 0, 0);
+ move_and_check(client, 500, 500);
+ move_and_check(client, 100, 300);
+ move_and_check(client, 132, 123);
+
+ srand(time(NULL));
+
+ assert(client->output->width > 0);
+ assert(client->output->height > 0);
+
+ /* some random fun */
+ for (i = 0; i < 50; ++i) {
+ x = rand() % client->output->width;
+ y = rand() % client->output->height;
+
+ move_and_check(client, x, y);
+ }
+}
+
+/* first test if move_client function works */
+TEST(move_client_test)
+{
+ struct client *client = client_create(100, 100, 200, 200);
+
+ move_client_tst(client);
+}
+
+TEST(move_toytoolkit_client_test)
+{
+ struct client *client = toytoolkit_client_create(10, 10, 200, 200);
+
+ move_client_tst(client);
+}
--
2.1.0
More information about the wayland-devel
mailing list