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

Side by Side Diff: pkg/csslib/test/testing.dart

Issue 64373003: pkg/csslib: types, fixes, cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/csslib/test/selector_test.dart ('k') | pkg/csslib/test/visitor_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** Common definitions used for setting up the test environment. */ 5 /** Common definitions used for setting up the test environment. */
6 library testing; 6 library testing;
7 7
8 import 'package:csslib/parser.dart'; 8 import 'package:csslib/parser.dart';
9 import 'package:csslib/visitor.dart'; 9 import 'package:csslib/visitor.dart';
10 import 'package:csslib/src/messages.dart'; 10 import 'package:csslib/src/messages.dart';
11 11
12 useMockMessages() { 12 void useMockMessages() {
13 messages = new Messages(printHandler: (message) {}); 13 messages = new Messages(printHandler: (message) {});
14 } 14 }
15 15
16 /** 16 /**
17 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, 17 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
18 * CSS will allow any property/value pairs regardless of validity; all of our 18 * CSS will allow any property/value pairs regardless of validity; all of our
19 * tests (by default) will ensure that the CSS is really valid. 19 * tests (by default) will ensure that the CSS is really valid.
20 */ 20 */
21 StyleSheet parseCss(String cssInput, {List errors, List opts}) => 21 StyleSheet parseCss(String cssInput, {List errors, List opts}) =>
22 parse(cssInput, errors: errors, options: opts == null ? 22 parse(cssInput, errors: errors, options: opts == null ?
23 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts); 23 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts);
24 24
25 /** 25 /**
26 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, 26 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
27 * CSS will allow any property/value pairs regardless of validity; all of our 27 * CSS will allow any property/value pairs regardless of validity; all of our
28 * tests (by default) will ensure that the CSS is really valid. 28 * tests (by default) will ensure that the CSS is really valid.
29 */ 29 */
30 StyleSheet compileCss(String cssInput, {List errors, List opts, 30 StyleSheet compileCss(String cssInput, {List errors, List opts,
31 bool polyfill: false, List<StyleSheet> includes: null}) => 31 bool polyfill: false, List<StyleSheet> includes: null}) =>
32 compile(cssInput, errors: errors, options: opts == null ? 32 compile(cssInput, errors: errors, options: opts == null ?
33 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts, 33 ['--no-colors', '--checked', '--warnings_as_errors', 'memory'] : opts,
34 polyfill: polyfill, includes: includes); 34 polyfill: polyfill, includes: includes);
35 35
36 StyleSheet polyFillCompileCss(input, {List errors, List opts}) => 36 StyleSheet polyFillCompileCss(input, {List errors, List opts}) =>
37 compileCss(input, errors: errors, polyfill: true, opts: opts); 37 compileCss(input, errors: errors, polyfill: true, opts: opts);
38 38
39 /** CSS emitter walks the style sheet tree and emits readable CSS. */ 39 /** CSS emitter walks the style sheet tree and emits readable CSS. */
40 var _emitCss = new CssPrinter(); 40 final _emitCss = new CssPrinter();
41 41
42 /** Simple Visitor does nothing but walk tree. */ 42 /** Simple Visitor does nothing but walk tree. */
43 var _cssVisitor = new Visitor(); 43 final _cssVisitor = new Visitor();
44 44
45 /** Pretty printer for CSS. */ 45 /** Pretty printer for CSS. */
46 String prettyPrint(StyleSheet ss) { 46 String prettyPrint(StyleSheet ss) {
47 // Walk the tree testing basic Vistor class. 47 // Walk the tree testing basic Vistor class.
48 walkTree(ss); 48 walkTree(ss);
49 return (_emitCss..visitTree(ss, pretty: true)).toString(); 49 return (_emitCss..visitTree(ss, pretty: true)).toString();
50 } 50 }
51 51
52 /** 52 /**
53 * Helper function to emit compact (non-pretty printed) CSS for suite test 53 * Helper function to emit compact (non-pretty printed) CSS for suite test
54 * comparsions. Spaces, new lines, etc. are reduced for easier comparsions of 54 * comparsions. Spaces, new lines, etc. are reduced for easier comparsions of
55 * expected suite test results. 55 * expected suite test results.
56 */ 56 */
57 String compactOuptut(StyleSheet ss) { 57 String compactOuptut(StyleSheet ss) {
58 walkTree(ss); 58 walkTree(ss);
59 return (_emitCss..visitTree(ss, pretty: false)).toString(); 59 return (_emitCss..visitTree(ss, pretty: false)).toString();
60 } 60 }
61 61
62 /** Walks the style sheet tree does nothing; insures the basic walker works. */ 62 /** Walks the style sheet tree does nothing; insures the basic walker works. */
63 void walkTree(StyleSheet ss) { 63 void walkTree(StyleSheet ss) {
64 _cssVisitor..visitTree(ss); 64 _cssVisitor..visitTree(ss);
65 } 65 }
66 66
67 String dumpTree(StyleSheet ss) => treeToDebugString(ss); 67 String dumpTree(StyleSheet ss) => treeToDebugString(ss);
68
69
OLDNEW
« no previous file with comments | « pkg/csslib/test/selector_test.dart ('k') | pkg/csslib/test/visitor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698