Commit d56e8c8e authored by Benjamin Otte's avatar Benjamin Otte

tests: Move declaration tests to new test infrastructure

This way, we can test more feature of them, in particular check for
different errors, which were causing test failures.
parent 47635a24
......@@ -66,88 +66,6 @@ test_parse_selectors (void)
}
}
static void
test_parse_declarations (void)
{
GtkCssProvider *provider;
GError *error;
gboolean res;
gint i;
const gchar *valid[] = {
"* {}",
"* { font: Sans 15 }",
"* { font: Sans 15; }",
"* { font: bold }",
"* { color: red }",
"* { /* just a comment */ }",
"* { /* multi\nline\ncomment */ }",
"* { font: /* comment here */ Sans 15 }",
"* { color: red; background-color: shade (@bg_color, 0.5) }",
"* { margin: 5 }",
"* { margin: 5 10 }",
"* { margin: 5 10 3 }",
"* { margin: 5 10 3 5 }",
"* { padding: 5 }",
"* { padding: 5 10 }",
"* { border-width: 5; border-radius: 10 }",
"* { border-color: #ff00ff }",
"* { engine: clearlooks }",
"* { background-image: -gtk-gradient (linear, \n"
" left top, right top, \n"
" from (#fff), to (#000)) }",
"* { background-image: -gtk-gradient (linear, \n"
" 0.0 0.5, 0.5 1.0, \n"
" from (#fff), \n"
" color-stop (0.5, #f00),\n"
" to (#000)) }",
"* { background-image: -gtk-gradient (radial, \n"
" center center, 0.2, \n"
" center center, 0.8, \n"
" color-stop (0.0,#fff),\n"
" color-stop (1.0,#000))}\n",
"* { border-image: url(\"" SRCDIR "/test.png\") 3 4 3 4 stretch }",
"* { border-image: url(\"" SRCDIR "/test.png\") 3 4 3 4 repeat stretch}",
"* { transition: 150ms ease-in-out }",
"* { transition: 1s linear loop }",
NULL
};
const gchar *invalid[] = {
"* { color }",
"* { color:green; color }",
"* { color:red; color; color:green }",
"* { color:green; color: }",
"* { color:red; color:; color:green }",
"* { color:green; color{;color:maroon} }",
"* { color:red; color{;color:maroon}; color:green }",
"* { content: 'Hello",
NULL
};
error = NULL;
for (i = 0; valid[i]; i++)
{
provider = gtk_css_provider_new ();
res = gtk_css_provider_load_from_data (provider, valid[i], -1, &error);
if (error)
g_print ("parsing '%s': got unexpected error: %s\n", valid[i], error->message);
g_assert_no_error (error);
g_assert (res);
g_object_unref (provider);
}
for (i = 0; invalid[i]; i++)
{
provider = gtk_css_provider_new ();
res = gtk_css_provider_load_from_data (provider, invalid[i], -1, &error);
g_assert_error (error, GTK_CSS_PROVIDER_ERROR, GTK_CSS_PROVIDER_ERROR_FAILED);
g_assert (!res);
g_object_unref (provider);
g_clear_error (&error);
}
}
static void
test_path (void)
{
......@@ -432,7 +350,6 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/style/parse/selectors", test_parse_selectors);
g_test_add_func ("/style/parse/declarations", test_parse_declarations);
g_test_add_func ("/style/path", test_path);
g_test_add_func ("/style/match", test_match);
g_test_add_func ("/style/style-property", test_style_property);
......
......@@ -175,6 +175,81 @@ EXTRA_DIST += \
declarations.css \
declarations.errors \
declarations.ref.css \
declarations-invalid-01.css \
declarations-invalid-01.errors \
declarations-invalid-01.ref.css \
declarations-invalid-02.css \
declarations-invalid-02.errors \
declarations-invalid-02.ref.css \
declarations-invalid-03.css \
declarations-invalid-03.errors \
declarations-invalid-03.ref.css \
declarations-invalid-04.css \
declarations-invalid-04.errors \
declarations-invalid-04.ref.css \
declarations-invalid-05.css \
declarations-invalid-05.errors \
declarations-invalid-05.ref.css \
declarations-invalid-06.css \
declarations-invalid-06.errors \
declarations-invalid-06.ref.css \
declarations-invalid-07.css \
declarations-invalid-07.errors \
declarations-invalid-07.ref.css \
declarations-invalid-08.css \
declarations-invalid-08.errors \
declarations-invalid-08.ref.css \
declarations-valid-01.css \
declarations-valid-01.ref.css \
declarations-valid-02.css \
declarations-valid-02.ref.css \
declarations-valid-03.css \
declarations-valid-03.ref.css \
declarations-valid-04.css \
declarations-valid-04.ref.css \
declarations-valid-05.css \
declarations-valid-05.ref.css \
declarations-valid-06.css \
declarations-valid-06.ref.css \
declarations-valid-07.css \
declarations-valid-07.ref.css \
declarations-valid-08.css \
declarations-valid-08.ref.css \
declarations-valid-09.css \
declarations-valid-09.ref.css \
declarations-valid-10.css \
declarations-valid-10.ref.css \
declarations-valid-11.css \
declarations-valid-11.ref.css \
declarations-valid-12.css \
declarations-valid-12.ref.css \
declarations-valid-13.css \
declarations-valid-13.ref.css \
declarations-valid-14.css \
declarations-valid-14.ref.css \
declarations-valid-15.css \
declarations-valid-15.ref.css \
declarations-valid-16.css \
declarations-valid-16.ref.css \
declarations-valid-17.css \
declarations-valid-17.ref.css \
declarations-valid-18.css \
declarations-valid-18.errors \
declarations-valid-18.ref.css \
declarations-valid-19.css \
declarations-valid-19.ref.css \
declarations-valid-20.css \
declarations-valid-20.ref.css \
declarations-valid-21.css \
declarations-valid-21.ref.css \
declarations-valid-22.css \
declarations-valid-22.ref.css \
declarations-valid-23.css \
declarations-valid-23.ref.css \
declarations-valid-24.css \
declarations-valid-24.ref.css \
declarations-valid-25.css \
declarations-valid-25.ref.css \
does-not-exist.css \
does-not-exist.errors \
does-not-exist.ref.css \
......
declarations-invalid-01.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
declarations-invalid-02.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* { color:red; color; color:green }
declarations-invalid-03.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
declarations-invalid-04.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* { color:red; color:; color:green }
declarations-invalid-05.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* { color:green; color{;color:maroon} }
declarations-invalid-06.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* { color:red; color{;color:maroon}; color:green }
declarations-invalid-07.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
declarations-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_NAME
declarations-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
declarations-invalid-08.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}
* {
font-family: "Sans";
font-size: 10;
font-style: normal;
font-variant: normal;
font-weight: bold;
}
* { /* multi
line
comment */ }
* { font: /* comment here */ Sans 15 }
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}
* { color: red; background-color: shade (@bg_color, 0.5) }
* {
background-color: shade (@bg_color, 0.5);
color: rgb(255,0,0);
}
* {
margin-bottom: 5;
margin-left: 5;
margin-right: 5;
margin-top: 5;
}
* {
margin-bottom: 5;
margin-left: 10;
margin-right: 10;
margin-top: 5;
}
* {
margin-bottom: 3;
margin-left: 10;
margin-right: 10;
margin-top: 5;
}
* {
margin-bottom: 3;
margin-left: 5;
margin-right: 10;
margin-top: 5;
}
* {
padding-bottom: 5;
padding-left: 5;
padding-right: 5;
padding-top: 5;
}
* {
padding-bottom: 5;
padding-left: 10;
padding-right: 10;
padding-top: 5;
}
* { border-width: 5; border-radius: 10 }
* {
border-bottom-left-radius: 10;
border-bottom-right-radius: 10;
border-bottom-width: 5;
border-left-width: 5;
border-right-width: 5;
border-top-left-radius: 10;
border-top-right-radius: 10;
border-top-width: 5;
}
* {
border-bottom-color: rgb(255,0,255);
border-left-color: rgb(255,0,255);
border-right-color: rgb(255,0,255);
border-top-color: rgb(255,0,255);
}
* { engine: definitelydoesnotexist }
declarations-valid-18.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
* { background-image: -gtk-gradient (linear,
left top, right top,
from (#fff), to (#000)) }
* {
background-image: -gtk-gradient (linear, left top, right top, from (rgb(255,255,255)), to (rgb(0,0,0)));
}
* { background-image: -gtk-gradient (linear,
0.0 0.5, 0.5 1.0,
from (#fff),
color-stop (0.5, #f00),
to (#000)) }
* {
background-image: -gtk-gradient (linear, left center, center bottom, from (rgb(255,255,255)), color-stop (0.5, rgb(255,0,0)), to (rgb(0,0,0)));
}
* { background-image: -gtk-gradient (radial,
center center, 0.25,
center center, 0.75,
color-stop (0.0,#fff),
color-stop (1.0,#000))}
* {
background-image: -gtk-gradient (radial, center center, 0.25, center center, 0.75, from (rgb(255,255,255)), to (rgb(0,0,0)));
}
* { border-image: url("./test.png") 3 4 3 4 stretch }
* {
border-image-repeat: stretch;
border-image-slice: 3 4;
border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABmJLR0QA/wD/AP+gvaeTAAAAFUlEQVQImQXBAQEAAACAEP9PF1CpMCnkBftPnd1xAAAAAElFTkSuQmCC");
border-image-width: none;
}
* { border-image: url("./test.png") 3 4 3 4 repeat stretch}
* {
border-image-repeat: repeat stretch;
border-image-slice: 3 4;
border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABmJLR0QA/wD/AP+gvaeTAAAAFUlEQVQImQXBAQEAAACAEP9PF1CpMCnkBftPnd1xAAAAAElFTkSuQmCC");
border-image-width: none;
}
* { transition: 150ms ease-in-out }
* {
transition: 150ms ease-in-out;
}
* { transition: 1s linear loop }
* {
transition: 1s linear loop;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment