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

Don't rely on timings for dimension_provider unit test. #39343

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,41 +110,23 @@ void doTests() {
});

test('funnels resize events on sizeSource', () async {
final Future<Object?> event = provider.onResize.first;
final Future<List<Object?>> events = provider.onResize.take(3).toList();

// The resize observer fires asynchronously, so we wait a little between
// resizes, so the observer has time to fire events separately.
await Future<void>.delayed(const Duration(milliseconds: 100), () {
sizeSource
..style.width = '100px'
..style.height = '100px';
});
sizeSource
..style.width = '100px'
..style.height = '100px';

await Future<void>.delayed(const Duration(milliseconds: 100), () {
sizeSource
..style.width = '200px'
..style.height = '200px';
});
expect(await provider.onResize.first, const ui.Size(100, 100));

await Future<void>.delayed(const Duration(milliseconds: 100), () {
sizeSource
..style.width = '300px'
..style.height = '300px';
});
sizeSource
..style.width = '200px'
..style.height = '200px';

// Let the DOM settle so the observer reports the last 300x300 mutation...
await Future<void>.delayed(const Duration(milliseconds: 100));
expect(await provider.onResize.first, const ui.Size(200, 200));

sizeSource
..style.width = '300px'
..style.height = '300px';

expect(event, completion(const ui.Size(100, 100)));
expect(events, completes);
expect(
events,
completion(const <ui.Size>[
ui.Size(100, 100),
ui.Size(200, 200),
ui.Size(300, 300),
]));
expect(await provider.onResize.first, const ui.Size(300, 300));
});

test('closed by onHotRestart', () async {
Expand Down