This reverts commit e2490f2906.
This commit is contained in:
@@ -16,13 +16,18 @@ import 'package:test_api/test_api.dart' as test_package;
|
||||
import 'binding.dart';
|
||||
import 'deprecated.dart';
|
||||
|
||||
/// Ensure the appropriate test binding is initialized.
|
||||
TestWidgetsFlutterBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) {
|
||||
/// Ensure the [WidgetsBinding] is initialized.
|
||||
WidgetsBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) {
|
||||
environment ??= Platform.environment;
|
||||
if (environment.containsKey('FLUTTER_TEST') && environment['FLUTTER_TEST'] != 'false') {
|
||||
return AutomatedTestWidgetsFlutterBinding.ensureInitialized();
|
||||
if (WidgetsBinding.instance == null) {
|
||||
if (environment.containsKey('FLUTTER_TEST') && environment['FLUTTER_TEST'] != 'false') {
|
||||
AutomatedTestWidgetsFlutterBinding();
|
||||
} else {
|
||||
LiveTestWidgetsFlutterBinding();
|
||||
}
|
||||
}
|
||||
return LiveTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(WidgetsBinding.instance is TestWidgetsFlutterBinding);
|
||||
return WidgetsBinding.instance!;
|
||||
}
|
||||
|
||||
/// Setup mocking of the global [HttpClient].
|
||||
@@ -43,7 +48,7 @@ void mockFlutterAssets() {
|
||||
/// platform messages.
|
||||
SystemChannels.navigation.setMockMethodCallHandler((MethodCall methodCall) async {});
|
||||
|
||||
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async {
|
||||
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async {
|
||||
assert(message != null);
|
||||
String key = utf8.decode(message!.buffer.asUint8List());
|
||||
File asset = File(path.join(assetFolderPath, key));
|
||||
|
||||
@@ -6,9 +6,13 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'binding.dart';
|
||||
|
||||
/// Ensure the appropriate test binding is initialized.
|
||||
TestWidgetsFlutterBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) {
|
||||
return AutomatedTestWidgetsFlutterBinding.ensureInitialized();
|
||||
/// Ensure the [WidgetsBinding] is initialized.
|
||||
WidgetsBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) {
|
||||
if (WidgetsBinding.instance == null) {
|
||||
AutomatedTestWidgetsFlutterBinding();
|
||||
}
|
||||
assert(WidgetsBinding.instance is TestWidgetsFlutterBinding);
|
||||
return WidgetsBinding.instance!;
|
||||
}
|
||||
|
||||
/// This method is a noop on the web.
|
||||
|
||||
@@ -67,7 +67,7 @@ class MatchesGoldenFile extends AsyncMatcher {
|
||||
|
||||
final Uri testNameUri = goldenFileComparator.getTestUri(key, version);
|
||||
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
return binding.runAsync<String?>(() async {
|
||||
final ui.Image? image = await imageFuture;
|
||||
if (image == null) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class MatchesGoldenFile extends AsyncMatcher {
|
||||
final Element element = elements.single;
|
||||
final RenderObject renderObject = _findRepaintBoundary(element);
|
||||
final Size size = renderObject.paintBounds.size;
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
final Element e = binding.renderViewElement!;
|
||||
|
||||
// Unlike `flutter_tester`, we don't have the ability to render an element
|
||||
|
||||
@@ -407,7 +407,7 @@ class _RenderPostFrameCallbacker extends RenderProxyBox {
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
if (callback != null) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration duration) {
|
||||
callback!(duration);
|
||||
markNeedsPaint();
|
||||
});
|
||||
|
||||
@@ -107,11 +107,8 @@ mixin TestDefaultBinaryMessengerBinding on BindingBase, ServicesBinding {
|
||||
|
||||
/// Base class for bindings used by widgets library tests.
|
||||
///
|
||||
/// The [ensureInitialized] method creates (if necessary) and returns an
|
||||
/// instance of the appropriate subclass. (If one is already created, it returns
|
||||
/// that one, even if it's not the one that it would normally create. This
|
||||
/// allows tests to force the use of [LiveTestWidgetsFlutterBinding] even in a
|
||||
/// normal unit test environment, e.g. to test that binding.)
|
||||
/// The [ensureInitialized] method creates (if necessary) and returns
|
||||
/// an instance of the appropriate subclass.
|
||||
///
|
||||
/// When using these bindings, certain features are disabled. For
|
||||
/// example, [timeDilation] is reset to 1.0 on initialization.
|
||||
@@ -268,14 +265,6 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
/// equivalent as [Future.delayed].
|
||||
Future<void> delayed(Duration duration);
|
||||
|
||||
/// The current [TestWidgetsFlutterBinding], if one has been created.
|
||||
///
|
||||
/// Provides access to the features exposed by this binding. The binding must
|
||||
/// be initialized before using this getter; this is typically done by calling
|
||||
/// [testWidgets] or [TestWidgetsFlutterBinding.ensureInitialized].
|
||||
static TestWidgetsFlutterBinding get instance => BindingBase.checkInstance(_instance);
|
||||
static TestWidgetsFlutterBinding? _instance;
|
||||
|
||||
/// Creates and initializes the binding. This function is
|
||||
/// idempotent; calling it a second time will just return the
|
||||
/// previously-created instance.
|
||||
@@ -294,26 +283,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
/// [LiveTestWidgetsFlutterBinding], so this function will always set up an
|
||||
/// [AutomatedTestWidgetsFlutterBinding] when run in a web browser.
|
||||
///
|
||||
/// The parameter `environment` is used to test the test framework
|
||||
/// itself by checking how it reacts to different environment
|
||||
/// variable values, and should not be used outside of this context.
|
||||
///
|
||||
/// If a [TestWidgetsFlutterBinding] subclass was explicitly initialized
|
||||
/// before calling [ensureInitialized], then that version of the binding is
|
||||
/// returned regardless of the logic described above. This allows tests to
|
||||
/// force a specific test binding to be used.
|
||||
///
|
||||
/// This is called automatically by [testWidgets].
|
||||
static TestWidgetsFlutterBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) {
|
||||
if (_instance != null)
|
||||
return _instance!;
|
||||
return binding.ensureInitialized(environment);
|
||||
}
|
||||
/// The parameter `environment` is exposed to test different environment
|
||||
/// variable values, and should not be used.
|
||||
static WidgetsBinding ensureInitialized([@visibleForTesting Map<String, String>? environment]) => binding.ensureInitialized(environment);
|
||||
|
||||
@override
|
||||
void initInstances() {
|
||||
super.initInstances();
|
||||
_instance = this;
|
||||
timeDilation = 1.0; // just in case the developer has artificially changed it for development
|
||||
if (overrideHttpClient) {
|
||||
binding.setupHttpOverrides();
|
||||
@@ -918,12 +894,12 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
// tests.
|
||||
// ignore: invalid_use_of_visible_for_testing_member
|
||||
RawKeyboard.instance.clearKeysPressed();
|
||||
assert(!RendererBinding.instance.mouseTracker.mouseIsConnected,
|
||||
assert(!RendererBinding.instance!.mouseTracker.mouseIsConnected,
|
||||
'The MouseTracker thinks that there is still a mouse connected, which indicates that a '
|
||||
'test has not removed the mouse pointer which it added. Call removePointer on the '
|
||||
'active mouse gesture to remove the mouse pointer.');
|
||||
// ignore: invalid_use_of_visible_for_testing_member
|
||||
RendererBinding.instance.initMouseTracker();
|
||||
RendererBinding.instance!.initMouseTracker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,41 +911,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
///
|
||||
/// This class assumes it is always run in checked mode (since tests are always
|
||||
/// run in checked mode).
|
||||
///
|
||||
/// See [TestWidgetsFlutterBinding] for a list of mixins that must be
|
||||
/// provided by the binding active while the test framework is
|
||||
/// running.
|
||||
class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
@override
|
||||
void initInstances() {
|
||||
super.initInstances();
|
||||
_instance = this;
|
||||
binding.mockFlutterAssets();
|
||||
}
|
||||
|
||||
/// The current [AutomatedTestWidgetsFlutterBinding], if one has been created.
|
||||
///
|
||||
/// The binding must be initialized before using this getter. If you
|
||||
/// need the binding to be constructed before calling [testWidgets],
|
||||
/// you can ensure a binding has been constructed by calling the
|
||||
/// [TestWidgetsFlutterBinding.ensureInitialized] function.
|
||||
static AutomatedTestWidgetsFlutterBinding get instance => BindingBase.checkInstance(_instance);
|
||||
static AutomatedTestWidgetsFlutterBinding? _instance;
|
||||
|
||||
/// Returns an instance of the binding that implements
|
||||
/// [AutomatedTestWidgetsFlutterBinding]. If no binding has yet been
|
||||
/// initialized, the a new instance is created.
|
||||
///
|
||||
/// Generally, there is no need to call this method. Use
|
||||
/// [TestWidgetsFlutterBinding.ensureInitialized] instead, as it
|
||||
/// will select the correct test binding implementation
|
||||
/// automatically.
|
||||
static AutomatedTestWidgetsFlutterBinding ensureInitialized() {
|
||||
if (AutomatedTestWidgetsFlutterBinding._instance == null)
|
||||
AutomatedTestWidgetsFlutterBinding();
|
||||
return AutomatedTestWidgetsFlutterBinding.instance;
|
||||
}
|
||||
|
||||
FakeAsync? _currentFakeAsync; // set in runTest; cleared in postTest
|
||||
Completer<void>? _pendingAsyncTasks;
|
||||
|
||||
@@ -1428,40 +1376,7 @@ enum LiveTestWidgetsFlutterBindingFramePolicy {
|
||||
/// [pump]. (There would be no point setting it to a value that
|
||||
/// doesn't trigger a paint, since then you could not see anything
|
||||
/// anyway.)
|
||||
///
|
||||
/// See [TestWidgetsFlutterBinding] for a list of mixins that must be
|
||||
/// provided by the binding active while the test framework is
|
||||
/// running.
|
||||
class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
@override
|
||||
void initInstances() {
|
||||
super.initInstances();
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
/// The current [LiveTestWidgetsFlutterBinding], if one has been created.
|
||||
///
|
||||
/// The binding must be initialized before using this getter. If you
|
||||
/// need the binding to be constructed before calling [testWidgets],
|
||||
/// you can ensure a binding has been constructed by calling the
|
||||
/// [TestWidgetsFlutterBinding.ensureInitialized] function.
|
||||
static LiveTestWidgetsFlutterBinding get instance => BindingBase.checkInstance(_instance);
|
||||
static LiveTestWidgetsFlutterBinding? _instance;
|
||||
|
||||
/// Returns an instance of the binding that implements
|
||||
/// [LiveTestWidgetsFlutterBinding]. If no binding has yet been
|
||||
/// initialized, the a new instance is created.
|
||||
///
|
||||
/// Generally, there is no need to call this method. Use
|
||||
/// [TestWidgetsFlutterBinding.ensureInitialized] instead, as it
|
||||
/// will select the correct test binding implementation
|
||||
/// automatically.
|
||||
static LiveTestWidgetsFlutterBinding ensureInitialized() {
|
||||
if (LiveTestWidgetsFlutterBinding._instance == null)
|
||||
LiveTestWidgetsFlutterBinding();
|
||||
return LiveTestWidgetsFlutterBinding.instance;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get inTest => _inTest;
|
||||
bool _inTest = false;
|
||||
|
||||
@@ -318,7 +318,7 @@ class CommonFinders {
|
||||
/// If the `skipOffstage` argument is true (the default), then this skips
|
||||
/// nodes that are [Offstage] or that are from inactive [Route]s.
|
||||
Finder bySemanticsLabel(Pattern label, { bool skipOffstage = true }) {
|
||||
if (WidgetsBinding.instance.pipelineOwner.semanticsOwner == null)
|
||||
if (WidgetsBinding.instance!.pipelineOwner.semanticsOwner == null)
|
||||
throw StateError('Semantics are not enabled. '
|
||||
'Make sure to call tester.ensureSemantics() before using '
|
||||
'this finder, and call dispose on its return value after.');
|
||||
@@ -375,7 +375,7 @@ abstract class Finder {
|
||||
@protected
|
||||
Iterable<Element> get allCandidates {
|
||||
return collectAllElementsFrom(
|
||||
WidgetsBinding.instance.renderViewElement!,
|
||||
WidgetsBinding.instance!.renderViewElement!,
|
||||
skipOffstage: skipOffstage,
|
||||
);
|
||||
}
|
||||
@@ -518,7 +518,7 @@ class _HitTestableFinder extends ChainedFinder {
|
||||
final RenderBox box = candidate.renderObject! as RenderBox;
|
||||
final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size));
|
||||
final HitTestResult hitResult = HitTestResult();
|
||||
WidgetsBinding.instance.hitTest(hitResult, absoluteOffset);
|
||||
WidgetsBinding.instance!.hitTest(hitResult, absoluteOffset);
|
||||
for (final HitTestEntry entry in hitResult.path) {
|
||||
if (entry.target == candidate.renderObject) {
|
||||
yield candidate;
|
||||
|
||||
@@ -1677,7 +1677,7 @@ class _MatchesReferenceImage extends AsyncMatcher {
|
||||
imageFuture = captureImage(elements.single);
|
||||
}
|
||||
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
return binding.runAsync<String?>(() async {
|
||||
final ui.Image image = await imageFuture;
|
||||
final ByteData? bytes = await image.toByteData();
|
||||
|
||||
@@ -130,7 +130,7 @@ void testWidgets(
|
||||
}) {
|
||||
assert(variant != null);
|
||||
assert(variant.values.isNotEmpty, 'There must be at least one value to test in the testing variant.');
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
final WidgetTester tester = WidgetTester._(binding);
|
||||
for (final dynamic value in variant.values) {
|
||||
final String variationDescription = variant.describeValue(value);
|
||||
@@ -404,7 +404,7 @@ Future<void> benchmarkWidgets(
|
||||
print(kDebugWarning);
|
||||
return true;
|
||||
}());
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
assert(binding is! AutomatedTestWidgetsFlutterBinding);
|
||||
final WidgetTester tester = WidgetTester._(binding);
|
||||
SemanticsHandle? semanticsHandle;
|
||||
|
||||
@@ -68,9 +68,9 @@ void main() {
|
||||
test('Test pump on LiveWidgetController', () async {
|
||||
runApp(const MaterialApp(home: Center(child: CountButton())));
|
||||
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
final WidgetController controller =
|
||||
LiveWidgetController(WidgetsBinding.instance);
|
||||
LiveWidgetController(WidgetsBinding.instance!);
|
||||
await controller.tap(find.text('Counter 0'));
|
||||
expect(find.text('Counter 0'), findsOneWidget);
|
||||
expect(find.text('Counter 1'), findsNothing);
|
||||
@@ -81,9 +81,9 @@ void main() {
|
||||
|
||||
test('Test pumpAndSettle on LiveWidgetController', () async {
|
||||
runApp(const MaterialApp(home: Center(child: AnimateSample())));
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
final WidgetController controller =
|
||||
LiveWidgetController(WidgetsBinding.instance);
|
||||
LiveWidgetController(WidgetsBinding.instance!);
|
||||
expect(find.text('Value: 1.0'), findsNothing);
|
||||
await controller.pumpAndSettle();
|
||||
expect(find.text('Value: 1.0'), findsOneWidget);
|
||||
@@ -101,9 +101,9 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
final WidgetController controller =
|
||||
LiveWidgetController(WidgetsBinding.instance);
|
||||
LiveWidgetController(WidgetsBinding.instance!);
|
||||
|
||||
final Offset location = controller.getCenter(find.text('test'));
|
||||
final List<PointerEventRecord> records = <PointerEventRecord>[
|
||||
|
||||
@@ -162,7 +162,7 @@ void main() {
|
||||
|
||||
final Widget target = _AlwaysAnimating(
|
||||
onPaint: () {
|
||||
final int current = SchedulerBinding.instance.currentFrameTimeStamp.inMicroseconds;
|
||||
final int current = SchedulerBinding.instance!.currentFrameTimeStamp.inMicroseconds;
|
||||
initial ??= current;
|
||||
logPaints.add(current - initial!);
|
||||
},
|
||||
@@ -751,7 +751,7 @@ void main() {
|
||||
flutterErrorDetails = details;
|
||||
};
|
||||
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
await binding.runTest(() async {
|
||||
final Timer timer = Timer(const Duration(seconds: 1), () {});
|
||||
expect(timer.isActive, true);
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
realValue: ui.window.devicePixelRatio,
|
||||
fakeValue: 2.5,
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.devicePixelRatio;
|
||||
return WidgetsBinding.instance!.window.devicePixelRatio;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, double fakeValue) {
|
||||
binding.window.devicePixelRatioTestValue = fakeValue;
|
||||
@@ -35,7 +35,7 @@ void main() {
|
||||
realValue: ui.window.physicalSize,
|
||||
fakeValue: const Size(50, 50),
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.physicalSize;
|
||||
return WidgetsBinding.instance!.window.physicalSize;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, Size fakeValue) {
|
||||
binding.window.physicalSizeTestValue = fakeValue;
|
||||
@@ -49,7 +49,7 @@ void main() {
|
||||
realValue: ui.window.viewInsets,
|
||||
fakeValue: const FakeWindowPadding(),
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.viewInsets;
|
||||
return WidgetsBinding.instance!.window.viewInsets;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, WindowPadding fakeValue) {
|
||||
binding.window.viewInsetsTestValue = fakeValue;
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
realValue: ui.window.padding,
|
||||
fakeValue: const FakeWindowPadding(),
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.padding;
|
||||
return WidgetsBinding.instance!.window.padding;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, WindowPadding fakeValue) {
|
||||
binding.window.paddingTestValue = fakeValue;
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
realValue: ui.window.locale,
|
||||
fakeValue: const Locale('fake_language_code'),
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.locale;
|
||||
return WidgetsBinding.instance!.window.locale;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, Locale fakeValue) {
|
||||
binding.window.localeTestValue = fakeValue;
|
||||
@@ -91,7 +91,7 @@ void main() {
|
||||
realValue: ui.window.locales,
|
||||
fakeValue: <Locale>[const Locale('fake_language_code')],
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.locales;
|
||||
return WidgetsBinding.instance!.window.locales;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, List<Locale> fakeValue) {
|
||||
binding.window.localesTestValue = fakeValue;
|
||||
@@ -105,7 +105,7 @@ void main() {
|
||||
realValue: ui.window.textScaleFactor,
|
||||
fakeValue: 2.5,
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.textScaleFactor;
|
||||
return WidgetsBinding.instance!.window.textScaleFactor;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, double fakeValue) {
|
||||
binding.window.textScaleFactorTestValue = fakeValue;
|
||||
@@ -119,7 +119,7 @@ void main() {
|
||||
realValue: ui.window.alwaysUse24HourFormat,
|
||||
fakeValue: !ui.window.alwaysUse24HourFormat,
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.alwaysUse24HourFormat;
|
||||
return WidgetsBinding.instance!.window.alwaysUse24HourFormat;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, bool fakeValue) {
|
||||
binding.window.alwaysUse24HourFormatTestValue = fakeValue;
|
||||
@@ -133,7 +133,7 @@ void main() {
|
||||
realValue: ui.window.defaultRouteName,
|
||||
fakeValue: 'fake_route',
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.defaultRouteName;
|
||||
return WidgetsBinding.instance!.window.defaultRouteName;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, String fakeValue) {
|
||||
binding.window.defaultRouteNameTestValue = fakeValue;
|
||||
@@ -147,7 +147,7 @@ void main() {
|
||||
realValue: ui.window.accessibilityFeatures,
|
||||
fakeValue: const FakeAccessibilityFeatures(),
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.accessibilityFeatures;
|
||||
return WidgetsBinding.instance!.window.accessibilityFeatures;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, AccessibilityFeatures fakeValue) {
|
||||
binding.window.accessibilityFeaturesTestValue = fakeValue;
|
||||
@@ -161,7 +161,7 @@ void main() {
|
||||
realValue: Brightness.light,
|
||||
fakeValue: Brightness.dark,
|
||||
propertyRetriever: () {
|
||||
return WidgetsBinding.instance.window.platformBrightness;
|
||||
return WidgetsBinding.instance!.window.platformBrightness;
|
||||
},
|
||||
propertyFaker: (TestWidgetsFlutterBinding binding, Brightness fakeValue) {
|
||||
binding.window.platformBrightnessTestValue = fakeValue;
|
||||
@@ -182,8 +182,8 @@ void main() {
|
||||
testWindow.clearAllTestValues();
|
||||
|
||||
// Verify that the window once again reports real property values.
|
||||
expect(WidgetsBinding.instance.window.devicePixelRatio, originalDevicePixelRatio);
|
||||
expect(WidgetsBinding.instance.window.textScaleFactor, originalTextScaleFactor);
|
||||
expect(WidgetsBinding.instance!.window.devicePixelRatio, originalDevicePixelRatio);
|
||||
expect(WidgetsBinding.instance!.window.textScaleFactor, originalTextScaleFactor);
|
||||
});
|
||||
|
||||
testWidgets('TestWindow sends fake locales when WidgetsBindingObserver notifiers are called', (WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user