]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "gtktemplate" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 3 Jan 2021 15:32:22 +0000 (16:32 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 3 Jan 2021 15:37:12 +0000 (16:37 +0100)
Backported from 0.48

configure.ac
tests/Makefile.am
tests/gtktemplate/Makefile.am [new file with mode: 0644]
tests/gtktemplate/gtktemplate.gresource.xml [new file with mode: 0644]
tests/gtktemplate/gtktemplate.ui [new file with mode: 0644]
tests/gtktemplate/gtktemplate.vala [new file with mode: 0644]

index de371b216ca709dbfd30b40b5634294ab65ae987..ae490df77816d5d40dbe072626449f30304a091c 100644 (file)
@@ -167,6 +167,7 @@ AC_CONFIG_FILES([Makefile
            tests/Makefile
            tests/fastvapi/Makefile
            tests/girwriter/Makefile
+           tests/gtktemplate/Makefile
            doc/Makefile
            doc/manual/Makefile
            doc/manual/version.xml
index 2c6fee3bcadc41625c5102870bfd7b141b5a881c..36e09469e26ccd1a345132f030690c9a9f6d2eef 100644 (file)
@@ -3,6 +3,7 @@ NULL =
 SUBDIRS = \
        fastvapi \
        girwriter \
+       gtktemplate \
        $(NULL)
 
 AM_CPPFLAGS = \
diff --git a/tests/gtktemplate/Makefile.am b/tests/gtktemplate/Makefile.am
new file mode 100644 (file)
index 0000000..6cd454e
--- /dev/null
@@ -0,0 +1,22 @@
+NULL =
+
+check-gtktemplate: $(top_builddir)/compiler/valac
+       G_DEBUG=fatal-warnings $(top_builddir)/compiler/valac \
+               -C \
+               --vapidir $(top_srcdir)/vapi \
+               --pkg gtk+-3.0 \
+               --gresources $(srcdir)/gtktemplate.gresource.xml \
+               $(srcdir)/gtktemplate.vala; \
+       rm -f gtktemplate.c
+
+check: check-gtktemplate
+
+EXTRA_DIST = \
+       gtktemplate.gresource.xml \
+       gtktemplate.ui \
+       gtktemplate.vala \
+       $(NULL)
+
+CLEANFILES = \
+       gtktemplate.c \
+       $(NULL)
diff --git a/tests/gtktemplate/gtktemplate.gresource.xml b/tests/gtktemplate/gtktemplate.gresource.xml
new file mode 100644 (file)
index 0000000..aa9b082
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+       <gresource prefix="/org/example/">
+               <file preprocess="xml-stripblanks">gtktemplate.ui</file>
+       </gresource>
+</gresources>
diff --git a/tests/gtktemplate/gtktemplate.ui b/tests/gtktemplate/gtktemplate.ui
new file mode 100644 (file)
index 0000000..1546d94
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="GtkTemplateTest" parent="GtkApplicationWindow">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">GtkTemplate</property>
+    <property name="default_width">300</property>
+    <property name="default_height">200</property>
+    <property name="show_menubar">False</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkButton" id="button0">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <signal name="clicked" handler="on_clicked_cb" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="button1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <signal name="activate" handler="on_activate_cb" swapped="yes"/>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/tests/gtktemplate/gtktemplate.vala b/tests/gtktemplate/gtktemplate.vala
new file mode 100644 (file)
index 0000000..520fb55
--- /dev/null
@@ -0,0 +1,16 @@
+[GtkTemplate (ui = "/org/example/gtktemplate.ui")]
+public class GtkTemplate : Gtk.ApplicationWindow {
+       [GtkChild]
+       public Gtk.Button button0;
+
+       [GtkChild (internal = true)]
+       public Gtk.Button button1;
+
+       [GtkCallback]
+       void on_clicked_cb (Gtk.Button button) {
+       }
+
+       [GtkCallback (name = "on_activate_cb")]
+       void on_something_cb (Gtk.Button button) {
+       }
+}