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

Side by Side Diff: tests/html/cssstyledeclaration_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 library CssStyleDeclarationTest; 5 library CssStyleDeclarationTest;
6
6 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart'; 8 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 9 import 'dart:html';
9 import 'dart:async'; 10 import 'dart:async';
10 import 'utils.dart'; 11 import 'utils.dart';
11 12
12 main() { 13 main() {
13 useHtmlConfiguration(); 14 useHtmlConfiguration();
14 15
15 createTestStyle() { 16 createTestStyle() {
16 return new CssStyleDeclaration.css(""" 17 return new CssStyleDeclaration.css("""
17 color: blue; 18 color: blue;
18 width: 2px !important; 19 width: 2px !important;
19 """); 20 """);
20 }; 21 }
22
23 ;
21 24
22 test('default constructor is empty', () { 25 test('default constructor is empty', () {
23 var style = new CssStyleDeclaration(); 26 var style = new CssStyleDeclaration();
24 expect(style.cssText, isEmpty); 27 expect(style.cssText, isEmpty);
25 expect(style.getPropertyPriority('color'), isEmpty); 28 expect(style.getPropertyPriority('color'), isEmpty);
26 expect(style.item(0), isEmpty); 29 expect(style.item(0), isEmpty);
27 expect(style, hasLength(0)); 30 expect(style, hasLength(0));
28 // These assertions throw a UnimplementedError in dartium: 31 // These assertions throw a UnimplementedError in dartium:
29 // expect(style.parentRule, isNull); 32 // expect(style.parentRule, isNull);
30 // expect(style.getPropertyCssValue('color'), isNull); 33 // expect(style.getPropertyCssValue('color'), isNull);
31 // expect(style.getPropertyShorthand('color'), isNull); 34 // expect(style.getPropertyShorthand('color'), isNull);
32 }); 35 });
33 36
34 test('length is wrapped', () { 37 test('length is wrapped', () {
35 expect(createTestStyle(), hasLength(2)); 38 expect(createTestStyle(), hasLength(2));
36 }); 39 });
37 40
38 test('getPropertyPriority is wrapped', () { 41 test('getPropertyPriority is wrapped', () {
39 var style = createTestStyle(); 42 var style = createTestStyle();
40 expect(style.getPropertyPriority("color"), isEmpty); 43 expect(style.getPropertyPriority("color"), isEmpty);
41 expect(style.getPropertyPriority("width"), equals("important")); 44 expect(style.getPropertyPriority("width"), equals("important"));
42 }); 45 });
43 46
44 test('removeProperty is wrapped', () { 47 test('removeProperty is wrapped', () {
45 var style = createTestStyle(); 48 var style = createTestStyle();
46 style.removeProperty("width"); 49 style.removeProperty("width");
47 expect(style.cssText.trim(), 50 expect(style.cssText.trim(), equals("color: blue;"));
48 equals("color: blue;"));
49 }); 51 });
50 52
51 test('CSS property empty getters and setters', () { 53 test('CSS property empty getters and setters', () {
52 var style = createTestStyle(); 54 var style = createTestStyle();
53 expect(style.border, equals("")); 55 expect(style.border, equals(""));
54 56
55 style.border = "1px solid blue"; 57 style.border = "1px solid blue";
56 style.border = ""; 58 style.border = "";
57 expect(style.border, equals("")); 59 expect(style.border, equals(""));
58 60
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 })); 99 }));
98 }); 100 });
99 101
100 test('Invalid values', () { 102 test('Invalid values', () {
101 var element = new DivElement(); 103 var element = new DivElement();
102 // Should not throw an error. 104 // Should not throw an error.
103 element.style.background = 'some_bad_value'; 105 element.style.background = 'some_bad_value';
104 }); 106 });
105 107
106 test('css multi get', () { 108 test('css multi get', () {
107 var listElement = new Element.html('<ul class="foo">' 109 var listElement = new Element.html(
110 '<ul class="foo">'
108 '<li class="bar" style="background-color: red; border-left: 10px;">' 111 '<li class="bar" style="background-color: red; border-left: 10px;">'
109 '<li class="baz" style="background-color: black;>' 112 '<li class="baz" style="background-color: black;>'
110 '<li class="baz classy" style="background-color: blue; ">' 113 '<li class="baz classy" style="background-color: blue; ">'
111 '</ul>', treeSanitizer: new NullTreeSanitizer()); 114 '</ul>',
115 treeSanitizer: new NullTreeSanitizer());
112 document.documentElement.children.add(listElement); 116 document.documentElement.children.add(listElement);
113 117
114 var elements = document.queryAll('li'); 118 var elements = document.queryAll('li');
115 expect(elements.style.backgroundColor, equals('red')); 119 expect(elements.style.backgroundColor, equals('red'));
116 expect(elements.style.borderLeftWidth, equals('10px')); 120 expect(elements.style.borderLeftWidth, equals('10px'));
117 elements = document.queryAll('.baz'); 121 elements = document.queryAll('.baz');
118 expect(elements.style.backgroundColor, equals('black')); 122 expect(elements.style.backgroundColor, equals('black'));
119 expect(elements.style.borderLeftWidth, equals('')); 123 expect(elements.style.borderLeftWidth, equals(''));
120 elements = document.queryAll('.bar'); 124 elements = document.queryAll('.bar');
121 expect(elements.style.backgroundColor, equals('red')); 125 expect(elements.style.backgroundColor, equals('red'));
122 }); 126 });
123 127
124 test('css multi set', () { 128 test('css multi set', () {
125 var listElement = new Element.html('<ul class="foo">' 129 var listElement = new Element.html(
130 '<ul class="foo">'
126 '<li class="bar" style="background-color: red; border-left: 10px;">' 131 '<li class="bar" style="background-color: red; border-left: 10px;">'
127 '<li class="baz" style="background-color: black;>' 132 '<li class="baz" style="background-color: black;>'
128 '<li class="baz" id="wat" style="background-color: blue; ">' 133 '<li class="baz" id="wat" style="background-color: blue; ">'
129 '</ul>', treeSanitizer: new NullTreeSanitizer()); 134 '</ul>',
135 treeSanitizer: new NullTreeSanitizer());
130 document.documentElement.children.add(listElement); 136 document.documentElement.children.add(listElement);
131 137
132 var elements = document.queryAll('li'); 138 var elements = document.queryAll('li');
133 elements.style.backgroundColor = 'green'; 139 elements.style.backgroundColor = 'green';
134 expect(elements.style.backgroundColor, equals('green')); 140 expect(elements.style.backgroundColor, equals('green'));
135 expect(elements.style.borderLeftWidth, equals('10px')); 141 expect(elements.style.borderLeftWidth, equals('10px'));
136 142
137 elements = document.queryAll('.baz'); 143 elements = document.queryAll('.baz');
138 expect(elements.style.backgroundColor, equals('green')); 144 expect(elements.style.backgroundColor, equals('green'));
139 elements.style.backgroundColor = 'yellow'; 145 elements.style.backgroundColor = 'yellow';
(...skipping 11 matching lines...) Expand all
151 expect(elements.style.borderLeftWidth, equals('10px')); 157 expect(elements.style.borderLeftWidth, equals('10px'));
152 }); 158 });
153 159
154 test('supports property', () { 160 test('supports property', () {
155 expect(document.body.style.supportsProperty('bogus-property'), false); 161 expect(document.body.style.supportsProperty('bogus-property'), false);
156 expect(document.body.style.supportsProperty('background'), true); 162 expect(document.body.style.supportsProperty('background'), true);
157 expect(document.body.style.supportsProperty('borderBottomWidth'), true); 163 expect(document.body.style.supportsProperty('borderBottomWidth'), true);
158 expect(document.body.style.supportsProperty('animation'), true); 164 expect(document.body.style.supportsProperty('animation'), true);
159 }); 165 });
160 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698