[gtk+] Add a test for the system rgba visual
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a test for the system rgba visual
- Date: Sat, 26 Mar 2016 14:11:08 +0000 (UTC)
commit 2374e2aa3b723c7352135b5a5964c96fff86a8f6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 26 10:09:19 2016 -0400
Add a test for the system rgba visual
The main point of this test is to ensure that the pixel_details
getters work as expected.
testsuite/gdk/Makefile.am | 1 +
testsuite/gdk/visual.c | 65 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/gdk/Makefile.am b/testsuite/gdk/Makefile.am
index 599dbba..63b7f8b 100644
--- a/testsuite/gdk/Makefile.am
+++ b/testsuite/gdk/Makefile.am
@@ -23,6 +23,7 @@ TEST_PROGS += \
encoding \
keysyms \
rgba \
+ visual \
$(NULL)
CLEANFILES = \
diff --git a/testsuite/gdk/visual.c b/testsuite/gdk/visual.c
new file mode 100644
index 0000000..8b8b2ee
--- /dev/null
+++ b/testsuite/gdk/visual.c
@@ -0,0 +1,65 @@
+#include <gdk/gdk.h>
+
+/* We don't technically guarantee that the visual returned by
+ * gdk_screen_get_rgba_visual is ARGB8888. But if it isn't, lots
+ * of code will break, so test this here anyway.
+ * The main point of this test is to ensure that the pixel_details
+ * functions return meaningful values for TrueColor visuals.
+ */
+static void
+test_rgba_visual (void)
+{
+ GdkScreen *screen;
+ GdkVisual *visual;
+ guint32 r_mask, g_mask, b_mask;
+ gint r_shift, g_shift, b_shift;
+ gint r_precision, g_precision, b_precision;
+ gint depth;
+ GdkVisualType type;
+
+ g_test_bug ("764210");
+
+ screen = gdk_screen_get_default ();
+ visual = gdk_screen_get_rgba_visual (screen);
+
+ if (visual == NULL)
+ {
+ g_test_skip ("no rgba visual");
+ return;
+ }
+
+ depth = gdk_visual_get_depth (visual);
+ type = gdk_visual_get_visual_type (visual);
+ gdk_visual_get_red_pixel_details (visual, &r_mask, &r_shift, &r_precision);
+ gdk_visual_get_green_pixel_details (visual, &g_mask, &g_shift, &g_precision);
+ gdk_visual_get_blue_pixel_details (visual, &b_mask, &b_shift, &b_precision);
+
+ g_assert_cmpint (depth, ==, 32);
+ g_assert_cmpint (type, ==, GDK_VISUAL_TRUE_COLOR);
+
+ g_assert_cmphex (r_mask, ==, 0x00ff0000);
+ g_assert_cmphex (g_mask, ==, 0x0000ff00);
+ g_assert_cmphex (b_mask, ==, 0x000000ff);
+
+ g_assert_cmpint (r_shift, ==, 16);
+ g_assert_cmpint (g_shift, ==, 8);
+ g_assert_cmpint (b_shift, ==, 0);
+
+ g_assert_cmpint (r_precision, ==, 8);
+ g_assert_cmpint (g_precision, ==, 8);
+ g_assert_cmpint (b_precision, ==, 8);
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ gdk_init (NULL, NULL);
+
+ g_test_bug_base ("http://bugzilla.gnome.org/");
+
+ g_test_add_func ("/visual/rgba", test_rgba_visual);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]