[gnome-builder] tests: add egg-slider test
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] tests: add egg-slider test
- Date: Sat, 16 Jan 2016 18:53:53 +0000 (UTC)
commit 7ce161dad9bc4b4072afbb0a8ea66cac21f07a56
Author: Christian Hergert <chergert redhat com>
Date: Sat Jan 16 10:53:31 2016 -0800
tests: add egg-slider test
tests/Makefile.am | 6 ++
tests/test-egg-slider.c | 58 +++++++++++++++++++++
tests/test-egg-slider.ui | 124 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 188 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1c4464e..3a1dfae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -148,6 +148,12 @@ test_fuzzy_CFLAGS = $(search_cflags)
test_fuzzy_LDADD = $(search_libs)
+misc_programs += test-egg-slider
+test_egg_slider_SOURCES = test-egg-slider.c
+test_egg_slider_CFLAGS = $(egg_cflags)
+test_egg_slider_LDADD = $(egg_libs)
+
+
#TESTS += test-ide-ctags
#test_ide_ctags_SOURCES = test-ide-ctags.c
#test_ide_ctags_CFLAGS = $(tests_cflags)
diff --git a/tests/test-egg-slider.c b/tests/test-egg-slider.c
new file mode 100644
index 0000000..4b9a896
--- /dev/null
+++ b/tests/test-egg-slider.c
@@ -0,0 +1,58 @@
+#include <gtk/gtk.h>
+#include <stdlib.h>
+
+#include "egg-slider.h"
+
+static void
+connect_button (GtkBuilder *builder,
+ const gchar *name,
+ GCallback callback)
+{
+ EggSlider *slider = EGG_SLIDER (gtk_builder_get_object (builder, "slider"));
+ GtkButton *button = GTK_BUTTON (gtk_builder_get_object (builder, name));
+
+ g_assert (slider != NULL);
+ g_assert (button != NULL);
+
+ g_signal_connect_swapped (button, "clicked", callback, slider);
+}
+
+static void set_bottom (EggSlider *slider) { egg_slider_set_position (slider, EGG_SLIDER_BOTTOM); }
+static void set_top (EggSlider *slider) { egg_slider_set_position (slider, EGG_SLIDER_TOP); }
+static void set_left (EggSlider *slider) { egg_slider_set_position (slider, EGG_SLIDER_LEFT); }
+static void set_right (EggSlider *slider) { egg_slider_set_position (slider, EGG_SLIDER_RIGHT); }
+static void set_none (EggSlider *slider) { egg_slider_set_position (slider, EGG_SLIDER_NONE); }
+
+int
+main (int argc,
+ char *argv[])
+{
+ GtkBuilder *builder;
+ GObject *window;
+ GError *error = NULL;
+
+ gtk_init (&argc, &argv);
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_file (builder, "test-egg-slider.ui", &error);
+ g_assert_no_error (error);
+
+ window = gtk_builder_get_object (builder, "window");
+ g_assert (window != NULL);
+
+ connect_button (builder, "up_button", G_CALLBACK (set_bottom));
+ connect_button (builder, "down_button", G_CALLBACK (set_top));
+ connect_button (builder, "end_button", G_CALLBACK (set_left));
+ connect_button (builder, "start_button", G_CALLBACK (set_right));
+ connect_button (builder, "none_button", G_CALLBACK (set_none));
+
+ g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
+
+ gtk_window_present (GTK_WINDOW (window));
+
+ gtk_main ();
+
+ g_object_unref (builder);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/test-egg-slider.ui b/tests/test-egg-slider.ui
new file mode 100644
index 0000000..c847c6f
--- /dev/null
+++ b/tests/test-egg-slider.ui
@@ -0,0 +1,124 @@
+<interface>
+ <object class="GtkWindow" id="window">
+ <property name="title">EggSlider Test</property>
+ <property name="default-height">400</property>
+ <property name="default-width">800</property>
+ <child>
+ <object class="EggSlider" id="slider">
+ <property name="visible">true</property>
+ <child type="top">
+ <object class="GtkLabel">
+ <property name="label">Top</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child type="bottom">
+ <object class="GtkEntry">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child type="left">
+ <object class="GtkListBox">
+ <property name="visible">true</property>
+ <property name="width-request">100</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="label">Row 1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="right">
+ <object class="GtkListBox">
+ <property name="width-request">100</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="label">Row 1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkButton" id="none_button">
+ <property name="visible">true</property>
+ <property name="label">•</property>
+ </object>
+ <packing>
+ <property name="top-attach">1</property>
+ <property name="left-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="start_button">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">pan-start-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top-attach">1</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="end_button">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">pan-end-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top-attach">1</property>
+ <property name="left-attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="up_button">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">pan-up-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top-attach">0</property>
+ <property name="left-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="down_button">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">pan-down-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top-attach">2</property>
+ <property name="left-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]