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 (known to produce wrong results)
test5: Test a complex selector (not producing the expected
       output atm)
widget-factory.ui:
       The real thing: widget-factory+Adwaita. Note that
       this expedts to be run with GSETTINGS_BACKEND=memory

Note that test4 checks the wrong results that we currently
produce for selectors involving :not. It will have to be
updated when we fix the handling of :not. The widget-factory.ui
testcase will certainly also be affected.
This commit is contained in:
Matthias Clasen 2020-01-16 20:04:00 -05:00
parent 9de31929d6
commit 8ecd4e87e3
20 changed files with 6330 additions and 0 deletions

View File

@ -20,6 +20,12 @@ 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',
'widget-factory.css', 'widget-factory.ui', 'widget-factory.nodes',
]
if get_option('install-tests')

View File

@ -0,0 +1,13 @@
/* Just a basic test of the machinery */
box {
color: red;
}
label {
color: green;
}
label.test2 {
color: blue;
}

View File

@ -0,0 +1,5 @@
window.background:dir(ltr) class
decoration:dir(ltr) class
box.horizontal:dir(ltr) name
label:dir(ltr) name
label.test:dir(ltr) name

View File

@ -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>

View File

@ -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;
}

View File

@ -0,0 +1,48 @@
window.background:dir(ltr) class
decoration:dir(ltr) class
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

View File

@ -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>

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
window.background:dir(ltr) class
decoration:dir(ltr) class
box.horizontal:dir(ltr) name
label:dir(ltr) name|state|hover|disabled|backdrop
label.test:dir(ltr) name|state|hover|disabled|backdrop

View File

@ -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>

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
window.background:dir(ltr) class
decoration:dir(ltr) class
box.horizontal:dir(ltr) name
label.a:dir(ltr)
label.b:dir(ltr)
label.c:dir(ltr)
label.d:dir(ltr)
label.e.f:dir(ltr)

View File

@ -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>

View File

@ -0,0 +1,5 @@
/* an example of a complex selector */
window grid > box ~ button box > checkbutton box + label {
color: red;
}

View File

@ -0,0 +1,10 @@
window.background:dir(ltr) class
decoration:dir(ltr) class
grid.horizontal:dir(ltr) class
label:dir(ltr) class
button:dir(ltr) class
box.horizontal:dir(ltr) class
checkbutton:dir(ltr) class
check:dir(ltr) class
box.horizontal:dir(ltr) class
label:dir(ltr) class

View File

@ -0,0 +1,36 @@
<?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="GtkGrid">
<child>
<object class="GtkLabel"/>
</child>
<child>
<object class="GtkBox"/>
<object class="GtkLabel"/>
<object class="GtkButton">
<child>
<object class="GtkBox">
<child>
<object class="GtkCheckButton">
<child>
<object class="GtkBox"/>
</child>
<child>
<object class="GtkLabel"/>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,2 @@
@import url("resource:///org/gtk/libgtk/theme/Adwaita/gtk-contained.css");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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')