Commit 15674c5b authored by Benjamin Otte's avatar Benjamin Otte

tests: Move stylecontext CSS tests

Use the new CSS infrastructure for part of the old CSS tests. This way
we can probably check for warning messages such as deprecations.
parent 1a763044
......@@ -18,99 +18,6 @@ test_parse_empty (void)
g_object_unref (provider);
}
static void
test_parse_at (void)
{
GtkCssProvider *provider;
GError *error;
gboolean res;
gint i;
const gchar *valid[] = {
"@import \"" SRCDIR "/test.css\";",
"@import '" SRCDIR "/test.css';",
"@import url(\"" SRCDIR "/test.css\");",
"@import url('" SRCDIR "/test.css');",
"@import\nurl (\t\"" SRCDIR "/test.css\" ) ;",
"@define-color bg_color #f9a039;",
"@define-color color @bg_color;",
"@define-color color rgb(100, 99, 88);",
"@define-color color rgba(50%, 50%, 50%, 0.5);",
"@define-color color lighter(#f9a039);",
"@define-color color darker ( @blue ) ;",
"@define-color color shade(@blue, 1.3);",
"@define-color color alpha(@blue, 1.3);",
"@define-color color mix(@blue, @red, 0.2);",
"@define-color color red;",
"@define-color color mix(shade (#121212, 0.5), mix (rgb(10%,20%,100%), @blue,0.5), 0.2);",
"@define-color blue @blue;",
"@define-color blue123_a-b #123;",
"@binding-set gtk-emacs-menu { bind \"<ctrl>n\" { \"move-current\" (next) }; };",
"@binding-set gtk-emacs-text-view {\n"
" bind \"<ctrl>u\" { \"move-cursor\" (paragraph-ends, -1, 0)\n"
" \"delete-from-cursor\" (paragraph-ends, 1) };\n"
"};",
"@binding-set test {\n"
" bind \"<ctrl>space\" { \"set-anchor\" () };\n"
" unbind \"<ctrl>v\";\n"
"};",
NULL
};
const gchar *invalid[] = {
"@import " SRCDIR "/test.css ;",
"@import url ( \"" SRCDIR "/test.css\" xyz );",
"@import url(\");",
"@import url(');",
"@import url(\"abc');",
"@ import ;",
"@define_color blue red;",
"@define-color blue #12234;",
"@define-color blue #12g234;",
"@define-color blue @@;",
"@define-color blue 5!#%4@DG$##x;",
"@define-color color mix(@red, @blue, @green);",
"@define-color color mix(@blue, 0.2, @red);",
"@define-color color mix(0.2, @blue, @red);",
"@define-color color mix(@blue, @red);",
"@define-color color mix(@blue);",
"@define-color color mix();",
"@define-color color rgba(50%, 50%, 50%);",
"@define-color color rgb(50%, a);",
"@define-color 1col rgb(50%, a);",
"@three-dee { some other crap };",
"@binding-set \"foo\";",
"@binding-set foo { bind key { \"action\"() }; };",
"@binding-set foo { bind key { \"action\"() }; };",
"@binding-set foo { bind \"key\" { action() }; };",
"@binding-set foo { bind \"key\"; };",
"@binding-set foo { unbind \"key\" { \"bla\" () }; };",
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_parse_selectors (void)
{
......@@ -563,7 +470,6 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/style/parse/empty", test_parse_empty);
g_test_add_func ("/style/parse/at", test_parse_at);
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);
......
......@@ -25,6 +25,130 @@ clean-local:
rm $(builddir)/*.out.css || true
EXTRA_DIST += \
at-invalid-01.css \
at-invalid-01.errors \
at-invalid-01.ref.css \
at-invalid-02.css \
at-invalid-02.errors \
at-invalid-02.ref.css \
at-invalid-03.css \
at-invalid-03.errors \
at-invalid-03.ref.css \
at-invalid-04.css \
at-invalid-04.errors \
at-invalid-04.ref.css \
at-invalid-05.css \
at-invalid-05.errors \
at-invalid-05.ref.css \
at-invalid-06.css \
at-invalid-06.errors \
at-invalid-06.ref.css \
at-invalid-07.css \
at-invalid-07.errors \
at-invalid-07.ref.css \
at-invalid-08.css \
at-invalid-08.errors \
at-invalid-08.ref.css \
at-invalid-09.css \
at-invalid-09.errors \
at-invalid-09.ref.css \
at-invalid-10.css \
at-invalid-10.errors \
at-invalid-10.ref.css \
at-invalid-11.css \
at-invalid-11.errors \
at-invalid-11.ref.css \
at-invalid-12.css \
at-invalid-12.errors \
at-invalid-12.ref.css \
at-invalid-13.css \
at-invalid-13.errors \
at-invalid-13.ref.css \
at-invalid-14.css \
at-invalid-14.errors \
at-invalid-14.ref.css \
at-invalid-15.css \
at-invalid-15.errors \
at-invalid-15.ref.css \
at-invalid-16.css \
at-invalid-16.errors \
at-invalid-16.ref.css \
at-invalid-17.css \
at-invalid-17.errors \
at-invalid-17.ref.css \
at-invalid-18.css \
at-invalid-18.errors \
at-invalid-18.ref.css \
at-invalid-19.css \
at-invalid-19.errors \
at-invalid-19.ref.css \
at-invalid-20.css \
at-invalid-20.errors \
at-invalid-20.ref.css \
at-invalid-21.css \
at-invalid-21.errors \
at-invalid-21.ref.css \
at-invalid-22.css \
at-invalid-22.errors \
at-invalid-22.ref.css \
at-invalid-23.css \
at-invalid-23.errors \
at-invalid-23.ref.css \
at-invalid-24.css \
at-invalid-24.errors \
at-invalid-24.ref.css \
at-invalid-25.css \
at-invalid-25.errors \
at-invalid-25.ref.css \
at-invalid-26.css \
at-invalid-26.errors \
at-invalid-26.ref.css \
at-invalid-27.css \
at-invalid-27.errors \
at-invalid-27.ref.css \
at-valid-01.css \
at-valid-01.ref.css \
at-valid-02.css \
at-valid-02.ref.css \
at-valid-03.css \
at-valid-03.ref.css \
at-valid-04.css \
at-valid-04.ref.css \
at-valid-05.css \
at-valid-05.ref.css \
at-valid-06.css \
at-valid-06.ref.css \
at-valid-07.css \
at-valid-08.css \
at-valid-08.ref.css \
at-valid-09.css \
at-valid-09.ref.css \
at-valid-10.css \
at-valid-10.ref.css \
at-valid-11.css \
at-valid-11.ref.css \
at-valid-12.css \
at-valid-12.ref.css \
at-valid-13.css \
at-valid-13.ref.css \
at-valid-14.css \
at-valid-14.ref.css \
at-valid-15.css \
at-valid-15.ref.css \
at-valid-16.css \
at-valid-16.ref.css \
at-valid-17.css \
at-valid-18.css \
at-valid-18.ref.css \
at-valid-19.css \
at-valid-19.errors \
at-valid-19.ref.css \
at-valid-20.css \
at-valid-20.errors \
at-valid-20.ref.css \
at-valid-21.css \
at-valid-21.errors \
at-valid-21.ref.css \
boolean.css \
boolean.errors \
boolean.ref.css \
......
at-invalid-01.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@import url ( "./test.css" xyz );
at-invalid-02.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-03.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-04.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-05.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-06.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-07.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color blue #12234;
at-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color blue #12g234;
at-invalid-09.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-10.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color blue 5!#%4@DG$##x;
at-invalid-11.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix(@red, @blue, @green);
at-invalid-12.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix(@blue, 0.2, @red);
at-invalid-13.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix(0.2, @blue, @red);
at-invalid-14.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix(@blue, @red);
at-invalid-15.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix(@blue);
at-invalid-16.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color mix();
at-invalid-17.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color rgba(50%, 50%, 50%);
at-invalid-18.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color color rgb(50%, a);
at-invalid-19.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@define-color 1col rgb(50%, a);
at-invalid-20.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@three-dee { some other crap };
at-invalid-21.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-21.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-22.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
@binding-set foo { bind key { "action"() }; };
at-invalid-23.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-23.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED
@binding-set foo { bind key { "action"() }; };
at-invalid-24.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-24.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED
@binding-set foo { bind "key" { action() }; };
at-invalid-25.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-25.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED
@binding-set foo { bind "key"; };
at-invalid-26.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-26.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED
@binding-set foo { unbind "key" { "bla" () }; };
at-invalid-27.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-27.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED
@import "./simple.css";
foo {
color: rgb(0,0,0);
}
@import './simple.css';
foo {
color: rgb(0,0,0);
}
@import url("./simple.css");
foo {
color: rgb(0,0,0);
}
@import url('./simple.css');
foo {
color: rgb(0,0,0);
}
@import
url( "./simple.css" ) ;
foo {
color: rgb(0,0,0);
}
@define-color bg_color #f9a039;
@define-color bg_color rgb(249,160,57);
@define-color color @bg_color;
@define-color color rgb(100, 99, 88);
@define-color color rgb(100,99,88);
@define-color color rgba(50%, 50%, 50%, 0.5);
@define-color color rgba(128,128,128,0.5);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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