summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-12-06 19:22:24 +0100
committerTimm Bäder <mail@baedert.org>2017-12-21 19:12:32 +0100
commitac6b7b24f9331b299d87186ca3b1e2f71748599f (patch)
tree8139ff755e4439237cce715d340f2bd3f226a083
parentfd0b7caa7c426b17256b0700011779b7f524f14c (diff)
downloadgtk+-ac6b7b24f9331b299d87186ca3b1e2f71748599f.tar.gz
tests: Add border drawing test
-rw-r--r--tests/meson.build1
-rw-r--r--tests/testborderdrawing.c160
2 files changed, 161 insertions, 0 deletions
diff --git a/tests/meson.build b/tests/meson.build
index 2c435c09dc..decfb67be9 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -127,6 +127,7 @@ gtk_tests = [
['testcenterbox'],
['testgridbaseline'],
['showrendernode'],
+ ['testborderdrawing'],
]
if os_linux
diff --git a/tests/testborderdrawing.c b/tests/testborderdrawing.c
new file mode 100644
index 0000000000..cb6d8605ed
--- /dev/null
+++ b/tests/testborderdrawing.c
@@ -0,0 +1,160 @@
+
+#include<gtk/gtk.h>
+
+static const char *css =
+".one {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-left: 50px solid #0f0;"
+" border-top: 10px solid red;"
+" border-bottom: 50px solid teal;"
+" border-right: 100px solid pink;"
+" border-radius: 100px;"
+"}"
+".two {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-left: 50px solid #0f0;"
+" border-top: 10px solid red;"
+" border-bottom: 50px solid teal;"
+" border-right: 100px solid pink;"
+" border-radius: 50%;"
+"}"
+".three {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-left: 50px solid #0f0;"
+" border-top: 10px solid red;"
+" border-bottom: 50px solid teal;"
+" border-right: 100px solid pink;"
+" border-radius: 0px;"
+"}"
+".four {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border: 10px solid black;"
+" border-radius: 999px;"
+"}"
+".five {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border: 30px solid black;"
+" border-radius: 0px;"
+"}"
+".b1 {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-top: 30px solid black;"
+" border-radius: 0px;"
+"}"
+".b2 {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-bottom: 30px solid black;"
+" border-radius: 0px;"
+"}"
+".b3 {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-right: 30px solid blue;"
+" border-radius: 40px;"
+"}"
+".b4 {"
+" all: unset;"
+" min-width: 100px;"
+" min-height:100px;"
+" border-bottom: 30px solid blue;"
+" border-radius: 40px;"
+"}"
+;
+
+
+int
+main (int argc, char **argv)
+{
+ GtkWidget *window;
+ GtkWidget *box;
+ GtkWidget *top;
+ GtkWidget *bottom;
+ GtkWidget *w;
+ GtkCssProvider *provider;
+
+ gtk_init ();
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, css, -1);
+ gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 40);
+ top = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
+ bottom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
+ g_object_set (box, "margin", 40, NULL);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "one");
+ gtk_container_add (GTK_CONTAINER (top), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "two");
+ gtk_container_add (GTK_CONTAINER (top), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "three");
+ gtk_container_add (GTK_CONTAINER (top), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "four");
+ gtk_container_add (GTK_CONTAINER (top), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "five");
+ gtk_container_add (GTK_CONTAINER (top), w);
+
+
+ /* Bottom */
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "b1");
+ gtk_container_add (GTK_CONTAINER (bottom), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "b2");
+ gtk_container_add (GTK_CONTAINER (bottom), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "b3");
+ gtk_container_add (GTK_CONTAINER (bottom), w);
+
+ w = gtk_button_new ();
+ gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (w), "b4");
+ gtk_container_add (GTK_CONTAINER (bottom), w);
+
+ gtk_container_add (GTK_CONTAINER (box), top);
+ gtk_container_add (GTK_CONTAINER (box), bottom);
+ gtk_container_add (GTK_CONTAINER (window), box);
+ g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ gtk_widget_destroy (window);
+}