Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f3dbefd3
Unverified
Commit
f3dbefd3
authored
Aug 09, 2019
by
Kate Lovett
Committed by
GitHub
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Adding physicalDepth to MediaQueryData & TestWindow (#37718)" (#37938)
This reverts commit
3a2d3081
.
parent
8fe424f9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
138 deletions
+58
-138
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+22
-48
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+0
-4
window.dart
packages/flutter_test/lib/src/window.dart
+36
-72
window_test.dart
packages/flutter_test/test/window_test.dart
+0
-14
No files found.
packages/flutter/lib/src/widgets/media_query.dart
View file @
f3dbefd3
...
@@ -74,7 +74,6 @@ enum Orientation {
...
@@ -74,7 +74,6 @@ enum Orientation {
/// widgets that reduce those properties by the same amount.
/// widgets that reduce those properties by the same amount.
/// The [removePadding], [removeViewPadding], and [removeInsets] methods are
/// The [removePadding], [removeViewPadding], and [removeInsets] methods are
/// useful for this.
/// useful for this.
///
/// See also:
/// See also:
///
///
/// * [Scaffold], [SafeArea], [CupertinoTabScaffold], and
/// * [Scaffold], [SafeArea], [CupertinoTabScaffold], and
...
@@ -94,7 +93,6 @@ class MediaQueryData {
...
@@ -94,7 +93,6 @@ class MediaQueryData {
this
.
padding
=
EdgeInsets
.
zero
,
this
.
padding
=
EdgeInsets
.
zero
,
this
.
viewInsets
=
EdgeInsets
.
zero
,
this
.
viewInsets
=
EdgeInsets
.
zero
,
this
.
viewPadding
=
EdgeInsets
.
zero
,
this
.
viewPadding
=
EdgeInsets
.
zero
,
this
.
physicalDepth
=
double
.
maxFinite
,
this
.
alwaysUse24HourFormat
=
false
,
this
.
alwaysUse24HourFormat
=
false
,
this
.
accessibleNavigation
=
false
,
this
.
accessibleNavigation
=
false
,
this
.
invertColors
=
false
,
this
.
invertColors
=
false
,
...
@@ -116,7 +114,6 @@ class MediaQueryData {
...
@@ -116,7 +114,6 @@ class MediaQueryData {
padding
=
EdgeInsets
.
fromWindowPadding
(
window
.
padding
,
window
.
devicePixelRatio
),
padding
=
EdgeInsets
.
fromWindowPadding
(
window
.
padding
,
window
.
devicePixelRatio
),
viewPadding
=
EdgeInsets
.
fromWindowPadding
(
window
.
viewPadding
,
window
.
devicePixelRatio
),
viewPadding
=
EdgeInsets
.
fromWindowPadding
(
window
.
viewPadding
,
window
.
devicePixelRatio
),
viewInsets
=
EdgeInsets
.
fromWindowPadding
(
window
.
viewInsets
,
window
.
devicePixelRatio
),
viewInsets
=
EdgeInsets
.
fromWindowPadding
(
window
.
viewInsets
,
window
.
devicePixelRatio
),
physicalDepth
=
window
.
physicalDepth
,
accessibleNavigation
=
window
.
accessibilityFeatures
.
accessibleNavigation
,
accessibleNavigation
=
window
.
accessibilityFeatures
.
accessibleNavigation
,
invertColors
=
window
.
accessibilityFeatures
.
invertColors
,
invertColors
=
window
.
accessibilityFeatures
.
invertColors
,
disableAnimations
=
window
.
accessibilityFeatures
.
disableAnimations
,
disableAnimations
=
window
.
accessibilityFeatures
.
disableAnimations
,
...
@@ -213,19 +210,6 @@ class MediaQueryData {
...
@@ -213,19 +210,6 @@ class MediaQueryData {
/// property and how it relates to [padding] and [viewInsets].
/// property and how it relates to [padding] and [viewInsets].
final
EdgeInsets
viewPadding
;
final
EdgeInsets
viewPadding
;
/// The physical depth is the maximum elevation that the Window allows.
///
/// Physical layers drawn at or above this elevation will have their elevation
/// clamped to this value. This can happen if the physical layer itself has
/// an elevation larger than the available depth, or if some ancestor of the
/// layer causes it to have a cumulative elevation that is larger than the
/// available depth.
///
/// The default value is [double.maxFinite], which is used for platforms that
/// do not specify a maximum elevation. This property is currently only
/// expected to be set to a non-default value on Fuchsia.
final
double
physicalDepth
;
/// Whether to use 24-hour format when formatting time.
/// Whether to use 24-hour format when formatting time.
///
///
/// The behavior of this flag is different across platforms:
/// The behavior of this flag is different across platforms:
...
@@ -275,8 +259,7 @@ class MediaQueryData {
...
@@ -275,8 +259,7 @@ class MediaQueryData {
/// * [Window.AccessibilityFeatures], where the setting originates.
/// * [Window.AccessibilityFeatures], where the setting originates.
final
bool
boldText
;
final
bool
boldText
;
/// The orientation of the media (e.g., whether the device is in landscape or
/// The orientation of the media (e.g., whether the device is in landscape or portrait mode).
/// portrait mode).
Orientation
get
orientation
{
Orientation
get
orientation
{
return
size
.
width
>
size
.
height
?
Orientation
.
landscape
:
Orientation
.
portrait
;
return
size
.
width
>
size
.
height
?
Orientation
.
landscape
:
Orientation
.
portrait
;
}
}
...
@@ -291,7 +274,6 @@ class MediaQueryData {
...
@@ -291,7 +274,6 @@ class MediaQueryData {
EdgeInsets
padding
,
EdgeInsets
padding
,
EdgeInsets
viewPadding
,
EdgeInsets
viewPadding
,
EdgeInsets
viewInsets
,
EdgeInsets
viewInsets
,
double
physicalDepth
,
bool
alwaysUse24HourFormat
,
bool
alwaysUse24HourFormat
,
bool
disableAnimations
,
bool
disableAnimations
,
bool
invertColors
,
bool
invertColors
,
...
@@ -306,7 +288,6 @@ class MediaQueryData {
...
@@ -306,7 +288,6 @@ class MediaQueryData {
padding:
padding
??
this
.
padding
,
padding:
padding
??
this
.
padding
,
viewPadding:
viewPadding
??
this
.
viewPadding
,
viewPadding:
viewPadding
??
this
.
viewPadding
,
viewInsets:
viewInsets
??
this
.
viewInsets
,
viewInsets:
viewInsets
??
this
.
viewInsets
,
physicalDepth:
physicalDepth
??
this
.
physicalDepth
,
alwaysUse24HourFormat:
alwaysUse24HourFormat
??
this
.
alwaysUse24HourFormat
,
alwaysUse24HourFormat:
alwaysUse24HourFormat
??
this
.
alwaysUse24HourFormat
,
invertColors:
invertColors
??
this
.
invertColors
,
invertColors:
invertColors
??
this
.
invertColors
,
disableAnimations:
disableAnimations
??
this
.
disableAnimations
,
disableAnimations:
disableAnimations
??
this
.
disableAnimations
,
...
@@ -324,7 +305,7 @@ class MediaQueryData {
...
@@ -324,7 +305,7 @@ class MediaQueryData {
///
///
/// See also:
/// See also:
///
///
/// * [
MediaQuery.removePadding], which uses this method to remove [padding]
/// * [
new MediaQuery.removePadding], which uses this method to remove padding
/// from the ambient [MediaQuery].
/// from the ambient [MediaQuery].
/// * [SafeArea], which both removes the padding from the [MediaQuery] and
/// * [SafeArea], which both removes the padding from the [MediaQuery] and
/// adds a [Padding] widget.
/// adds a [Padding] widget.
...
@@ -373,8 +354,8 @@ class MediaQueryData {
...
@@ -373,8 +354,8 @@ class MediaQueryData {
///
///
/// See also:
/// See also:
///
///
/// * [MediaQuery.removeViewInsets], which uses this method to remove
/// * [
new
MediaQuery.removeViewInsets], which uses this method to remove
///
[viewInsets]
from the ambient [MediaQuery].
///
padding
from the ambient [MediaQuery].
/// * [removePadding], the same thing but for [padding].
/// * [removePadding], the same thing but for [padding].
/// * [removeViewPadding], the same thing but for [viewPadding].
/// * [removeViewPadding], the same thing but for [viewPadding].
MediaQueryData
removeViewInsets
({
MediaQueryData
removeViewInsets
({
...
@@ -420,8 +401,8 @@ class MediaQueryData {
...
@@ -420,8 +401,8 @@ class MediaQueryData {
///
///
/// See also:
/// See also:
///
///
/// * [MediaQuery.removeViewPadding], which uses this method to remove
/// * [
new
MediaQuery.removeViewPadding], which uses this method to remove
///
[viewPadding]
from the ambient [MediaQuery].
///
padding
from the ambient [MediaQuery].
/// * [removePadding], the same thing but for [padding].
/// * [removePadding], the same thing but for [padding].
/// * [removeViewInsets], the same thing but for [viewInsets].
/// * [removeViewInsets], the same thing but for [viewInsets].
MediaQueryData
removeViewPadding
({
MediaQueryData
removeViewPadding
({
...
@@ -470,7 +451,6 @@ class MediaQueryData {
...
@@ -470,7 +451,6 @@ class MediaQueryData {
&&
typedOther
.
padding
==
padding
&&
typedOther
.
padding
==
padding
&&
typedOther
.
viewPadding
==
viewPadding
&&
typedOther
.
viewPadding
==
viewPadding
&&
typedOther
.
viewInsets
==
viewInsets
&&
typedOther
.
viewInsets
==
viewInsets
&&
typedOther
.
physicalDepth
==
physicalDepth
&&
typedOther
.
alwaysUse24HourFormat
==
alwaysUse24HourFormat
&&
typedOther
.
alwaysUse24HourFormat
==
alwaysUse24HourFormat
&&
typedOther
.
disableAnimations
==
disableAnimations
&&
typedOther
.
disableAnimations
==
disableAnimations
&&
typedOther
.
invertColors
==
invertColors
&&
typedOther
.
invertColors
==
invertColors
...
@@ -488,7 +468,6 @@ class MediaQueryData {
...
@@ -488,7 +468,6 @@ class MediaQueryData {
padding
,
padding
,
viewPadding
,
viewPadding
,
viewInsets
,
viewInsets
,
physicalDepth
,
alwaysUse24HourFormat
,
alwaysUse24HourFormat
,
disableAnimations
,
disableAnimations
,
invertColors
,
invertColors
,
...
@@ -507,7 +486,6 @@ class MediaQueryData {
...
@@ -507,7 +486,6 @@ class MediaQueryData {
'padding:
$padding
, '
'padding:
$padding
, '
'viewPadding:
$viewPadding
, '
'viewPadding:
$viewPadding
, '
'viewInsets:
$viewInsets
, '
'viewInsets:
$viewInsets
, '
'physicalDepth:
$physicalDepth
, '
'alwaysUse24HourFormat:
$alwaysUse24HourFormat
, '
'alwaysUse24HourFormat:
$alwaysUse24HourFormat
, '
'accessibleNavigation:
$accessibleNavigation
, '
'accessibleNavigation:
$accessibleNavigation
, '
'disableAnimations:
$disableAnimations
, '
'disableAnimations:
$disableAnimations
, '
...
@@ -551,8 +529,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -551,8 +529,8 @@ class MediaQuery extends InheritedWidget {
assert
(
data
!=
null
),
assert
(
data
!=
null
),
super
(
key:
key
,
child:
child
);
super
(
key:
key
,
child:
child
);
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
from
///
from the given context, but removes the specified padding
.
///
the given context, but removes the specified paddings
.
///
///
/// This should be inserted into the widget tree when the [MediaQuery] padding
/// This should be inserted into the widget tree when the [MediaQuery] padding
/// is consumed by a widget in such a way that the padding is no longer
/// is consumed by a widget in such a way that the padding is no longer
...
@@ -572,11 +550,9 @@ class MediaQuery extends InheritedWidget {
...
@@ -572,11 +550,9 @@ class MediaQuery extends InheritedWidget {
///
///
/// * [SafeArea], which both removes the padding from the [MediaQuery] and
/// * [SafeArea], which both removes the padding from the [MediaQuery] and
/// adds a [Padding] widget.
/// adds a [Padding] widget.
/// * [MediaQueryData.padding], the affected property of the
/// * [MediaQueryData.padding], the affected property of the [MediaQueryData].
/// [MediaQueryData].
/// * [new removeViewInsets], the same thing but for removing view insets.
/// * [removeViewInsets], the same thing but for [MediaQueryData.viewInsets].
/// * [new removeViewPadding], the same thing but for removing view insets.
/// * [removeViewPadding], the same thing but for
/// [MediaQueryData.viewPadding].
factory
MediaQuery
.
removePadding
({
factory
MediaQuery
.
removePadding
({
Key
key
,
Key
key
,
@required
BuildContext
context
,
@required
BuildContext
context
,
...
@@ -598,8 +574,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -598,8 +574,8 @@ class MediaQuery extends InheritedWidget {
);
);
}
}
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
from
///
from
the given context, but removes the specified view insets.
/// the given context, but removes the specified view insets.
///
///
/// This should be inserted into the widget tree when the [MediaQuery] view
/// This should be inserted into the widget tree when the [MediaQuery] view
/// insets are consumed by a widget in such a way that the view insets are no
/// insets are consumed by a widget in such a way that the view insets are no
...
@@ -617,11 +593,9 @@ class MediaQuery extends InheritedWidget {
...
@@ -617,11 +593,9 @@ class MediaQuery extends InheritedWidget {
///
///
/// See also:
/// See also:
///
///
/// * [MediaQueryData.viewInsets], the affected property of the
/// * [MediaQueryData.viewInsets], the affected property of the [MediaQueryData].
/// [MediaQueryData].
/// * [new removePadding], the same thing but for removing paddings.
/// * [removePadding], the same thing but for [MediaQueryData.padding].
/// * [new removeViewPadding], the same thing but for removing view insets.
/// * [removeViewPadding], the same thing but for
/// [MediaQueryData.viewPadding].
factory
MediaQuery
.
removeViewInsets
({
factory
MediaQuery
.
removeViewInsets
({
Key
key
,
Key
key
,
@required
BuildContext
context
,
@required
BuildContext
context
,
...
@@ -643,8 +617,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -643,8 +617,8 @@ class MediaQuery extends InheritedWidget {
);
);
}
}
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
/// Creates a new [MediaQuery] that inherits from the ambient [MediaQuery]
from
///
from
the given context, but removes the specified view padding.
/// the given context, but removes the specified view padding.
///
///
/// This should be inserted into the widget tree when the [MediaQuery] view
/// This should be inserted into the widget tree when the [MediaQuery] view
/// padding is consumed by a widget in such a way that the view padding is no
/// padding is consumed by a widget in such a way that the view padding is no
...
@@ -664,8 +638,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -664,8 +638,8 @@ class MediaQuery extends InheritedWidget {
///
///
/// * [MediaQueryData.viewPadding], the affected property of the
/// * [MediaQueryData.viewPadding], the affected property of the
/// [MediaQueryData].
/// [MediaQueryData].
/// * [
removePadding], the same thing but for [MediaQueryData.padding]
.
/// * [
new removePadding], the same thing but for removing paddings
.
/// * [
removeViewInsets], the same thing but for [MediaQueryData.viewInsets]
.
/// * [
new removeViewInsets], the same thing but for removing view insets
.
factory
MediaQuery
.
removeViewPadding
({
factory
MediaQuery
.
removeViewPadding
({
Key
key
,
Key
key
,
@required
BuildContext
context
,
@required
BuildContext
context
,
...
@@ -697,8 +671,8 @@ class MediaQuery extends InheritedWidget {
...
@@ -697,8 +671,8 @@ class MediaQuery extends InheritedWidget {
/// context.
/// context.
///
///
/// You can use this function to query the size an orientation of the screen.
/// You can use this function to query the size an orientation of the screen.
/// When that information changes, your widget will be scheduled to be
/// When that information changes, your widget will be scheduled to be
rebuilt,
///
rebuilt,
keeping your widget up-to-date.
/// keeping your widget up-to-date.
///
///
/// Typical usage is as follows:
/// Typical usage is as follows:
///
///
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
f3dbefd3
...
@@ -47,7 +47,6 @@ void main() {
...
@@ -47,7 +47,6 @@ void main() {
expect
(
data
.
disableAnimations
,
false
);
expect
(
data
.
disableAnimations
,
false
);
expect
(
data
.
boldText
,
false
);
expect
(
data
.
boldText
,
false
);
expect
(
data
.
platformBrightness
,
Brightness
.
light
);
expect
(
data
.
platformBrightness
,
Brightness
.
light
);
expect
(
data
.
physicalDepth
,
equals
(
WidgetsBinding
.
instance
.
window
.
physicalDepth
));
});
});
testWidgets
(
'MediaQueryData.copyWith defaults to source'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MediaQueryData.copyWith defaults to source'
,
(
WidgetTester
tester
)
async
{
...
@@ -59,7 +58,6 @@ void main() {
...
@@ -59,7 +58,6 @@ void main() {
expect
(
copied
.
padding
,
data
.
padding
);
expect
(
copied
.
padding
,
data
.
padding
);
expect
(
copied
.
viewPadding
,
data
.
viewPadding
);
expect
(
copied
.
viewPadding
,
data
.
viewPadding
);
expect
(
copied
.
viewInsets
,
data
.
viewInsets
);
expect
(
copied
.
viewInsets
,
data
.
viewInsets
);
expect
(
copied
.
physicalDepth
,
data
.
physicalDepth
);
expect
(
copied
.
alwaysUse24HourFormat
,
data
.
alwaysUse24HourFormat
);
expect
(
copied
.
alwaysUse24HourFormat
,
data
.
alwaysUse24HourFormat
);
expect
(
copied
.
accessibleNavigation
,
data
.
accessibleNavigation
);
expect
(
copied
.
accessibleNavigation
,
data
.
accessibleNavigation
);
expect
(
copied
.
invertColors
,
data
.
invertColors
);
expect
(
copied
.
invertColors
,
data
.
invertColors
);
...
@@ -77,7 +75,6 @@ void main() {
...
@@ -77,7 +75,6 @@ void main() {
padding:
const
EdgeInsets
.
all
(
9.10938
),
padding:
const
EdgeInsets
.
all
(
9.10938
),
viewPadding:
const
EdgeInsets
.
all
(
11.24031
),
viewPadding:
const
EdgeInsets
.
all
(
11.24031
),
viewInsets:
const
EdgeInsets
.
all
(
1.67262
),
viewInsets:
const
EdgeInsets
.
all
(
1.67262
),
physicalDepth:
120.0
,
alwaysUse24HourFormat:
true
,
alwaysUse24HourFormat:
true
,
accessibleNavigation:
true
,
accessibleNavigation:
true
,
invertColors:
true
,
invertColors:
true
,
...
@@ -91,7 +88,6 @@ void main() {
...
@@ -91,7 +88,6 @@ void main() {
expect
(
copied
.
padding
,
const
EdgeInsets
.
all
(
9.10938
));
expect
(
copied
.
padding
,
const
EdgeInsets
.
all
(
9.10938
));
expect
(
copied
.
viewPadding
,
const
EdgeInsets
.
all
(
11.24031
));
expect
(
copied
.
viewPadding
,
const
EdgeInsets
.
all
(
11.24031
));
expect
(
copied
.
viewInsets
,
const
EdgeInsets
.
all
(
1.67262
));
expect
(
copied
.
viewInsets
,
const
EdgeInsets
.
all
(
1.67262
));
expect
(
copied
.
physicalDepth
,
120.0
);
expect
(
copied
.
alwaysUse24HourFormat
,
true
);
expect
(
copied
.
alwaysUse24HourFormat
,
true
);
expect
(
copied
.
accessibleNavigation
,
true
);
expect
(
copied
.
accessibleNavigation
,
true
);
expect
(
copied
.
invertColors
,
true
);
expect
(
copied
.
invertColors
,
true
);
...
...
packages/flutter_test/lib/src/window.dart
View file @
f3dbefd3
...
@@ -11,10 +11,10 @@ import 'package:meta/meta.dart';
...
@@ -11,10 +11,10 @@ import 'package:meta/meta.dart';
/// for testing purposes.
/// for testing purposes.
///
///
/// Tests for certain widgets, e.g., [MaterialApp], might require faking certain
/// Tests for certain widgets, e.g., [MaterialApp], might require faking certain
/// properties of a [Window]. [TestWindow] facilitates the faking of these
/// properties of a [Window]. [TestWindow] facilitates the faking of these
properties
///
properties by overriding the properties of a real [Window] with desired fak
e
///
by overidding the properties of a real [Window] with desired fake values. Th
e
///
values. The binding used within tests, [TestWidgetsFlutterBinding], contains
///
binding used within tests, [TestWidgetsFlutterBinding], contains a [TestWindow]
///
a [TestWindow]
that is used by all tests.
/// that is used by all tests.
///
///
/// ## Sample Code
/// ## Sample Code
///
///
...
@@ -42,11 +42,10 @@ import 'package:meta/meta.dart';
...
@@ -42,11 +42,10 @@ import 'package:meta/meta.dart';
/// return to using the real [Window] property, [TestWindow] provides
/// return to using the real [Window] property, [TestWindow] provides
/// methods to clear each individual test value, e.g., [clearLocaleTestValue()].
/// methods to clear each individual test value, e.g., [clearLocaleTestValue()].
///
///
/// To clear all fake test values in a [TestWindow], consider using
/// To clear all fake test values in a [TestWindow], consider using [clearAllTestValues()].
/// [clearAllTestValues()].
class
TestWindow
implements
Window
{
class
TestWindow
implements
Window
{
/// Constructs a [TestWindow] that defers all behavior to the given [
Window]
/// Constructs a [TestWindow] that defers all behavior to the given [
window] unless
///
unless explicitly over
ridden for test purposes.
///
explicitly ove
ridden for test purposes.
TestWindow
({
TestWindow
({
@required
Window
window
,
@required
Window
window
,
})
:
_window
=
window
;
})
:
_window
=
window
;
...
@@ -57,14 +56,12 @@ class TestWindow implements Window {
...
@@ -57,14 +56,12 @@ class TestWindow implements Window {
@override
@override
double
get
devicePixelRatio
=>
_devicePixelRatio
??
_window
.
devicePixelRatio
;
double
get
devicePixelRatio
=>
_devicePixelRatio
??
_window
.
devicePixelRatio
;
double
_devicePixelRatio
;
double
_devicePixelRatio
;
/// Hides the real device pixel ratio and reports the given [devicePixelRatio]
/// Hides the real device pixel ratio and reports the given [devicePixelRatio] instead.
/// instead.
set
devicePixelRatioTestValue
(
double
devicePixelRatio
)
{
set
devicePixelRatioTestValue
(
double
devicePixelRatio
)
{
_devicePixelRatio
=
devicePixelRatio
;
_devicePixelRatio
=
devicePixelRatio
;
onMetricsChanged
();
onMetricsChanged
();
}
}
/// Deletes any existing test device pixel ratio and returns to using the real
/// Deletes any existing test device pixel ratio and returns to using the real device pixel ratio.
/// device pixel ratio.
void
clearDevicePixelRatioTestValue
()
{
void
clearDevicePixelRatioTestValue
()
{
_devicePixelRatio
=
null
;
_devicePixelRatio
=
null
;
onMetricsChanged
();
onMetricsChanged
();
...
@@ -73,62 +70,43 @@ class TestWindow implements Window {
...
@@ -73,62 +70,43 @@ class TestWindow implements Window {
@override
@override
Size
get
physicalSize
=>
_physicalSizeTestValue
??
_window
.
physicalSize
;
Size
get
physicalSize
=>
_physicalSizeTestValue
??
_window
.
physicalSize
;
Size
_physicalSizeTestValue
;
Size
_physicalSizeTestValue
;
/// Hides the real physical size and reports the given [physicalSizeTestValue]
/// Hides the real physical size and reports the given [physicalSizeTestValue] instead.
/// instead.
set
physicalSizeTestValue
(
Size
physicalSizeTestValue
)
{
set
physicalSizeTestValue
(
Size
physicalSizeTestValue
)
{
_physicalSizeTestValue
=
physicalSizeTestValue
;
_physicalSizeTestValue
=
physicalSizeTestValue
;
onMetricsChanged
();
onMetricsChanged
();
}
}
/// Deletes any existing test physical size and returns to using the real
/// Deletes any existing test physical size and returns to using the real physical size.
/// physical size.
void
clearPhysicalSizeTestValue
()
{
void
clearPhysicalSizeTestValue
()
{
_physicalSizeTestValue
=
null
;
_physicalSizeTestValue
=
null
;
onMetricsChanged
();
onMetricsChanged
();
}
}
@override
double
get
physicalDepth
=>
_physicalDepthTestValue
??
_window
.
physicalDepth
;
double
_physicalDepthTestValue
;
/// Hides the real physical depth and reports the given
/// [physicalDepthTestValue] instead.
set
physicalDepthTestValue
(
double
physicalDepthTestValue
)
{
_physicalDepthTestValue
=
physicalDepthTestValue
;
onMetricsChanged
();
}
/// Deletes any existing test physical depth and returns to using the real
/// physical depth.
void
clearPhysicalDepthTestValue
()
{
_physicalDepthTestValue
=
null
;
onMetricsChanged
();
}
@override
@override
WindowPadding
get
viewInsets
=>
_viewInsetsTestValue
??
_window
.
viewInsets
;
WindowPadding
get
viewInsets
=>
_viewInsetsTestValue
??
_window
.
viewInsets
;
WindowPadding
_viewInsetsTestValue
;
WindowPadding
_viewInsetsTestValue
;
/// Hides the real view insets and reports the given [viewInsetsTestValue]
/// Hides the real view insets and reports the given [viewInsetsTestValue] instead.
/// instead.
set
viewInsetsTestValue
(
WindowPadding
viewInsetsTestValue
)
{
set
viewInsetsTestValue
(
WindowPadding
viewInsetsTestValue
)
{
_viewInsetsTestValue
=
viewInsetsTestValue
;
_viewInsetsTestValue
=
viewInsetsTestValue
;
onMetricsChanged
();
onMetricsChanged
();
}
}
/// Deletes any existing test view insets and returns to using the real view
/// Deletes any existing test view insets and returns to using the real view insets.
/// insets.
void
clearViewInsetsTestValue
()
{
void
clearViewInsetsTestValue
()
{
_viewInsetsTestValue
=
null
;
_viewInsetsTestValue
=
null
;
onMetricsChanged
();
onMetricsChanged
();
}
}
@override
// TODO(dnfield): Remove this ignore once custom embedders have had time to catch up
// And make this property actually wrap _window.viewPadding.
// @override
// ignore: annotate_overrides, public_member_api_docs
WindowPadding
get
viewPadding
=>
_viewPaddingTestValue
??
_window
.
padding
;
WindowPadding
get
viewPadding
=>
_viewPaddingTestValue
??
_window
.
padding
;
WindowPadding
_viewPaddingTestValue
;
WindowPadding
_viewPaddingTestValue
;
/// Hides the real view padding and reports the given [paddingTestValue]
/// Hides the real padding and reports the given [paddingTestValue] instead.
/// instead.
set
viewPaddingTestValue
(
WindowPadding
viewPaddingTestValue
)
{
set
viewPaddingTestValue
(
WindowPadding
viewPaddingTestValue
)
{
_viewPaddingTestValue
=
viewPaddingTestValue
;
_viewPaddingTestValue
=
viewPaddingTestValue
;
onMetricsChanged
();
onMetricsChanged
();
}
}
/// Deletes any existing test view padding and returns to using the real
/// Deletes any existing test padding and returns to using the real padding.
/// viewPadding.
void
clearViewPaddingTestValue
()
{
void
clearViewPaddingTestValue
()
{
_viewPaddingTestValue
=
null
;
_viewPaddingTestValue
=
null
;
onMetricsChanged
();
onMetricsChanged
();
...
@@ -201,14 +179,12 @@ class TestWindow implements Window {
...
@@ -201,14 +179,12 @@ class TestWindow implements Window {
@override
@override
double
get
textScaleFactor
=>
_textScaleFactorTestValue
??
_window
.
textScaleFactor
;
double
get
textScaleFactor
=>
_textScaleFactorTestValue
??
_window
.
textScaleFactor
;
double
_textScaleFactorTestValue
;
double
_textScaleFactorTestValue
;
/// Hides the real text scale factor and reports the given
/// Hides the real text scale factor and reports the given [textScaleFactorTestValue] instead.
/// [textScaleFactorTestValue] instead.
set
textScaleFactorTestValue
(
double
textScaleFactorTestValue
)
{
set
textScaleFactorTestValue
(
double
textScaleFactorTestValue
)
{
_textScaleFactorTestValue
=
textScaleFactorTestValue
;
_textScaleFactorTestValue
=
textScaleFactorTestValue
;
onTextScaleFactorChanged
();
onTextScaleFactorChanged
();
}
}
/// Deletes any existing test text scale factor and returns to using the real
/// Deletes any existing test text scale factor and returns to using the real text scale factor.
/// text scale factor.
void
clearTextScaleFactorTestValue
()
{
void
clearTextScaleFactorTestValue
()
{
_textScaleFactorTestValue
=
null
;
_textScaleFactorTestValue
=
null
;
onTextScaleFactorChanged
();
onTextScaleFactorChanged
();
...
@@ -223,14 +199,12 @@ class TestWindow implements Window {
...
@@ -223,14 +199,12 @@ class TestWindow implements Window {
set
onPlatformBrightnessChanged
(
VoidCallback
callback
)
{
set
onPlatformBrightnessChanged
(
VoidCallback
callback
)
{
_window
.
onPlatformBrightnessChanged
=
callback
;
_window
.
onPlatformBrightnessChanged
=
callback
;
}
}
/// Hides the real text scale factor and reports the given
/// Hides the real text scale factor and reports the given [platformBrightnessTestValue] instead.
/// [platformBrightnessTestValue] instead.
set
platformBrightnessTestValue
(
Brightness
platformBrightnessTestValue
)
{
set
platformBrightnessTestValue
(
Brightness
platformBrightnessTestValue
)
{
_platformBrightnessTestValue
=
platformBrightnessTestValue
;
_platformBrightnessTestValue
=
platformBrightnessTestValue
;
onPlatformBrightnessChanged
();
onPlatformBrightnessChanged
();
}
}
/// Deletes any existing test platform brightness and returns to using the
/// Deletes any existing test platform brightness and returns to using the real platform brightness.
/// real platform brightness.
void
clearPlatformBrightnessTestValue
()
{
void
clearPlatformBrightnessTestValue
()
{
_platformBrightnessTestValue
=
null
;
_platformBrightnessTestValue
=
null
;
onPlatformBrightnessChanged
();
onPlatformBrightnessChanged
();
...
@@ -239,13 +213,11 @@ class TestWindow implements Window {
...
@@ -239,13 +213,11 @@ class TestWindow implements Window {
@override
@override
bool
get
alwaysUse24HourFormat
=>
_alwaysUse24HourFormatTestValue
??
_window
.
alwaysUse24HourFormat
;
bool
get
alwaysUse24HourFormat
=>
_alwaysUse24HourFormatTestValue
??
_window
.
alwaysUse24HourFormat
;
bool
_alwaysUse24HourFormatTestValue
;
bool
_alwaysUse24HourFormatTestValue
;
/// Hides the real clock format and reports the given
/// Hides the real clock format and reports the given [alwaysUse24HourFormatTestValue] instead.
/// [alwaysUse24HourFormatTestValue] instead.
set
alwaysUse24HourFormatTestValue
(
bool
alwaysUse24HourFormatTestValue
)
{
set
alwaysUse24HourFormatTestValue
(
bool
alwaysUse24HourFormatTestValue
)
{
_alwaysUse24HourFormatTestValue
=
alwaysUse24HourFormatTestValue
;
_alwaysUse24HourFormatTestValue
=
alwaysUse24HourFormatTestValue
;
}
}
/// Deletes any existing test clock format and returns to using the real clock
/// Deletes any existing test clock format and returns to using the real clock format.
/// format.
void
clearAlwaysUse24HourTestValue
()
{
void
clearAlwaysUse24HourTestValue
()
{
_alwaysUse24HourFormatTestValue
=
null
;
_alwaysUse24HourFormatTestValue
=
null
;
}
}
...
@@ -288,13 +260,11 @@ class TestWindow implements Window {
...
@@ -288,13 +260,11 @@ class TestWindow implements Window {
@override
@override
String
get
defaultRouteName
=>
_defaultRouteNameTestValue
??
_window
.
defaultRouteName
;
String
get
defaultRouteName
=>
_defaultRouteNameTestValue
??
_window
.
defaultRouteName
;
String
_defaultRouteNameTestValue
;
String
_defaultRouteNameTestValue
;
/// Hides the real default route name and reports the given
/// Hides the real default route name and reports the given [defaultRouteNameTestValue] instead.
/// [defaultRouteNameTestValue] instead.
set
defaultRouteNameTestValue
(
String
defaultRouteNameTestValue
)
{
set
defaultRouteNameTestValue
(
String
defaultRouteNameTestValue
)
{
_defaultRouteNameTestValue
=
defaultRouteNameTestValue
;
_defaultRouteNameTestValue
=
defaultRouteNameTestValue
;
}
}
/// Deletes any existing test default route name and returns to using the real
/// Deletes any existing test default route name and returns to using the real default route name.
/// default route name.
void
clearDefaultRouteNameTestValue
()
{
void
clearDefaultRouteNameTestValue
()
{
_defaultRouteNameTestValue
=
null
;
_defaultRouteNameTestValue
=
null
;
}
}
...
@@ -312,14 +282,12 @@ class TestWindow implements Window {
...
@@ -312,14 +282,12 @@ class TestWindow implements Window {
@override
@override
bool
get
semanticsEnabled
=>
_semanticsEnabledTestValue
??
_window
.
semanticsEnabled
;
bool
get
semanticsEnabled
=>
_semanticsEnabledTestValue
??
_window
.
semanticsEnabled
;
bool
_semanticsEnabledTestValue
;
bool
_semanticsEnabledTestValue
;
/// Hides the real semantics enabled and reports the given
/// Hides the real semantics enabled and reports the given [semanticsEnabledTestValue] instead.
/// [semanticsEnabledTestValue] instead.
set
semanticsEnabledTestValue
(
bool
semanticsEnabledTestValue
)
{
set
semanticsEnabledTestValue
(
bool
semanticsEnabledTestValue
)
{
_semanticsEnabledTestValue
=
semanticsEnabledTestValue
;
_semanticsEnabledTestValue
=
semanticsEnabledTestValue
;
onSemanticsEnabledChanged
();
onSemanticsEnabledChanged
();
}
}
/// Deletes any existing test semantics enabled and returns to using the real
/// Deletes any existing test semantics enabled and returns to using the real semantics enabled.
/// semantics enabled.
void
clearSemanticsEnabledTestValue
()
{
void
clearSemanticsEnabledTestValue
()
{
_semanticsEnabledTestValue
=
null
;
_semanticsEnabledTestValue
=
null
;
onSemanticsEnabledChanged
();
onSemanticsEnabledChanged
();
...
@@ -342,14 +310,12 @@ class TestWindow implements Window {
...
@@ -342,14 +310,12 @@ class TestWindow implements Window {
@override
@override
AccessibilityFeatures
get
accessibilityFeatures
=>
_accessibilityFeaturesTestValue
??
_window
.
accessibilityFeatures
;
AccessibilityFeatures
get
accessibilityFeatures
=>
_accessibilityFeaturesTestValue
??
_window
.
accessibilityFeatures
;
AccessibilityFeatures
_accessibilityFeaturesTestValue
;
AccessibilityFeatures
_accessibilityFeaturesTestValue
;
/// Hides the real accessibility features and reports the given
/// Hides the real accessibility features and reports the given [accessibilityFeaturesTestValue] instead.
/// [accessibilityFeaturesTestValue] instead.
set
accessibilityFeaturesTestValue
(
AccessibilityFeatures
accessibilityFeaturesTestValue
)
{
set
accessibilityFeaturesTestValue
(
AccessibilityFeatures
accessibilityFeaturesTestValue
)
{
_accessibilityFeaturesTestValue
=
accessibilityFeaturesTestValue
;
_accessibilityFeaturesTestValue
=
accessibilityFeaturesTestValue
;
onAccessibilityFeaturesChanged
();
onAccessibilityFeaturesChanged
();
}
}
/// Deletes any existing test accessibility features and returns to using the
/// Deletes any existing test accessibility features and returns to using the real accessibility features.
/// real accessibility features.
void
clearAccessibilityFeaturesTestValue
()
{
void
clearAccessibilityFeaturesTestValue
()
{
_accessibilityFeaturesTestValue
=
null
;
_accessibilityFeaturesTestValue
=
null
;
onAccessibilityFeaturesChanged
();
onAccessibilityFeaturesChanged
();
...
@@ -389,11 +355,10 @@ class TestWindow implements Window {
...
@@ -389,11 +355,10 @@ class TestWindow implements Window {
}
}
/// Delete any test value properties that have been set on this [TestWindow]
/// Delete any test value properties that have been set on this [TestWindow]
/// and return to reporting the real [Window] values for all [Window]
/// and return to reporting the real [Window] values for all [Window] properties.
/// properties.
///
///
/// If desired, clearing of properties can be done on an individual basis,
/// If desired, clearing of properties can be done on an individual basis,
e.g.,
///
e.g.,
[clearLocaleTestValue()].
/// [clearLocaleTestValue()].
void
clearAllTestValues
()
{
void
clearAllTestValues
()
{
clearAccessibilityFeaturesTestValue
();
clearAccessibilityFeaturesTestValue
();
clearAlwaysUse24HourTestValue
();
clearAlwaysUse24HourTestValue
();
...
@@ -404,15 +369,14 @@ class TestWindow implements Window {
...
@@ -404,15 +369,14 @@ class TestWindow implements Window {
clearLocalesTestValue
();
clearLocalesTestValue
();
clearPaddingTestValue
();
clearPaddingTestValue
();
clearPhysicalSizeTestValue
();
clearPhysicalSizeTestValue
();
clearPhysicalDepthTestValue
();
clearSemanticsEnabledTestValue
();
clearSemanticsEnabledTestValue
();
clearTextScaleFactorTestValue
();
clearTextScaleFactorTestValue
();
clearViewInsetsTestValue
();
clearViewInsetsTestValue
();
}
}
/// This gives us some grace time when the dart:ui side adds something to
/// This gives us some grace time when the dart:ui side adds something to
/// Window, and makes things easier when we do rolls to give us time to
catch
/// Window, and makes things easier when we do rolls to give us time to
/// up.
///
catch
up.
@override
@override
dynamic
noSuchMethod
(
Invocation
invocation
)
{
dynamic
noSuchMethod
(
Invocation
invocation
)
{
return
null
;
return
null
;
...
...
packages/flutter_test/test/window_test.dart
View file @
f3dbefd3
...
@@ -43,20 +43,6 @@ void main() {
...
@@ -43,20 +43,6 @@ void main() {
);
);
});
});
testWidgets
(
'TestWindow can fake physical depth'
,
(
WidgetTester
tester
)
async
{
verifyThatTestWindowCanFakeProperty
<
double
>(
tester:
tester
,
realValue:
ui
.
window
.
physicalDepth
,
fakeValue:
120.0
,
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
physicalDepth
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
binding
.
window
.
physicalDepthTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake view insets'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TestWindow can fake view insets'
,
(
WidgetTester
tester
)
async
{
verifyThatTestWindowCanFakeProperty
<
WindowPadding
>(
verifyThatTestWindowCanFakeProperty
<
WindowPadding
>(
tester:
tester
,
tester:
tester
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment