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.
This commit is contained in:
Benjamin Otte 2011-07-20 02:26:50 +02:00
parent 1a763044fe
commit 15674c5bd4
126 changed files with 241 additions and 94 deletions

View File

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

View File

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

View File

@ -0,0 +1 @@
@import ./test.css ;

View File

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

View File

View File

@ -0,0 +1 @@
@import url ( "./test.css" xyz );

View File

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

View File

View File

@ -0,0 +1 @@
@import url(");

View File

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

View File

View File

@ -0,0 +1 @@
@import url(');

View File

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

View File

View File

@ -0,0 +1 @@
@import url("abc');

View File

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

View File

View File

@ -0,0 +1 @@
@ import ;

View File

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

View File

View File

@ -0,0 +1 @@
@define_color blue red;

View File

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

View File

View File

@ -0,0 +1 @@
@define-color blue #12234;

View File

@ -0,0 +1 @@
at-invalid-08.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color blue #12g234;

View File

@ -0,0 +1 @@
at-invalid-09.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color blue @@;

View File

@ -0,0 +1 @@
at-invalid-10.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color blue 5!#%4@DG$##x;

View File

@ -0,0 +1 @@
at-invalid-11.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix(@red, @blue, @green);

View File

@ -0,0 +1 @@
at-invalid-12.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix(@blue, 0.2, @red);

View File

@ -0,0 +1 @@
at-invalid-13.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix(0.2, @blue, @red);

View File

@ -0,0 +1 @@
at-invalid-14.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix(@blue, @red);

View File

@ -0,0 +1 @@
at-invalid-15.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix(@blue);

View File

@ -0,0 +1 @@
at-invalid-16.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color mix();

View File

@ -0,0 +1 @@
at-invalid-17.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color rgba(50%, 50%, 50%);

View File

@ -0,0 +1 @@
at-invalid-18.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color color rgb(50%, a);

View File

@ -0,0 +1 @@
at-invalid-19.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@define-color 1col rgb(50%, a);

View File

@ -0,0 +1 @@
at-invalid-20.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@three-dee { some other crap };

View File

@ -0,0 +1,2 @@
at-invalid-21.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-21.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@binding-set "foo";

View File

@ -0,0 +1 @@
at-invalid-22.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX

View File

View File

@ -0,0 +1 @@
@binding-set foo { bind key { "action"() }; };

View File

@ -0,0 +1,2 @@
at-invalid-23.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-23.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED

View File

View File

@ -0,0 +1 @@
@binding-set foo { bind key { "action"() }; };

View File

@ -0,0 +1,2 @@
at-invalid-24.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-24.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED

View File

View File

@ -0,0 +1 @@
@binding-set foo { bind "key" { action() }; };

View File

@ -0,0 +1,2 @@
at-invalid-25.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-25.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED

View File

View File

@ -0,0 +1 @@
@binding-set foo { bind "key"; };

View File

@ -0,0 +1,2 @@
at-invalid-26.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-26.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED

View File

View File

@ -0,0 +1 @@
@binding-set foo { unbind "key" { "bla" () }; };

View File

@ -0,0 +1,2 @@
at-invalid-27.css:1: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
at-invalid-27.css:1: error: GTK_CSS_PROVIDER_ERROR_DEPRECATED

View File

View File

@ -0,0 +1 @@
@import "./simple.css";

View File

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

View File

@ -0,0 +1 @@
@import './simple.css';

View File

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

View File

@ -0,0 +1 @@
@import url("./simple.css");

View File

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

View File

@ -0,0 +1 @@
@import url('./simple.css');

View File

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

View File

@ -0,0 +1,2 @@
@import
url( "./simple.css" ) ;

View File

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

View File

@ -0,0 +1 @@
@define-color bg_color #f9a039;

View File

@ -0,0 +1 @@
@define-color bg_color rgb(249,160,57);

View File

@ -0,0 +1 @@
@define-color color @bg_color;

View File

@ -0,0 +1 @@
@define-color color rgb(100, 99, 88);

View File

@ -0,0 +1 @@
@define-color color rgb(100,99,88);

View File

@ -0,0 +1 @@
@define-color color rgba(50%, 50%, 50%, 0.5);

View File

@ -0,0 +1 @@
@define-color color rgba(128,128,128,0.5);

Some files were not shown because too many files have changed in this diff Show More