Skip to content

Commit

Permalink
updateSemantics in TestWindow should always be implemented. (#114857)
Browse files Browse the repository at this point in the history
* Test that updateSemantics can be called

* Test that updateSemantics in FakeWindow is always implemented

* Sort import directives

Co-authored-by: a-wallen <stephenwallen@google.com>
  • Loading branch information
a-wallen and a-wallen committed Nov 10, 2022
1 parent befd8b6 commit 154ae0f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/flutter_test/test/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// found in the LICENSE file.

import 'dart:ui' as ui show window;
import 'dart:ui' show AccessibilityFeatures, Brightness, Locale, Size, WindowPadding;
import 'dart:ui' show AccessibilityFeatures, Brightness, Locale, PlatformDispatcher, SemanticsUpdate, SingletonFlutterWindow, Size, WindowPadding;

import 'package:flutter/semantics.dart' show SemanticsUpdateBuilder;
import 'package:flutter/widgets.dart' show WidgetsBinding, WidgetsBindingObserver;
import 'package:flutter_test/flutter_test.dart';

Expand Down Expand Up @@ -207,6 +208,14 @@ void main() {
expect(observer.locales, equals(expectedValue));
retrieveTestBinding(tester).window.localesTestValue = defaultLocales;
});

test('Window test', () {
final FakeSingletonWindow fakeWindow = FakeSingletonWindow();
final TestWindow testWindow = TestWindow(window: fakeWindow);
final SemanticsUpdate update = SemanticsUpdateBuilder().build();
testWindow.updateSemantics(update);
expect(fakeWindow.lastUpdate, update);
});
}

void verifyThatTestWindowCanFakeProperty<WindowPropertyType>({
Expand Down Expand Up @@ -266,3 +275,15 @@ class TestObserver with WidgetsBindingObserver {
this.locales = locales;
}
}

class FakeSingletonWindow extends Fake implements SingletonFlutterWindow {
SemanticsUpdate? lastUpdate;

@override
PlatformDispatcher get platformDispatcher => PlatformDispatcher.instance;

@override
void updateSemantics(SemanticsUpdate update) {
lastUpdate = update;
}
}

0 comments on commit 154ae0f

Please sign in to comment.