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

Commit 510ecfa

Browse files
Don't rely on timings for dimension_provider unit test. (#39343)
1 parent ae38c95 commit 510ecfa

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

lib/web_ui/test/engine/view_embedder/dimensions_provider/custom_element_dimensions_provider_test.dart

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -110,41 +110,23 @@ void doTests() {
110110
});
111111

112112
test('funnels resize events on sizeSource', () async {
113-
final Future<Object?> event = provider.onResize.first;
114-
final Future<List<Object?>> events = provider.onResize.take(3).toList();
115-
116-
// The resize observer fires asynchronously, so we wait a little between
117-
// resizes, so the observer has time to fire events separately.
118-
await Future<void>.delayed(const Duration(milliseconds: 100), () {
119-
sizeSource
120-
..style.width = '100px'
121-
..style.height = '100px';
122-
});
113+
sizeSource
114+
..style.width = '100px'
115+
..style.height = '100px';
123116

124-
await Future<void>.delayed(const Duration(milliseconds: 100), () {
125-
sizeSource
126-
..style.width = '200px'
127-
..style.height = '200px';
128-
});
117+
expect(await provider.onResize.first, const ui.Size(100, 100));
129118

130-
await Future<void>.delayed(const Duration(milliseconds: 100), () {
131-
sizeSource
132-
..style.width = '300px'
133-
..style.height = '300px';
134-
});
119+
sizeSource
120+
..style.width = '200px'
121+
..style.height = '200px';
135122

136-
// Let the DOM settle so the observer reports the last 300x300 mutation...
137-
await Future<void>.delayed(const Duration(milliseconds: 100));
123+
expect(await provider.onResize.first, const ui.Size(200, 200));
124+
125+
sizeSource
126+
..style.width = '300px'
127+
..style.height = '300px';
138128

139-
expect(event, completion(const ui.Size(100, 100)));
140-
expect(events, completes);
141-
expect(
142-
events,
143-
completion(const <ui.Size>[
144-
ui.Size(100, 100),
145-
ui.Size(200, 200),
146-
ui.Size(300, 300),
147-
]));
129+
expect(await provider.onResize.first, const ui.Size(300, 300));
148130
});
149131

150132
test('closed by onHotRestart', () async {

0 commit comments

Comments
 (0)