Unverified Commit 914f77f8 authored by Matt Carroll's avatar Matt Carroll Committed by GitHub

Bugfix: Add platformBrightness to TestWindow. (#27569)

* Bugfix: Add platformBrightness to TestWindow.

* Manual engine roll:

cc27cafb8 Implemented Dark Mode for Android (#25525) ([flutter/engine#7488](https://github.com/flutter/engine/pull/7488))
9c05cbcfb Roll src/third_party/dart b53dceadaa..5823be65af (5 commits) 5823be65af [vm/compiler] Continued graph checker development (reland) 8231cdb7a3 [gardening] Update status for issue 35854 db7f848632 [vm] Remove dead BigInt code. 35ab1755f4 Support more type propagation for code-as-ui features 569ee07f91 [vm] Cleanup class finalization checks
ec5e6f6ef Ensure dart2js and kernel worker snapshots are copied out of gen dir ([flutter/engine#7692](https://github.com/flutter/engine/pull/7692))
8b5fa65c4 Roll src/third_party/skia 50ea3c06b80f..2d35a1c87553 (6 commits) ([flutter/engine#7693](https://github.com/flutter/engine/pull/7693))
parent 1e127003
93aa035dd46999353d8f7fe4be61e6599c794b4b
cc27cafb840f6fd57b86a36a3e7ed5461575f10a
......@@ -151,6 +151,24 @@ class TestWindow implements Window {
_textScaleFactorTestValue = null;
}
@override
Brightness get platformBrightness => _platformBrightnessTestValue ?? _window.platformBrightness;
Brightness _platformBrightnessTestValue;
@override
VoidCallback get onPlatformBrightnessChanged => _window.onPlatformBrightnessChanged;
@override
set onPlatformBrightnessChanged(VoidCallback callback) {
_window.onPlatformBrightnessChanged =callback;
}
/// Hides the real text scale factor and reports the given [platformBrightnessTestValue] instead.
set platformBrightnessTestValue(Brightness platformBrightnessTestValue) {
_platformBrightnessTestValue = platformBrightnessTestValue;
}
/// Deletes any existing test platform brightness and returns to using the real platform brightness.
void clearPlatformBrightnessTestValue() {
_platformBrightnessTestValue = null;
}
@override
bool get alwaysUse24HourFormat => _alwaysUse24HourFormatTestValue ?? _window.alwaysUse24HourFormat;
bool _alwaysUse24HourFormatTestValue;
......@@ -292,6 +310,7 @@ class TestWindow implements Window {
clearAlwaysUse24HourTestValue();
clearDefaultRouteNameTestValue();
clearDevicePixelRatioTestValue();
clearPlatformBrightnessTestValue();
clearLocaleTestValue();
clearLocalesTestValue();
clearPaddingTestValue();
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:ui' as ui show window;
import 'dart:ui' show Size, Locale, WindowPadding, AccessibilityFeatures;
import 'dart:ui' show Size, Locale, WindowPadding, AccessibilityFeatures, Brightness;
import 'package:flutter/widgets.dart' show WidgetsBinding;
import 'package:flutter_test/flutter_test.dart';
......@@ -164,6 +164,20 @@ void main() {
);
});
testWidgets('TestWindow can fake platform brightness', (WidgetTester tester) async {
verifyThatTestWindowCanFakeProperty<Brightness>(
tester: tester,
realValue: Brightness.light,
fakeValue: Brightness.dark,
propertyRetriever: () {
return WidgetsBinding.instance.window.platformBrightness;
},
propertyFaker: (TestWidgetsFlutterBinding binding, Brightness fakeValue) {
binding.window.platformBrightnessTestValue = fakeValue;
}
);
});
testWidgets('TestWindow can clear out fake properties all at once', (WidgetTester tester) {
final double originalDevicePixelRatio = ui.window.devicePixelRatio;
final double originalTextScaleFactor = ui.window.textScaleFactor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment