Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 11c0f2d

Browse files
committed
Format test
1 parent 5e42a60 commit 11c0f2d

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

lib/web_ui/test/engine/host_node_test.dart

+24-19
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,48 @@ void testMain() {
3333
});
3434

3535
test('Attaches a stylesheet to the shadow root', () {
36-
final DomElement? style = hostNode.querySelector('#flt-internals-stylesheet');
36+
final DomElement? style =
37+
hostNode.querySelector('#flt-internals-stylesheet');
3738

3839
expect(style, isNotNull);
3940
expect(style!.tagName, equalsIgnoringCase('style'));
4041
});
4142

4243
test('(Self-test) hasCssRule can extract rules', () {
43-
final DomElement? style = hostNode.querySelector('#flt-internals-stylesheet');
44+
final DomElement? style =
45+
hostNode.querySelector('#flt-internals-stylesheet');
4446

4547
final bool hasRule = hasCssRule(style,
46-
selector: '.flt-text-editing::placeholder',
47-
declaration: 'opacity: 0');
48+
selector: '.flt-text-editing::placeholder',
49+
declaration: 'opacity: 0');
4850

4951
final bool hasFakeRule = hasCssRule(style,
50-
selector: 'input::selection',
51-
declaration: 'color: #fabada;');
52+
selector: 'input::selection', declaration: 'color: #fabada;');
5253

5354
expect(hasRule, isTrue);
5455
expect(hasFakeRule, isFalse);
5556
});
5657

5758
test('Attaches styling to remove password reveal icons on Edge', () {
58-
final DomElement? style = hostNode.querySelector('#flt-internals-stylesheet');
59+
final DomElement? style =
60+
hostNode.querySelector('#flt-internals-stylesheet');
5961

6062
// Check that style.sheet! contains input::-ms-reveal rule
6163
final bool hidesRevealIcons = hasCssRule(style,
62-
selector: 'input::-ms-reveal',
63-
declaration: 'display: none');
64+
selector: 'input::-ms-reveal', declaration: 'display: none');
6465

65-
expect(hidesRevealIcons, isTrue, reason: 'In Edge, stylesheet must contain "input::-ms-reveal" rule.');
66+
expect(hidesRevealIcons, isTrue,
67+
reason: 'In Edge, stylesheet must contain "input::-ms-reveal" rule.');
6668
}, skip: !isEdge);
6769

6870
test('Does not attach the Edge-specific style tag on non-Edge browsers',
6971
() {
70-
final DomElement? style = hostNode.querySelector('#flt-internals-stylesheet');
72+
final DomElement? style =
73+
hostNode.querySelector('#flt-internals-stylesheet');
7174

7275
// Check that style.sheet! contains input::-ms-reveal rule
7376
final bool hidesRevealIcons = hasCssRule(style,
74-
selector: 'input::-ms-reveal',
75-
declaration: 'display: none');
77+
selector: 'input::-ms-reveal', declaration: 'display: none');
7678

7779
expect(hidesRevealIcons, isFalse);
7880
}, skip: isEdge);
@@ -138,18 +140,21 @@ void _runDomTests(HostNode hostNode) {
138140
});
139141
}
140142

141-
/// Asserts that a given [selector] { [rule]; } exists in a [sheet].
142-
bool hasCssRule(DomElement? styleSheet, {
143+
/// Finds out whether a given CSS Rule ([selector] { [declaration]; }) exists in a [styleSheet].
144+
bool hasCssRule(
145+
DomElement? styleSheet, {
143146
required String selector,
144147
required String declaration,
145148
}) {
146-
expect(styleSheet, isNotNull);
147-
expect((styleSheet! as DomHTMLStyleElement).sheet, isNotNull);
149+
assert(styleSheet != null);
150+
assert((styleSheet! as DomHTMLStyleElement).sheet != null);
148151

149152
// regexr.com/740ff
150-
final RegExp ruleLike = RegExp('[^{]*(?:$selector)[^{]*{[^}]*(?:$declaration)[^}]*}');
153+
final RegExp ruleLike =
154+
RegExp('[^{]*(?:$selector)[^{]*{[^}]*(?:$declaration)[^}]*}');
151155

152-
final DomCSSStyleSheet sheet = (styleSheet as DomHTMLStyleElement).sheet! as DomCSSStyleSheet;
156+
final DomCSSStyleSheet sheet =
157+
(styleSheet! as DomHTMLStyleElement).sheet! as DomCSSStyleSheet;
153158

154159
// Check that the cssText of any rule matches the ruleLike RegExp.
155160
return sheet.rules

0 commit comments

Comments
 (0)