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

Commit 154ae0f

Browse files
a-wallena-wallen
and
a-wallen
authored
updateSemantics in TestWindow should always be implemented. (#114857)
* Test that updateSemantics can be called * Test that updateSemantics in FakeWindow is always implemented * Sort import directives Co-authored-by: a-wallen <[email protected]>
1 parent befd8b6 commit 154ae0f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/flutter_test/test/window_test.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// found in the LICENSE file.
44

55
import 'dart:ui' as ui show window;
6-
import 'dart:ui' show AccessibilityFeatures, Brightness, Locale, Size, WindowPadding;
6+
import 'dart:ui' show AccessibilityFeatures, Brightness, Locale, PlatformDispatcher, SemanticsUpdate, SingletonFlutterWindow, Size, WindowPadding;
77

8+
import 'package:flutter/semantics.dart' show SemanticsUpdateBuilder;
89
import 'package:flutter/widgets.dart' show WidgetsBinding, WidgetsBindingObserver;
910
import 'package:flutter_test/flutter_test.dart';
1011

@@ -207,6 +208,14 @@ void main() {
207208
expect(observer.locales, equals(expectedValue));
208209
retrieveTestBinding(tester).window.localesTestValue = defaultLocales;
209210
});
211+
212+
test('Window test', () {
213+
final FakeSingletonWindow fakeWindow = FakeSingletonWindow();
214+
final TestWindow testWindow = TestWindow(window: fakeWindow);
215+
final SemanticsUpdate update = SemanticsUpdateBuilder().build();
216+
testWindow.updateSemantics(update);
217+
expect(fakeWindow.lastUpdate, update);
218+
});
210219
}
211220

212221
void verifyThatTestWindowCanFakeProperty<WindowPropertyType>({
@@ -266,3 +275,15 @@ class TestObserver with WidgetsBindingObserver {
266275
this.locales = locales;
267276
}
268277
}
278+
279+
class FakeSingletonWindow extends Fake implements SingletonFlutterWindow {
280+
SemanticsUpdate? lastUpdate;
281+
282+
@override
283+
PlatformDispatcher get platformDispatcher => PlatformDispatcher.instance;
284+
285+
@override
286+
void updateSemantics(SemanticsUpdate update) {
287+
lastUpdate = update;
288+
}
289+
}

0 commit comments

Comments
 (0)