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

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

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « packages/csslib/test/selector_test.dart ('k') | packages/csslib/test/var_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /** Common definitions used for setting up the test environment. */
6 library testing;
7
8 import 'package:csslib/parser.dart';
9 import 'package:csslib/visitor.dart';
10 import 'package:csslib/src/messages.dart';
11 import 'package:csslib/src/options.dart';
12
13 export 'package:csslib/src/options.dart';
14
15 const simpleOptionsWithCheckedAndWarningsAsErrors = const PreprocessorOptions(
16 useColors: false,
17 checked: true,
18 warningsAsErrors: true,
19 inputFile: 'memory');
20
21 const simpleOptions =
22 const PreprocessorOptions(useColors: false, inputFile: 'memory');
23
24 const options = const PreprocessorOptions(
25 useColors: false, warningsAsErrors: true, inputFile: 'memory');
26
27 /**
28 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
29 * CSS will allow any property/value pairs regardless of validity; all of our
30 * tests (by default) will ensure that the CSS is really valid.
31 */
32 StyleSheet parseCss(String cssInput,
33 {List<Message> errors, PreprocessorOptions opts}) => parse(cssInput,
34 errors: errors,
35 options: opts == null
36 ? simpleOptionsWithCheckedAndWarningsAsErrors
37 : opts);
38
39 /**
40 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally,
41 * CSS will allow any property/value pairs regardless of validity; all of our
42 * tests (by default) will ensure that the CSS is really valid.
43 */
44 StyleSheet compileCss(String cssInput, {List<Message> errors,
45 PreprocessorOptions opts, bool polyfill: false,
46 List<StyleSheet> includes: null}) => compile(cssInput,
47 errors: errors,
48 options: opts == null
49 ? simpleOptionsWithCheckedAndWarningsAsErrors
50 : opts,
51 polyfill: polyfill,
52 includes: includes);
53
54 StyleSheet polyFillCompileCss(input,
55 {List<Message> errors, PreprocessorOptions opts}) =>
56 compileCss(input, errors: errors, polyfill: true, opts: opts);
57
58 /** CSS emitter walks the style sheet tree and emits readable CSS. */
59 final _emitCss = new CssPrinter();
60
61 /** Simple Visitor does nothing but walk tree. */
62 final _cssVisitor = new Visitor();
63
64 /** Pretty printer for CSS. */
65 String prettyPrint(StyleSheet ss) {
66 // Walk the tree testing basic Vistor class.
67 walkTree(ss);
68 return (_emitCss..visitTree(ss, pretty: true)).toString();
69 }
70
71 /**
72 * Helper function to emit compact (non-pretty printed) CSS for suite test
73 * comparsions. Spaces, new lines, etc. are reduced for easier comparsions of
74 * expected suite test results.
75 */
76 String compactOuptut(StyleSheet ss) {
77 walkTree(ss);
78 return (_emitCss..visitTree(ss, pretty: false)).toString();
79 }
80
81 /** Walks the style sheet tree does nothing; insures the basic walker works. */
82 void walkTree(StyleSheet ss) {
83 _cssVisitor..visitTree(ss);
84 }
85
86 String dumpTree(StyleSheet ss) => treeToDebugString(ss);
OLDNEW
« no previous file with comments | « packages/csslib/test/selector_test.dart ('k') | packages/csslib/test/var_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698