Unverified Commit 5feee0d8 authored by Dan Field's avatar Dan Field Committed by GitHub

Fix DPR in test view configuration (#88609)

parent 9a190e5b
......@@ -1732,7 +1732,7 @@ class TestViewConfiguration extends ViewConfiguration {
TestViewConfiguration._(Size size, ui.FlutterView window)
: _paintMatrix = _getMatrix(size, window.devicePixelRatio, window),
_hitTestMatrix = _getMatrix(size, 1.0, window),
super(size: size);
super(size: size, devicePixelRatio: window.devicePixelRatio);
static Matrix4 _getMatrix(Size size, double devicePixelRatio, ui.FlutterView window) {
final double inverseRatio = devicePixelRatio / window.devicePixelRatio;
......
......@@ -24,6 +24,11 @@ void main() {
// The code below will throw without the default.
TestViewConfiguration(size: const Size(1280.0, 800.0));
});
test('sets the DPR to match the window', () {
final TestViewConfiguration configuration = TestViewConfiguration(size: const Size(1280.0, 800.0));
expect(configuration.devicePixelRatio, binding.window.devicePixelRatio);
});
});
group(AutomatedTestWidgetsFlutterBinding, () {
......
......@@ -396,14 +396,6 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab
set defaultTestTimeout(Timeout timeout) => _defaultTestTimeout = timeout;
Timeout? _defaultTestTimeout;
@override
void attachRootWidget(Widget rootWidget) {
// This is a workaround where screenshots of root widgets have incorrect
// bounds.
// TODO(jiahaog): Remove when https://github.com/flutter/flutter/issues/66006 is fixed.
super.attachRootWidget(RepaintBoundary(child: rootWidget));
}
@override
void reportExceptionNoticed(FlutterErrorDetails exception) {
// This method is called to log errors as they happen, and they will also
......
......@@ -126,11 +126,10 @@ Future<void> main() async {
});
});
// TODO(jiahaog): Remove when https://github.com/flutter/flutter/issues/66006 is fixed.
testWidgets('root widgets are wrapped with a RepaintBoundary', (WidgetTester tester) async {
testWidgets('root view reports correct dimensions', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder());
expect(find.byType(RepaintBoundary), findsOneWidget);
expect(tester.binding.renderView.paintBounds, const Rect.fromLTWH(0, 0, 2400, 1800));
});
});
......
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