| OLD | NEW |
| 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 import 'package:csslib/src/options.dart'; | 11 import 'package:csslib/src/options.dart'; |
| 12 | 12 |
| 13 export 'package:csslib/src/options.dart'; | 13 export 'package:csslib/src/options.dart'; |
| 14 | 14 |
| 15 const simpleOptionsWithCheckedAndWarningsAsErrors = const PreprocessorOptions( | 15 const simpleOptionsWithCheckedAndWarningsAsErrors = const PreprocessorOptions( |
| 16 useColors: false, | 16 useColors: false, |
| 17 checked: true, | 17 checked: true, |
| 18 warningsAsErrors: true, | 18 warningsAsErrors: true, |
| 19 inputFile: 'memory'); | 19 inputFile: 'memory'); |
| 20 | 20 |
| 21 const simpleOptions = | 21 const simpleOptions = |
| 22 const PreprocessorOptions(useColors: false, inputFile: 'memory'); | 22 const PreprocessorOptions(useColors: false, inputFile: 'memory'); |
| 23 | 23 |
| 24 const options = const PreprocessorOptions( | 24 const options = const PreprocessorOptions( |
| 25 useColors: false, warningsAsErrors: true, inputFile: 'memory'); | 25 useColors: false, warningsAsErrors: true, inputFile: 'memory'); |
| 26 | 26 |
| 27 void useMockMessages() { | |
| 28 messages = new Messages(printHandler: (message) {}); | |
| 29 } | |
| 30 | |
| 31 /** | 27 /** |
| 32 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, | 28 * Spin-up CSS parser in checked mode to detect any problematic CSS. Normally, |
| 33 * CSS will allow any property/value pairs regardless of validity; all of our | 29 * CSS will allow any property/value pairs regardless of validity; all of our |
| 34 * tests (by default) will ensure that the CSS is really valid. | 30 * tests (by default) will ensure that the CSS is really valid. |
| 35 */ | 31 */ |
| 36 StyleSheet parseCss(String cssInput, | 32 StyleSheet parseCss(String cssInput, |
| 37 {List<Message> errors, PreprocessorOptions opts}) => parse(cssInput, | 33 {List<Message> errors, PreprocessorOptions opts}) => parse(cssInput, |
| 38 errors: errors, | 34 errors: errors, |
| 39 options: opts == null | 35 options: opts == null |
| 40 ? simpleOptionsWithCheckedAndWarningsAsErrors | 36 ? simpleOptionsWithCheckedAndWarningsAsErrors |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 walkTree(ss); | 77 walkTree(ss); |
| 82 return (_emitCss..visitTree(ss, pretty: false)).toString(); | 78 return (_emitCss..visitTree(ss, pretty: false)).toString(); |
| 83 } | 79 } |
| 84 | 80 |
| 85 /** Walks the style sheet tree does nothing; insures the basic walker works. */ | 81 /** Walks the style sheet tree does nothing; insures the basic walker works. */ |
| 86 void walkTree(StyleSheet ss) { | 82 void walkTree(StyleSheet ss) { |
| 87 _cssVisitor..visitTree(ss); | 83 _cssVisitor..visitTree(ss); |
| 88 } | 84 } |
| 89 | 85 |
| 90 String dumpTree(StyleSheet ss) => treeToDebugString(ss); | 86 String dumpTree(StyleSheet ss) => treeToDebugString(ss); |
| OLD | NEW |