[libadwaita/wip/exalm/animation-cleanups: 3/4] tests: Add a simple easing test




commit 7e72932dbe6ba7bccf961089bae47315b256851a
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Nov 22 21:00:27 2021 +0500

    tests: Add a simple easing test

 tests/meson.build   |  1 +
 tests/test-easing.c | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index 9b31a5df..e133e7e2 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -30,6 +30,7 @@ test_names = [
   'test-carousel-indicator-dots',
   'test-carousel-indicator-lines',
   'test-combo-row',
+  'test-easing',
   'test-expander-row',
   'test-flap',
   'test-header-bar',
diff --git a/tests/test-easing.c b/tests/test-easing.c
new file mode 100644
index 00000000..58ba6287
--- /dev/null
+++ b/tests/test-easing.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 Purism SPC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Author: Alexander Mikhaylenko <alexander mikhaylenko puri sm>
+ */
+
+#include <adwaita.h>
+
+static void
+test_easing_ease (gconstpointer data)
+{
+  AdwEasing easing = GPOINTER_TO_INT (data);
+
+  g_assert_cmpfloat_with_epsilon (adw_easing_ease (easing, 0), 0, 0.005);
+  g_assert_cmpfloat_with_epsilon (adw_easing_ease (easing, 1), 1, 0.005);
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  g_autoptr (GEnumClass) enum_class = NULL;
+  guint i;
+
+  gtk_test_init (&argc, &argv, NULL);
+  adw_init ();
+
+  enum_class = g_type_class_ref (ADW_TYPE_EASING);
+
+  for (i = 0; i < enum_class->n_values; i++) {
+    GEnumValue *value = &enum_class->values[i];
+    g_autofree char *path =
+      g_strdup_printf ("/Adwaita/Easing/%s", value->value_nick);
+
+    g_test_add_data_func (path, GINT_TO_POINTER (value->value), test_easing_ease);
+  }
+
+  return g_test_run();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]