Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: utils/tests/css/src/DeclarationTest.dart

Issue 9168008: Enabled CSS tests, added CSS tests to buildbot, fixed tooling with nodejs, and added more tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More coding convention changes (consistency). Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/tests/css/css.status ('k') | utils/tests/css/src/ExpressionTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/css/src/DeclarationTest.dart
diff --git a/utils/tests/css/src/DeclarationTest.dart b/utils/tests/css/src/DeclarationTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..47d4e592c32e9a0b5c6bfa77e6ad7051c600d5c4
--- /dev/null
+++ b/utils/tests/css/src/DeclarationTest.dart
@@ -0,0 +1,256 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#import("../../../css/css.dart");
+#import('../../../../frog/lang.dart', prefix:'lang');
+
+class DeclarationTest {
+
+ static testMain() {
+ initCssWorld();
+
+ testSimpleTerms();
+ testMoreDecls();
+ testIdentifiers();
+ testComposites();
+ testNewerCss();
+ testCssFile();
+ }
+
+ static void testSimpleTerms() {
+ final String input =
+ ".foo {\n" +
+ " background-color: #191919;\n" +
+ " width: 10PX;\n" +
+ " height: 22mM !important;\n" +
+ " border-width: 20cm;\n" +
+ " margin-width: 33%;\n" +
+ " border-height: 30EM;\n" +
+ " width: .6in;\n" +
+ " length: 1.2in;\n" +
+ " -web-stuff: -10Px;\n" +
+ "}\n";
+ final String generated =
+ "\n" +
+ ".foo {\n" +
+ " background-color: #191919;\n" +
+ " width: 10px;\n" +
+ " height: 22mm !important;\n" +
+ " border-width: 20cm;\n" +
+ " margin-width: 33%;\n" +
+ " border-height: 30em;\n" +
+ " width: .6in;\n" + // Check double values.
+ " length: 1.2in;\n" +
+ " -web-stuff: -10px;\n" +
+ "}\n";
+
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+
+ static void testMoreDecls() {
+ final String input =
+ ".more {\n" +
+ " color: red;\n" +
+ " color: #aabbcc; /* test -- 3 */\n" +
+ " color: blue;\n" +
+ " background-image: url(http://test.jpeg);\n" +
+ " background-image: url(\"http://double_quote.html\");\n" +
+ " background-image: url('http://single_quote.html');\n" +
+ " color: rgba(10,20,255); <!-- test CDO/CDC -->\n" +
+ " color: #123aef; /* hex # part integer and part identifier */\n" +
+ "}\n";
+ final String generated =
+ "\n" +
+ ".more {\n" +
+ " color: #ff0000;\n" +
+ " color: #aabbcc;\n" +
+ " color: #ff;\n" +
+ " background-image: url(http://test.jpeg);\n" +
+ " background-image: url(http://double_quote.html);\n" +
+ " background-image: url(http://single_quote.html);\n" +
+ " color: rgba(10, 20, 255);\n" +
+ " color: #123aef;\n" +
+ "}\n";
+
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+
+ static void testIdentifiers() {
+ final String input =
+ // Make sure identifiers that could look like hex are handled.
+ "#da {\n" +
+ " height: 100px;\n" +
+ "}\n" +
+ // Make sure elements that contain a leading dash (negative) are valid.
+ "#-foo {\n" +
+ " width: 10px;\n" +
+ " color: #ff00cc;\n" +
+ "}\n";
+ final String generated =
+ "\n" +
+ "#da {\n" +
+ " height: 100px;\n" +
+ "}\n" +
+ "\n" +
+ "#-foo {\n" +
+ " width: 10px;\n" +
+ " color: #ff00cc;\n" +
+ "}\n";
+
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+
+ static void testComposites() {
+ final String input =
+ // Composites
+ ".xyzzy {\n" +
+ " border: 10px 80px 90px 100px;\n" +
+ " width: 99%;\n" +
+ "}\n" +
+ "@-webkit-keyframes pulsate {\n" +
+ " 0% {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ "}\n";
+ final String generated =
+ "\n" +
+ ".xyzzy {\n" +
+ " border: 10px 80px 90px 100px;\n" +
+ " width: 99%;\n" +
+ "}\n" +
+ "@-webkit-keyframes pulsate {\n" +
+ " 0% {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ "}\n";
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+
+ static void testNewerCss() {
+ final String input =
+ // Newer things in CSS
+ "@media screen,print {\n" +
+ " .foobar_screen {\n" +
+ " width: 10px;\n" +
+ " }\n" +
+ "}\n" +
+ "@page : test {\n" +
+ " width: 10px;\n" +
+ "}\n" +
+ "@page {\n" +
+ " height: 22px;\n" +
+ "}\n";
+ final String generated =
+ "@media screen,print {\n" +
+ "\n" +
+ ".foobar_screen {\n" +
+ " width: 10px;\n" +
+ "}\n" +
+ "\n" +
+ "}\n" +
+ "@page : test {\n" +
+ " width: 10px;\n" +
+ "\n" +
+ "}\n" +
+ "@page {\n" +
+ " height: 22px;\n" +
+ "\n" +
+ "}\n";
+
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+
+ static void testCssFile() {
+ final String scss =
+ "@import 'simple.css'\n" +
+ "@import \"test.css\" print\n" +
+ "@import url(test.css) screen, print\n" +
+
+ "div[href^='test'] {\n" +
+ " height: 10px;\n" +
+ "}\n" +
+
+ "@-webkit-keyframes pulsate {\n" +
+ " from {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ " 10% {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ " 30% {\n" +
+ " -webkit-transform: translate3d(0, 2, 0) scale(1.0);\n" +
+ " }\n" +
+ "}\n" +
+
+ ".foobar {\n" +
+ " grid-columns: 10px (\"content\" 1fr 10px)[4];\n" +
+ "}\n";
+
+ final String generated =
+ "@import url(simple.css)\n" +
+ "@import url(test.css) print\n" +
+ "@import url(test.css) screen,print\n" +
+ "\n" +
+ "div[href ^= \"test\"] {\n" +
+ " height: 10px;\n" +
+ "}\n" +
+ "@-webkit-keyframes pulsate {\n" +
+ " from {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ " 10% {\n" +
+ " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
+ " }\n" +
+ " 30% {\n" +
+ " -webkit-transform: translate3d(0, 2, 0) scale(1.0);\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ ".foobar {\n" +
+ " grid-columns: 10px (\"content\" 1fr 10px) [4];\n" +
+ "}\n";
+
+ Parser parser =
+ new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, scss));
+
+ Stylesheet stylesheet = parser.parse();
+ Expect.isNotNull(stylesheet);
+
+ Expect.equals(generated, stylesheet.toString());
+ }
+}
+
+main() {
+ DeclarationTest.testMain();
+}
« no previous file with comments | « utils/tests/css/css.status ('k') | utils/tests/css/src/ExpressionTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698