[retro-gtk/wip/aplazas/test: 1/3] tests
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/test: 1/3] tests
- Date: Thu, 9 Nov 2017 18:23:03 +0000 (UTC)
commit 59d36370125b09c151b2b1a7cc6cbc1923571e58
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Nov 5 08:26:08 2017 +0100
tests
meson.build | 1 +
tests/meson.build | 16 ++
tests/test-core-descriptor.c | 407 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 424 insertions(+), 0 deletions(-)
---
diff --git a/meson.build b/meson.build
index 5f560f7..b7114c8 100644
--- a/meson.build
+++ b/meson.build
@@ -35,4 +35,5 @@ add_project_arguments([
], language: 'c')
subdir('retro-gtk')
+subdir('tests')
subdir('demos')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..98f7505
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,16 @@
+tests = [
+ ['RetroCoreDescriptor', 'test-core-descriptor'],
+]
+
+foreach t : tests
+ test_display_name = t.get(0)
+ test_name = t.get(1)
+ test_srcs = ['@0@.c'.format(test_name)]
+
+ test_exe = executable(test_display_name, test_srcs,
+ c_args: retro_gtk_c_args,
+ dependencies: retro_gtk_deps,
+ link_with: retro_gtk_lib)
+
+ test('@0@ test'.format(test_display_name), test_exe)
+endforeach
diff --git a/tests/test-core-descriptor.c b/tests/test-core-descriptor.c
new file mode 100644
index 0000000..38da19b
--- /dev/null
+++ b/tests/test-core-descriptor.c
@@ -0,0 +1,407 @@
+/* test-core-descriptor.c
+ *
+ * Copyright (C) 2017 Adrien Plazas <kekun plazas laposte net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "../retro-gtk/retro-core-descriptor.h"
+
+/* static void */
+/* test_null (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (NULL, &error); */
+/* g_assert_error (error, */
+/* MANETTE_MAPPING_ERROR, */
+/* MANETTE_MAPPING_ERROR_NOT_A_MAPPING); */
+/* g_error_free (error); */
+
+/* g_assert_null (mapping); */
+/* } */
+
+/* static void */
+/* test_empty (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new ("", &error); */
+/* g_assert_error (error, */
+/* MANETTE_MAPPING_ERROR, */
+/* MANETTE_MAPPING_ERROR_NOT_A_MAPPING); */
+/* g_error_free (error); */
+
+/* g_assert_null (mapping); */
+/* } */
+
+/* static void */
+/* test_valid (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_STEAM_CONTROLLER, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_button_bindings (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* const ManetteMappingBinding * const *bindings; */
+/* const ManetteMappingBinding *binding; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_BUTTON, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_BUTTON, */
+/* 0); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_BUTTON); */
+/* g_assert_cmpint (binding->source.index, ==, 0); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_SOUTH); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_BUTTON, */
+/* 1); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_BUTTON); */
+/* g_assert_cmpint (binding->source.index, ==, 1); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_EAST); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_BUTTON, */
+/* 2); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_BUTTON); */
+/* g_assert_cmpint (binding->source.index, ==, 2); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_WEST); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_BUTTON, */
+/* 3); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_BUTTON); */
+/* g_assert_cmpint (binding->source.index, ==, 3); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_NORTH); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_axis_bindings (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* const ManetteMappingBinding * const *bindings; */
+/* const ManetteMappingBinding *binding; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_AXIS, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_AXIS, */
+/* 0); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 0); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_X); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_AXIS, */
+/* 1); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_null (bindings[1]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 1); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_Y); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_axis_range_bindings (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* const ManetteMappingBinding * const *bindings; */
+/* const ManetteMappingBinding *binding; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_AXIS, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_AXIS, */
+/* 2); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_nonnull (bindings[1]); */
+/* g_assert_null (bindings[2]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 2); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_RX); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+
+/* binding = bindings[1]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 2); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_RX); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_AXIS, */
+/* 3); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_nonnull (bindings[1]); */
+/* g_assert_null (bindings[2]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 3); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+/* g_assert_true (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_RY); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+
+/* binding = bindings[1]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_AXIS); */
+/* g_assert_cmpint (binding->source.index, ==, 3); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+/* g_assert_true (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_ABS); */
+/* g_assert_cmpint (binding->destination.code, ==, ABS_RY); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_hat_x_bindings (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* const ManetteMappingBinding * const *bindings; */
+/* const ManetteMappingBinding *binding; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_HAT, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_HAT, */
+/* 0); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_nonnull (bindings[1]); */
+/* g_assert_null (bindings[2]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_HAT); */
+/* g_assert_cmpint (binding->source.index, ==, 0); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+/* g_assert_true (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_DPAD_LEFT); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* binding = bindings[1]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_HAT); */
+/* g_assert_cmpint (binding->source.index, ==, 0); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_DPAD_RIGHT); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_hat_y_bindings (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* const ManetteMappingBinding * const *bindings; */
+/* const ManetteMappingBinding *binding; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_HAT, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* bindings = manette_mapping_get_bindings (mapping, */
+/* MANETTE_MAPPING_INPUT_TYPE_HAT, */
+/* 1); */
+
+/* g_assert_nonnull (bindings); */
+/* g_assert_nonnull (bindings[0]); */
+/* g_assert_nonnull (bindings[1]); */
+/* g_assert_null (bindings[2]); */
+
+/* binding = bindings[0]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_HAT); */
+/* g_assert_cmpint (binding->source.index, ==, 1); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_NEGATIVE); */
+/* g_assert_true (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_DPAD_UP); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* binding = bindings[1]; */
+/* g_assert_cmpint (binding->source.type, ==, MANETTE_MAPPING_INPUT_TYPE_HAT); */
+/* g_assert_cmpint (binding->source.index, ==, 1); */
+/* g_assert_cmpint (binding->source.range, ==, MANETTE_MAPPING_RANGE_POSITIVE); */
+/* g_assert_false (binding->source.invert); */
+/* g_assert_cmpint (binding->destination.type, ==, EV_KEY); */
+/* g_assert_cmpint (binding->destination.code, ==, BTN_DPAD_DOWN); */
+/* g_assert_cmpint (binding->destination.range, ==, MANETTE_MAPPING_RANGE_FULL); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+/* static void */
+/* test_has_destination_input (void) */
+/* { */
+/* ManetteMapping *mapping; */
+/* GError *error = NULL; */
+
+/* mapping = manette_mapping_new (MAPPING_STEAM_CONTROLLER, &error); */
+/* g_assert_no_error (error); */
+/* g_assert_nonnull (mapping); */
+/* g_assert_true (MANETTE_IS_MAPPING (mapping)); */
+
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_SOUTH)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_EAST)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_NORTH)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_WEST)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_TL)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_TR)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_TL2)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_TR2)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_SELECT)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_START)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_MODE)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_THUMBL)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_THUMBR)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_DPAD_UP)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_DPAD_DOWN)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_DPAD_LEFT)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_DPAD_RIGHT)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_X)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_Y)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_RX)); */
+/* g_assert_true (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_RY)); */
+
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_KEY, KEY_SPACE)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_C)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_KEY, BTN_Z)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_Z)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_RZ)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_HAT0X)); */
+/* g_assert_false (manette_mapping_has_destination_input (mapping, EV_ABS, ABS_HAT0Y)); */
+
+/* g_object_unref (mapping); */
+/* } */
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ /* g_test_add_func ("/RetroCoreDescriptor/test_null", test_null); */
+
+ return g_test_run();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]