[gtk/matthiasc/css-change-tracking-4: 12/12] Add testcases for css change flags
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/css-change-tracking-4: 12/12] Add testcases for css change flags
- Date: Fri, 17 Jan 2020 16:45:17 +0000 (UTC)
commit d75327197c8f0dda8e19cdbab91ed8e13d901c97
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 16 20:04:00 2020 -0500
Add testcases for css change flags
Add various tests for the change flag computation that
we do in the css selector tree.
test1: Just test the basic machinery of this test
test2: Trigger every change flag at least once
test3: Test that multiple states combine as expected
test4: Test negations
testsuite/css/change/meson.build | 5 +
testsuite/css/change/test1.css | 13 +++
testsuite/css/change/test1.nodes | 5 +
testsuite/css/change/test1.ui | 26 +++++
testsuite/css/change/test2.css | 186 ++++++++++++++++++++++++++++++
testsuite/css/change/test2.nodes | 48 ++++++++
testsuite/css/change/test2.ui | 237 +++++++++++++++++++++++++++++++++++++++
testsuite/css/change/test3.css | 21 ++++
testsuite/css/change/test3.nodes | 5 +
testsuite/css/change/test3.ui | 26 +++++
testsuite/css/change/test4.css | 25 +++++
testsuite/css/change/test4.nodes | 8 ++
testsuite/css/change/test4.ui | 39 +++++++
testsuite/css/meson.build | 1 +
14 files changed, 645 insertions(+)
---
diff --git a/testsuite/css/change/meson.build b/testsuite/css/change/meson.build
index f12c34d67f..59a2562710 100644
--- a/testsuite/css/change/meson.build
+++ b/testsuite/css/change/meson.build
@@ -20,6 +20,11 @@ test('change', test_change,
suite: 'css')
test_data = [
+ 'test1.css', 'test1.ui', 'test1.nodes',
+ 'test2.css', 'test2.ui', 'test2.nodes',
+ 'test3.css', 'test3.ui', 'test3.nodes',
+ 'test4.css', 'test4.ui', 'test4.nodes',
+ 'test5.css', 'test5.ui', 'test5.nodes',
]
if get_option('install-tests')
diff --git a/testsuite/css/change/test1.css b/testsuite/css/change/test1.css
new file mode 100644
index 0000000000..9ffd3c7551
--- /dev/null
+++ b/testsuite/css/change/test1.css
@@ -0,0 +1,13 @@
+/* Just a basic test of the machinery */
+
+box {
+ color: red;
+}
+
+label {
+ color: green;
+}
+
+label.test2 {
+ color: blue;
+}
diff --git a/testsuite/css/change/test1.nodes b/testsuite/css/change/test1.nodes
new file mode 100644
index 0000000000..4cf52ec676
--- /dev/null
+++ b/testsuite/css/change/test1.nodes
@@ -0,0 +1,5 @@
+[window.background:dir(ltr)]
+ decoration:dir(ltr)
+ box.horizontal:dir(ltr) name
+ label:dir(ltr) name
+ label.test:dir(ltr) name
diff --git a/testsuite/css/change/test1.ui b/testsuite/css/change/test1.ui
new file mode 100644
index 0000000000..b5ddb9c1cf
--- /dev/null
+++ b/testsuite/css/change/test1.ui
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="window1">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Hello World!</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Hello World!</property>
+ <style><class name="test"/></style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/css/change/test2.css b/testsuite/css/change/test2.css
new file mode 100644
index 0000000000..228f9537d2
--- /dev/null
+++ b/testsuite/css/change/test2.css
@@ -0,0 +1,186 @@
+/* trigger all change flags at least once */
+
+box {
+ color: green;
+}
+
+label {
+ color: green;
+}
+
+label.a:disabled {
+ color: blue;
+}
+
+label.b:selected {
+ color: blue;
+}
+
+label.c:backdrop {
+ color: blue;
+}
+
+label.d:focus {
+ color: blue;
+}
+
+label.e:first-child {
+ color: blue;
+}
+
+label.f:last-child {
+ color: blue;
+}
+
+label.g:nth-child(2) {
+ color: blue;
+}
+
+label.h:nth-last-child(2) {
+ color: blue;
+}
+
+label.i:hover {
+ color: blue;
+}
+
+label ~ label.j {
+ color: blue;
+}
+
+#label ~ label.j1 {
+ color: blue;
+}
+
+label.test ~ label.k {
+ color: blue;
+}
+
+label:hover ~ label.l {
+ color: blue;
+}
+
+label:disabled ~ label.m {
+ color: blue;
+}
+
+label:backdrop ~ label.n {
+ color: blue;
+}
+
+label:selected ~ label.o {
+ color: blue;
+}
+
+label:focus ~ label.p {
+ color: blue;
+}
+
+label:first-child ~ label.q {
+ color: blue;
+}
+
+label:last-child ~ label.r {
+ color: blue;
+}
+
+label:nth-child(2n+5) ~ label.s {
+ color: blue;
+}
+
+label:nth-last-child(2n+5) ~ label.t {
+ color: blue;
+}
+
+box label.u {
+ color: blue;
+}
+
+#box label.u1 {
+ color: blue;
+}
+
+box.test label.v {
+ color: blue;
+}
+
+box:focus label.w {
+ color: blue;
+}
+
+box:hover label.x {
+ color: blue;
+}
+
+box:disabled label.y {
+ color: blue;
+}
+
+box:backdrop label.z {
+ color: blue;
+}
+
+box:selected label.aa {
+ color: blue;
+}
+
+box:first-child label.bb {
+ color: blue;
+}
+
+box:last-child label.cc {
+ color: blue;
+}
+
+box:nth-child(3) label.dd {
+ color: blue;
+}
+
+box:nth-last-child(3) label.ee {
+ color: blue;
+}
+
+box~box label.ff {
+ color: blue;
+}
+
+#box1~box label.gg {
+ color: blue;
+}
+
+box.test~box label.hh {
+ color: blue;
+}
+
+box:focus~box label.ii {
+ color: blue;
+}
+
+box:hover~box label.jj {
+ color: blue;
+}
+
+box:backdrop~box label.kk {
+ color: blue;
+}
+
+box:selected~box label.ll {
+ color: blue;
+}
+
+box:first-child~box label.mm {
+ color: blue;
+}
+
+box:last-child~box label.nn {
+ color: blue;
+}
+
+box:nth-child(2)~box label.oo {
+ color: blue;
+}
+
+box:nth-last-child(2)~box label.pp {
+ color: blue;
+}
+
diff --git a/testsuite/css/change/test2.nodes b/testsuite/css/change/test2.nodes
new file mode 100644
index 0000000000..e0da6cbcef
--- /dev/null
+++ b/testsuite/css/change/test2.nodes
@@ -0,0 +1,48 @@
+[window.background:dir(ltr)]
+ decoration:dir(ltr)
+ box#box.horizontal.test:dir(ltr) name
+ label:dir(ltr) name
+ label.a:dir(ltr) class|name|disabled
+ label.b:dir(ltr) class|name|selected
+ label.c:dir(ltr) class|name|backdrop
+ label.d:dir(ltr) class|name|state
+ label.e:dir(ltr) class|name|first-child
+ label.f:dir(ltr) class|name|last-child
+ label.g:dir(ltr) class|name|nth-child
+ label.h:dir(ltr) class|name|nth-last-child
+ label.i:dir(ltr) class|name|hover
+ label.j:dir(ltr) class|name|sibling-name
+ label.j1:dir(ltr) class|name|sibling-id
+ label.k:dir(ltr) class|name|sibling-class|sibling-name
+ label.l:dir(ltr) class|name|sibling-name|sibling-hover
+ label.m:dir(ltr) class|name|sibling-name|sibling-disabled
+ label.n:dir(ltr) class|name|sibling-name|sibling-backdrop
+ label.o:dir(ltr) class|name|sibling-name|sibling-selected
+ label.p:dir(ltr) class|name|sibling-name|sibling-state
+ label.q:dir(ltr) class|name|sibling-name|sibling-first-child
+ label.r:dir(ltr) class|name|sibling-name|sibling-last-child
+ label.s:dir(ltr) class|name|nth-child|sibling-name|sibling-nth-child
+ label.t:dir(ltr) class|name|nth-last-child|sibling-name|sibling-nth-last-child
+ label.u:dir(ltr) class|name|parent-name
+ label.u1:dir(ltr) class|name|parent-id
+ label.v:dir(ltr) class|name|parent-class|parent-name
+ label.w:dir(ltr) class|name|parent-name|parent-state
+ label.x:dir(ltr) class|name|parent-name|parent-hover
+ label.y:dir(ltr) class|name|parent-name|parent-disabled
+ label.z:dir(ltr) class|name|parent-name|parent-backdrop
+ label.aa:dir(ltr) class|name|parent-name|parent-selected
+ label.bb:dir(ltr) class|name|parent-name|parent-first-child
+ label.cc:dir(ltr) class|name|parent-name|parent-last-child
+ label.dd:dir(ltr) class|name|parent-name|parent-nth-child
+ label.ee:dir(ltr) class|name|parent-name|parent-nth-last-child
+ label.ff:dir(ltr) class|name|parent-name|parent-sibling-name
+ label.gg:dir(ltr) class|name|parent-name|parent-sibling-id
+ label.hh:dir(ltr) class|name|parent-name|parent-sibling-class|parent-sibling-name
+ label.ii:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-state
+ label.jj:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-hover
+ label.kk:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-backdrop
+ label.ll:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-selected
+ label.mm:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-first-child
+ label.nn:dir(ltr) class|name|parent-name|parent-sibling-name|parent-sibling-last-child
+ label.oo:dir(ltr) class|name|parent-name|parent-nth-child|parent-sibling-name|parent-sibling-nth-child
+ label.pp:dir(ltr)
class|name|parent-name|parent-nth-last-child|parent-sibling-name|parent-sibling-nth-last-child
diff --git a/testsuite/css/change/test2.ui b/testsuite/css/change/test2.ui
new file mode 100644
index 0000000000..f679c5ac5d
--- /dev/null
+++ b/testsuite/css/change/test2.ui
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="window1">
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkBox">
+ <property name="name">box</property>
+ <style><class name="test"/></style>
+ <child>
+ <object class="GtkLabel">
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="a"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="b"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="c"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="d"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="e"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="f"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="g"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="h"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="i"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="j"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="j1"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="k"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="l"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="m"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="n"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="o"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="p"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="q"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="r"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="s"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="t"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="u"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="u1"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="v"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="w"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="x"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="y"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="z"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="aa"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="bb"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="cc"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="dd"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="ee"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="ff"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="gg"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="hh"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="ii"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="jj"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="kk"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="ll"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="mm"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="nn"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="oo"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="pp"/></style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/css/change/test3.css b/testsuite/css/change/test3.css
new file mode 100644
index 0000000000..c081d895fa
--- /dev/null
+++ b/testsuite/css/change/test3.css
@@ -0,0 +1,21 @@
+/* test combining multiple state changes */
+
+box {
+ color: red;
+}
+
+label:hover {
+ color: green;
+}
+
+label:backdrop {
+ color: blue;
+}
+
+label:disabled {
+ color: blue;
+}
+
+label:focus {
+ color: blue;
+}
diff --git a/testsuite/css/change/test3.nodes b/testsuite/css/change/test3.nodes
new file mode 100644
index 0000000000..c2afcaf509
--- /dev/null
+++ b/testsuite/css/change/test3.nodes
@@ -0,0 +1,5 @@
+[window.background:dir(ltr)]
+ decoration:dir(ltr)
+ box.horizontal:dir(ltr) name
+ label:dir(ltr) name|state|hover|disabled|backdrop
+ label.test:dir(ltr) name|state|hover|disabled|backdrop
diff --git a/testsuite/css/change/test3.ui b/testsuite/css/change/test3.ui
new file mode 100644
index 0000000000..b5ddb9c1cf
--- /dev/null
+++ b/testsuite/css/change/test3.ui
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="window1">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Hello World!</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Hello World!</property>
+ <style><class name="test"/></style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/css/change/test4.css b/testsuite/css/change/test4.css
new file mode 100644
index 0000000000..425600637a
--- /dev/null
+++ b/testsuite/css/change/test4.css
@@ -0,0 +1,25 @@
+/* test negations */
+
+box {
+ color: red;
+}
+
+label.a:not(:hover) {
+ color: green;
+}
+
+label.b:not(:hover):backdrop {
+ color: green;
+}
+
+box:not(:hover) label.c {
+ color: green;
+}
+
+box:not(:hover):backdrop label.d {
+ color: green;
+}
+
+box:not(:hover):backdrop label.e:not(.f) {
+ color: green;
+}
diff --git a/testsuite/css/change/test4.nodes b/testsuite/css/change/test4.nodes
new file mode 100644
index 0000000000..a357d7b08a
--- /dev/null
+++ b/testsuite/css/change/test4.nodes
@@ -0,0 +1,8 @@
+[window.background:dir(ltr)]
+ decoration:dir(ltr)
+ box.horizontal:dir(ltr) name
+ label.a:dir(ltr) class|name|hover
+ label.b:dir(ltr) class|name|hover|backdrop
+ label.c:dir(ltr) class|name|parent-name|parent-hover
+ label.d:dir(ltr) class|name|parent-name|parent-hover|parent-backdrop
+ label.e.f:dir(ltr)
diff --git a/testsuite/css/change/test4.ui b/testsuite/css/change/test4.ui
new file mode 100644
index 0000000000..7ec26d956a
--- /dev/null
+++ b/testsuite/css/change/test4.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="window1">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="a"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="b"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="c"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="d"/></style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <style><class name="e"/></style>
+ <style><class name="f"/></style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/css/meson.build b/testsuite/css/meson.build
index eefea5aff8..98509c29ca 100644
--- a/testsuite/css/meson.build
+++ b/testsuite/css/meson.build
@@ -1,6 +1,7 @@
subdir('parser')
subdir('nodes')
subdir('style')
+subdir('change')
testexecdir = join_paths(installed_test_bindir, 'css')
testdatadir = join_paths(installed_test_datadir, 'css')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]