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.
This commit is contained in:
Benjamin Otte 2011-07-21 02:41:42 +02:00
parent 47635a2434
commit d56e8c8e54
79 changed files with 264 additions and 83 deletions

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

View File

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

View File

@ -0,0 +1 @@
* { color }

View File

@ -0,0 +1 @@
declarations-invalid-01.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1 @@
* { color:green; color }

View File

@ -0,0 +1 @@
declarations-invalid-02.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { color:red; color; color:green }

View File

@ -0,0 +1 @@
declarations-invalid-03.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { color:green; color: }

View File

@ -0,0 +1 @@
declarations-invalid-04.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { color:red; color:; color:green }

View File

@ -0,0 +1 @@
declarations-invalid-05.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { color:green; color{;color:maroon} }

View File

@ -0,0 +1 @@
declarations-invalid-06.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { color:red; color{;color:maroon}; color:green }

View File

@ -0,0 +1 @@
declarations-invalid-07.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* {
color: rgb(0,255,0);
}

View File

@ -0,0 +1 @@
* { content: 'Hello

View File

@ -0,0 +1,3 @@
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

View File

@ -0,0 +1 @@
* {}

View File

@ -0,0 +1 @@
* { font: Sans 15 }

View File

@ -0,0 +1,7 @@
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}

View File

@ -0,0 +1 @@
* { font: Sans 15; }

View File

@ -0,0 +1,7 @@
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}

View File

@ -0,0 +1 @@
* { font: bold }

View File

@ -0,0 +1,7 @@
* {
font-family: "Sans";
font-size: 10;
font-style: normal;
font-variant: normal;
font-weight: bold;
}

View File

@ -0,0 +1 @@
* { color: red }

View File

@ -0,0 +1,3 @@
* {
color: rgb(255,0,0);
}

View File

@ -0,0 +1 @@
* { /* just a comment */ }

View File

@ -0,0 +1,3 @@
* { /* multi
line
comment */ }

View File

@ -0,0 +1 @@
* { font: /* comment here */ Sans 15 }

View File

@ -0,0 +1,7 @@
* {
font-family: "Sans";
font-size: 15;
font-style: normal;
font-variant: normal;
font-weight: normal;
}

View File

@ -0,0 +1 @@
* { color: red; background-color: shade (@bg_color, 0.5) }

View File

@ -0,0 +1,4 @@
* {
background-color: shade (@bg_color, 0.5);
color: rgb(255,0,0);
}

View File

@ -0,0 +1 @@
* { margin: 5 }

View File

@ -0,0 +1,6 @@
* {
margin-bottom: 5;
margin-left: 5;
margin-right: 5;
margin-top: 5;
}

View File

@ -0,0 +1 @@
* { margin: 5 10 }

View File

@ -0,0 +1,6 @@
* {
margin-bottom: 5;
margin-left: 10;
margin-right: 10;
margin-top: 5;
}

View File

@ -0,0 +1 @@
* { margin: 5 10 3 }

View File

@ -0,0 +1,6 @@
* {
margin-bottom: 3;
margin-left: 10;
margin-right: 10;
margin-top: 5;
}

View File

@ -0,0 +1 @@
* { margin: 5 10 3 5 }

View File

@ -0,0 +1,6 @@
* {
margin-bottom: 3;
margin-left: 5;
margin-right: 10;
margin-top: 5;
}

View File

@ -0,0 +1 @@
* { padding: 5 }

View File

@ -0,0 +1,6 @@
* {
padding-bottom: 5;
padding-left: 5;
padding-right: 5;
padding-top: 5;
}

View File

@ -0,0 +1 @@
* { padding: 5 10 }

View File

@ -0,0 +1,6 @@
* {
padding-bottom: 5;
padding-left: 10;
padding-right: 10;
padding-top: 5;
}

View File

@ -0,0 +1 @@
* { border-width: 5; border-radius: 10 }

View File

@ -0,0 +1,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;
}

View File

@ -0,0 +1 @@
* { border-color: #ff00ff }

View File

@ -0,0 +1,6 @@
* {
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);
}

View File

@ -0,0 +1 @@
* { engine: definitelydoesnotexist }

View File

@ -0,0 +1 @@
declarations-valid-18.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

@ -0,0 +1,3 @@
* { background-image: -gtk-gradient (linear,
left top, right top,
from (#fff), to (#000)) }

View File

@ -0,0 +1,3 @@
* {
background-image: -gtk-gradient (linear, left top, right top, from (rgb(255,255,255)), to (rgb(0,0,0)));
}

View File

@ -0,0 +1,5 @@
* { background-image: -gtk-gradient (linear,
0.0 0.5, 0.5 1.0,
from (#fff),
color-stop (0.5, #f00),
to (#000)) }

View File

@ -0,0 +1,3 @@
* {
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)));
}

View File

@ -0,0 +1,6 @@
* { background-image: -gtk-gradient (radial,
center center, 0.25,
center center, 0.75,
color-stop (0.0,#fff),
color-stop (1.0,#000))}

View File

@ -0,0 +1,3 @@
* {
background-image: -gtk-gradient (radial, center center, 0.25, center center, 0.75, from (rgb(255,255,255)), to (rgb(0,0,0)));
}

View File

@ -0,0 +1 @@
* { border-image: url("./test.png") 3 4 3 4 stretch }

View File

@ -0,0 +1,6 @@
* {
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;
}

View File

@ -0,0 +1 @@
* { border-image: url("./test.png") 3 4 3 4 repeat stretch}

View File

@ -0,0 +1,6 @@
* {
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;
}

View File

@ -0,0 +1 @@
* { transition: 150ms ease-in-out }

View File

@ -0,0 +1,3 @@
* {
transition: 150ms ease-in-out;
}

View File

@ -0,0 +1 @@
* { transition: 1s linear loop }

View File

@ -0,0 +1,3 @@
* {
transition: 1s linear loop;
}

BIN
tests/css/parser/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B