summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-05-02 17:21:31 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-05-02 17:39:06 -0400
commitd22f351e283616c588c1f346102e889b1f925678 (patch)
tree1fb9d32733dbb8514b7ef4d45aefc558e71e44c1 /testsuite
parent4f115ad9401e2902582a4daa83544c6877643dfc (diff)
downloadgtk+-d22f351e283616c588c1f346102e889b1f925678.tar.gz
gtk-builder-tool: Add some tests
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Makefile.am2
-rw-r--r--testsuite/tools/Makefile.am26
-rw-r--r--testsuite/tools/simplify/test1.expected5
-rw-r--r--testsuite/tools/simplify/test1.ui6
-rw-r--r--testsuite/tools/simplify/test2.expected6
-rw-r--r--testsuite/tools/simplify/test2.ui6
-rw-r--r--testsuite/tools/simplify/test3.expected6
-rw-r--r--testsuite/tools/simplify/test3.ui6
-rw-r--r--testsuite/tools/simplify/test4.expected6
-rw-r--r--testsuite/tools/simplify/test4.ui6
-rw-r--r--testsuite/tools/simplify/test5.expected9
-rw-r--r--testsuite/tools/simplify/test5.ui12
-rw-r--r--testsuite/tools/simplify/test6.expected5
-rw-r--r--testsuite/tools/simplify/test6.ui6
-rw-r--r--testsuite/tools/simplify/test7.expected8
-rw-r--r--testsuite/tools/simplify/test7.ui12
-rw-r--r--testsuite/tools/simplify/test8.expected11
-rw-r--r--testsuite/tools/simplify/test8.ui12
-rwxr-xr-xtestsuite/tools/test-simplify27
19 files changed, 176 insertions, 1 deletions
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 33bbe37652..418aa417ae 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/Makefile.decl
-SUBDIRS = gdk gtk a11y css reftests
+SUBDIRS = gdk gtk a11y css reftests tools
-include $(top_srcdir)/git.mk
diff --git a/testsuite/tools/Makefile.am b/testsuite/tools/Makefile.am
new file mode 100644
index 0000000000..6ccefc174d
--- /dev/null
+++ b/testsuite/tools/Makefile.am
@@ -0,0 +1,26 @@
+include $(top_srcdir)/Makefile.decl
+
+NULL =
+
+test_simplify = \
+ simplify/test1.ui simplify/test1.expected \
+ simplify/test2.ui simplify/test2.expected \
+ simplify/test3.ui simplify/test3.expected \
+ simplify/test4.ui simplify/test4.expected \
+ simplify/test5.ui simplify/test5.expected \
+ simplify/test6.ui simplify/test6.expected \
+ simplify/test7.ui simplify/test7.expected \
+ simplify/test8.ui simplify/test8.expected \
+ $(NULL)
+
+EXTRA_DIST += \
+ $(test_simplify)
+
+TESTS_ENVIRONMENT = \
+ GTK_BUILDER_TOOL="$(top_builddir)/gtk/gtk-builder-tool"
+
+TEST_PROGS += \
+ test-simplify \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/testsuite/tools/simplify/test1.expected b/testsuite/tools/simplify/test1.expected
new file mode 100644
index 0000000000..de1472e5cd
--- /dev/null
+++ b/testsuite/tools/simplify/test1.expected
@@ -0,0 +1,5 @@
+<!-- default property gets stripped -->
+<interface>
+ <object class="GtkWindow">
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test1.ui b/testsuite/tools/simplify/test1.ui
new file mode 100644
index 0000000000..4f03810de1
--- /dev/null
+++ b/testsuite/tools/simplify/test1.ui
@@ -0,0 +1,6 @@
+<!-- default property gets stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible">False</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test2.expected b/testsuite/tools/simplify/test2.expected
new file mode 100644
index 0000000000..20ffe8d3bb
--- /dev/null
+++ b/testsuite/tools/simplify/test2.expected
@@ -0,0 +1,6 @@
+<!-- non-default property not stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible">True</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test2.ui b/testsuite/tools/simplify/test2.ui
new file mode 100644
index 0000000000..20ffe8d3bb
--- /dev/null
+++ b/testsuite/tools/simplify/test2.ui
@@ -0,0 +1,6 @@
+<!-- non-default property not stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible">True</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test3.expected b/testsuite/tools/simplify/test3.expected
new file mode 100644
index 0000000000..2490e7900a
--- /dev/null
+++ b/testsuite/tools/simplify/test3.expected
@@ -0,0 +1,6 @@
+<!-- translatable property not stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible" translatable="yes">False</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test3.ui b/testsuite/tools/simplify/test3.ui
new file mode 100644
index 0000000000..2490e7900a
--- /dev/null
+++ b/testsuite/tools/simplify/test3.ui
@@ -0,0 +1,6 @@
+<!-- translatable property not stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible" translatable="yes">False</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test4.expected b/testsuite/tools/simplify/test4.expected
new file mode 100644
index 0000000000..41d8ecce20
--- /dev/null
+++ b/testsuite/tools/simplify/test4.expected
@@ -0,0 +1,6 @@
+<!-- irrelevant comments and context are stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible">True</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test4.ui b/testsuite/tools/simplify/test4.ui
new file mode 100644
index 0000000000..eb5b0f0ea6
--- /dev/null
+++ b/testsuite/tools/simplify/test4.ui
@@ -0,0 +1,6 @@
+<!-- irrelevant comments and context are stripped -->
+<interface>
+ <object class="GtkWindow">
+ <property name="visible" comments="foo" context="bla">True</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test5.expected b/testsuite/tools/simplify/test5.expected
new file mode 100644
index 0000000000..1fb898bc0e
--- /dev/null
+++ b/testsuite/tools/simplify/test5.expected
@@ -0,0 +1,9 @@
+<!-- placeholders are stripped -->
+<interface>
+ <object class="GtkWindow">
+ <child>
+ <object class="GtkBox">
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test5.ui b/testsuite/tools/simplify/test5.ui
new file mode 100644
index 0000000000..e379abdb2c
--- /dev/null
+++ b/testsuite/tools/simplify/test5.ui
@@ -0,0 +1,12 @@
+<!-- placeholders are stripped -->
+<interface>
+ <object class="GtkWindow">
+ <child>
+ <object class="GtkBox">
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test6.expected b/testsuite/tools/simplify/test6.expected
new file mode 100644
index 0000000000..8d4495b50e
--- /dev/null
+++ b/testsuite/tools/simplify/test6.expected
@@ -0,0 +1,5 @@
+<!-- non-canonical property name works -->
+<interface>
+ <object class="GtkWindow">
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test6.ui b/testsuite/tools/simplify/test6.ui
new file mode 100644
index 0000000000..e4f394dc21
--- /dev/null
+++ b/testsuite/tools/simplify/test6.ui
@@ -0,0 +1,6 @@
+<!-- non-canonical property name works -->
+<interface>
+ <object class="GtkWindow">
+ <property name="default_width">-1</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test7.expected b/testsuite/tools/simplify/test7.expected
new file mode 100644
index 0000000000..a75c4d4570
--- /dev/null
+++ b/testsuite/tools/simplify/test7.expected
@@ -0,0 +1,8 @@
+<!-- default child property gets stripped -->
+<interface>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel"/>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test7.ui b/testsuite/tools/simplify/test7.ui
new file mode 100644
index 0000000000..52e0da2f4b
--- /dev/null
+++ b/testsuite/tools/simplify/test7.ui
@@ -0,0 +1,12 @@
+<!-- default child property gets stripped -->
+<interface>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test8.expected b/testsuite/tools/simplify/test8.expected
new file mode 100644
index 0000000000..d5b6825347
--- /dev/null
+++ b/testsuite/tools/simplify/test8.expected
@@ -0,0 +1,11 @@
+<!-- non-default child property remains -->
+<interface>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel"/>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify/test8.ui b/testsuite/tools/simplify/test8.ui
new file mode 100644
index 0000000000..1aec7adfea
--- /dev/null
+++ b/testsuite/tools/simplify/test8.ui
@@ -0,0 +1,12 @@
+<!-- non-default child property remains -->
+<interface>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/tools/test-simplify b/testsuite/tools/test-simplify
new file mode 100755
index 0000000000..2de4366b16
--- /dev/null
+++ b/testsuite/tools/test-simplify
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+GTK_BUILDER_TOOL=${GTK_BUILDER_TOOL:-gtk-builder-tool}
+TEST_DATA_DIR=${TEST_DATA_DIR:-./simplify}
+TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
+
+shopt -s nullglob
+TESTS=( "$TEST_DATA_DIR"/*.ui )
+
+echo "1..${#TESTS}"
+
+I=1
+for t in ${TESTS[*]}; do
+ name=$(basename $t .ui)
+ expected="$TEST_DATA_DIR/$name.expected"
+ result="$TEST_RESULT_DIR/$name.out"
+
+ $GTK_BUILDER_TOOL simplify $t 2>/dev/null >$result
+
+ if diff "$expected" "$result" > /dev/null; then
+ echo "ok $I $name"
+ else
+ echo "not ok $I $name"
+ fi
+
+ I=$((I+1))
+done