Unverified Commit 3205736f authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add ui.Window fallback to TestViewConfiguration (#27987)

parent 9bc56566
......@@ -1319,10 +1319,16 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
/// size onto the actual display using the [BoxFit.contain] algorithm.
class TestViewConfiguration extends ViewConfiguration {
/// Creates a [TestViewConfiguration] with the given size. Defaults to 800x600.
TestViewConfiguration({
///
/// If a [window] instance is not provided it defaults to [ui.window].
factory TestViewConfiguration({
Size size = _kDefaultTestViewportSize,
ui.Window window,
})
}) {
return TestViewConfiguration._(size, window ?? ui.window);
}
TestViewConfiguration._(Size size, ui.Window window)
: _paintMatrix = _getMatrix(size, window.devicePixelRatio, window),
_hitTestMatrix = _getMatrix(size, 1.0, window),
super(size: size);
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group(TestViewConfiguration, () {
test('is initialized with top-level window if one is not provided', () {
// The code below will throw without the default.
TestViewConfiguration(size: const Size(1280.0, 800.0));
});
});
}
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