add ui.Window fallback to TestViewConfiguration (#27987)
This commit is contained in:
@@ -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);
|
||||
|
||||
17
packages/flutter_test/test/bindings_test.dart
Normal file
17
packages/flutter_test/test/bindings_test.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user