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
852bfe2a
Unverified
Commit
852bfe2a
authored
Mar 04, 2022
by
Michael Goderbauer
Committed by
GitHub
Mar 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `BindingBase.platformDispatcher` over `BindingBase.window` where possible (#99443)
parent
020bf31c
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
725 additions
and
145 deletions
+725
-145
binding.dart
packages/flutter/lib/src/foundation/binding.dart
+2
-2
binding.dart
packages/flutter/lib/src/gestures/binding.dart
+1
-1
gesture_settings.dart
packages/flutter/lib/src/gestures/gesture_settings.dart
+1
-1
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+2
-2
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+8
-8
binding.dart
packages/flutter/lib/src/semantics/binding.dart
+2
-2
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+1
-1
binding.dart
packages/flutter/lib/src/services/binding.dart
+4
-4
app.dart
packages/flutter/lib/src/widgets/app.dart
+4
-4
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+4
-4
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+3
-3
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+9
-9
router.dart
packages/flutter/lib/src/widgets/router.dart
+1
-1
app_test.dart
packages/flutter/test/material/app_test.dart
+28
-28
bottom_sheet_theme_test.dart
packages/flutter/test/material/bottom_sheet_theme_test.dart
+1
-1
binding_test.dart
packages/flutter/test/painting/binding_test.dart
+0
-1
lifecycle_test.dart
packages/flutter/test/services/lifecycle_test.dart
+1
-1
binding_first_frame_developer_test.dart
...tter/test/widgets/binding_first_frame_developer_test.dart
+1
-1
binding_first_frame_rasterized_test.dart
...ter/test/widgets/binding_first_frame_rasterized_test.dart
+2
-2
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+2
-2
binding.dart
packages/flutter_test/lib/src/binding.dart
+6
-3
window.dart
packages/flutter_test/lib/src/window.dart
+452
-64
platform_dispatcher_test.dart
packages/flutter_test/test/platform_dispatcher_test.dart
+190
-0
No files found.
packages/flutter/lib/src/foundation/binding.dart
View file @
852bfe2a
...
@@ -509,12 +509,12 @@ abstract class BindingBase {
...
@@ -509,12 +509,12 @@ abstract class BindingBase {
}
}
_postExtensionStateChangedEvent
(
_postExtensionStateChangedEvent
(
brightnessOverrideExtensionName
,
brightnessOverrideExtensionName
,
(
debugBrightnessOverride
??
window
.
platformBrightness
).
toString
(),
(
debugBrightnessOverride
??
platformDispatcher
.
platformBrightness
).
toString
(),
);
);
await
reassembleApplication
();
await
reassembleApplication
();
}
}
return
<
String
,
dynamic
>{
return
<
String
,
dynamic
>{
'value'
:
(
debugBrightnessOverride
??
window
.
platformBrightness
).
toString
(),
'value'
:
(
debugBrightnessOverride
??
platformDispatcher
.
platformBrightness
).
toString
(),
};
};
},
},
);
);
...
...
packages/flutter/lib/src/gestures/binding.dart
View file @
852bfe2a
...
@@ -258,7 +258,7 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
...
@@ -258,7 +258,7 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
void
initInstances
()
{
void
initInstances
()
{
super
.
initInstances
();
super
.
initInstances
();
_instance
=
this
;
_instance
=
this
;
window
.
onPointerDataPacket
=
_handlePointerDataPacket
;
platformDispatcher
.
onPointerDataPacket
=
_handlePointerDataPacket
;
}
}
/// The singleton instance of this object.
/// The singleton instance of this object.
...
...
packages/flutter/lib/src/gestures/gesture_settings.dart
View file @
852bfe2a
...
@@ -22,7 +22,7 @@ class DeviceGestureSettings {
...
@@ -22,7 +22,7 @@ class DeviceGestureSettings {
});
});
/// Create a new [DeviceGestureSettings] from the provided [window].
/// Create a new [DeviceGestureSettings] from the provided [window].
factory
DeviceGestureSettings
.
fromWindow
(
ui
.
SingletonFlutterWindo
w
window
)
{
factory
DeviceGestureSettings
.
fromWindow
(
ui
.
FlutterVie
w
window
)
{
final
double
?
physicalTouchSlop
=
window
.
viewConfiguration
.
gestureSettings
.
physicalTouchSlop
;
final
double
?
physicalTouchSlop
=
window
.
viewConfiguration
.
gestureSettings
.
physicalTouchSlop
;
return
DeviceGestureSettings
(
return
DeviceGestureSettings
(
touchSlop:
physicalTouchSlop
==
null
?
null
:
physicalTouchSlop
/
window
.
devicePixelRatio
touchSlop:
physicalTouchSlop
==
null
?
null
:
physicalTouchSlop
/
window
.
devicePixelRatio
...
...
packages/flutter/lib/src/rendering/binding.dart
View file @
852bfe2a
...
@@ -32,7 +32,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
...
@@ -32,7 +32,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
onSemanticsOwnerCreated:
_handleSemanticsOwnerCreated
,
onSemanticsOwnerCreated:
_handleSemanticsOwnerCreated
,
onSemanticsOwnerDisposed:
_handleSemanticsOwnerDisposed
,
onSemanticsOwnerDisposed:
_handleSemanticsOwnerDisposed
,
);
);
window
platformDispatcher
..
onMetricsChanged
=
handleMetricsChanged
..
onMetricsChanged
=
handleMetricsChanged
..
onTextScaleFactorChanged
=
handleTextScaleFactorChanged
..
onTextScaleFactorChanged
=
handleTextScaleFactorChanged
..
onPlatformBrightnessChanged
=
handlePlatformBrightnessChanged
..
onPlatformBrightnessChanged
=
handlePlatformBrightnessChanged
...
@@ -327,7 +327,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
...
@@ -327,7 +327,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
}
}
void
_handleSemanticsEnabledChanged
()
{
void
_handleSemanticsEnabledChanged
()
{
setSemanticsEnabled
(
window
.
semanticsEnabled
);
setSemanticsEnabled
(
platformDispatcher
.
semanticsEnabled
);
}
}
/// Whether the render tree associated with this binding should produce a tree
/// Whether the render tree associated with this binding should produce a tree
...
...
packages/flutter/lib/src/scheduler/binding.dart
View file @
852bfe2a
...
@@ -271,10 +271,10 @@ mixin SchedulerBinding on BindingBase {
...
@@ -271,10 +271,10 @@ mixin SchedulerBinding on BindingBase {
void
addTimingsCallback
(
TimingsCallback
callback
)
{
void
addTimingsCallback
(
TimingsCallback
callback
)
{
_timingsCallbacks
.
add
(
callback
);
_timingsCallbacks
.
add
(
callback
);
if
(
_timingsCallbacks
.
length
==
1
)
{
if
(
_timingsCallbacks
.
length
==
1
)
{
assert
(
window
.
onReportTimings
==
null
);
assert
(
platformDispatcher
.
onReportTimings
==
null
);
window
.
onReportTimings
=
_executeTimingsCallbacks
;
platformDispatcher
.
onReportTimings
=
_executeTimingsCallbacks
;
}
}
assert
(
window
.
onReportTimings
==
_executeTimingsCallbacks
);
assert
(
platformDispatcher
.
onReportTimings
==
_executeTimingsCallbacks
);
}
}
/// Removes a callback that was earlier added by [addTimingsCallback].
/// Removes a callback that was earlier added by [addTimingsCallback].
...
@@ -282,7 +282,7 @@ mixin SchedulerBinding on BindingBase {
...
@@ -282,7 +282,7 @@ mixin SchedulerBinding on BindingBase {
assert
(
_timingsCallbacks
.
contains
(
callback
));
assert
(
_timingsCallbacks
.
contains
(
callback
));
_timingsCallbacks
.
remove
(
callback
);
_timingsCallbacks
.
remove
(
callback
);
if
(
_timingsCallbacks
.
isEmpty
)
{
if
(
_timingsCallbacks
.
isEmpty
)
{
window
.
onReportTimings
=
null
;
platformDispatcher
.
onReportTimings
=
null
;
}
}
}
}
...
@@ -727,8 +727,8 @@ mixin SchedulerBinding on BindingBase {
...
@@ -727,8 +727,8 @@ mixin SchedulerBinding on BindingBase {
/// [PlatformDispatcher.onDrawFrame] are registered.
/// [PlatformDispatcher.onDrawFrame] are registered.
@protected
@protected
void
ensureFrameCallbacksRegistered
()
{
void
ensureFrameCallbacksRegistered
()
{
window
.
onBeginFrame
??=
_handleBeginFrame
;
platformDispatcher
.
onBeginFrame
??=
_handleBeginFrame
;
window
.
onDrawFrame
??=
_handleDrawFrame
;
platformDispatcher
.
onDrawFrame
??=
_handleDrawFrame
;
}
}
/// Schedules a new frame using [scheduleFrame] if this object is not
/// Schedules a new frame using [scheduleFrame] if this object is not
...
@@ -793,7 +793,7 @@ mixin SchedulerBinding on BindingBase {
...
@@ -793,7 +793,7 @@ mixin SchedulerBinding on BindingBase {
return
true
;
return
true
;
}());
}());
ensureFrameCallbacksRegistered
();
ensureFrameCallbacksRegistered
();
window
.
scheduleFrame
();
platformDispatcher
.
scheduleFrame
();
_hasScheduledFrame
=
true
;
_hasScheduledFrame
=
true
;
}
}
...
@@ -825,7 +825,7 @@ mixin SchedulerBinding on BindingBase {
...
@@ -825,7 +825,7 @@ mixin SchedulerBinding on BindingBase {
debugPrintStack
(
label:
'scheduleForcedFrame() called. Current phase is
$schedulerPhase
.'
);
debugPrintStack
(
label:
'scheduleForcedFrame() called. Current phase is
$schedulerPhase
.'
);
return
true
;
return
true
;
}());
}());
window
.
scheduleFrame
();
platformDispatcher
.
scheduleFrame
();
_hasScheduledFrame
=
true
;
_hasScheduledFrame
=
true
;
}
}
...
...
packages/flutter/lib/src/semantics/binding.dart
View file @
852bfe2a
...
@@ -17,7 +17,7 @@ mixin SemanticsBinding on BindingBase {
...
@@ -17,7 +17,7 @@ mixin SemanticsBinding on BindingBase {
void
initInstances
()
{
void
initInstances
()
{
super
.
initInstances
();
super
.
initInstances
();
_instance
=
this
;
_instance
=
this
;
_accessibilityFeatures
=
window
.
accessibilityFeatures
;
_accessibilityFeatures
=
platformDispatcher
.
accessibilityFeatures
;
}
}
/// The current [SemanticsBinding], if one has been created.
/// The current [SemanticsBinding], if one has been created.
...
@@ -33,7 +33,7 @@ mixin SemanticsBinding on BindingBase {
...
@@ -33,7 +33,7 @@ mixin SemanticsBinding on BindingBase {
/// See [dart:ui.PlatformDispatcher.onAccessibilityFeaturesChanged].
/// See [dart:ui.PlatformDispatcher.onAccessibilityFeaturesChanged].
@protected
@protected
void
handleAccessibilityFeaturesChanged
()
{
void
handleAccessibilityFeaturesChanged
()
{
_accessibilityFeatures
=
window
.
accessibilityFeatures
;
_accessibilityFeatures
=
platformDispatcher
.
accessibilityFeatures
;
}
}
/// Creates an empty semantics update builder.
/// Creates an empty semantics update builder.
...
...
packages/flutter/lib/src/semantics/semantics.dart
View file @
852bfe2a
...
@@ -3046,7 +3046,7 @@ class SemanticsOwner extends ChangeNotifier {
...
@@ -3046,7 +3046,7 @@ class SemanticsOwner extends ChangeNotifier {
final
CustomSemanticsAction
action
=
CustomSemanticsAction
.
getAction
(
actionId
)!;
final
CustomSemanticsAction
action
=
CustomSemanticsAction
.
getAction
(
actionId
)!;
builder
.
updateCustomAction
(
id:
actionId
,
label:
action
.
label
,
hint:
action
.
hint
,
overrideId:
action
.
action
?.
index
??
-
1
);
builder
.
updateCustomAction
(
id:
actionId
,
label:
action
.
label
,
hint:
action
.
hint
,
overrideId:
action
.
action
?.
index
??
-
1
);
}
}
SemanticsBinding
.
instance
.
window
.
updateSemantics
(
builder
.
build
());
SemanticsBinding
.
instance
.
platformDispatcher
.
updateSemantics
(
builder
.
build
());
notifyListeners
();
notifyListeners
();
}
}
...
...
packages/flutter/lib/src/services/binding.dart
View file @
852bfe2a
...
@@ -61,7 +61,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -61,7 +61,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
void
_initKeyboard
()
{
void
_initKeyboard
()
{
_keyboard
=
HardwareKeyboard
();
_keyboard
=
HardwareKeyboard
();
_keyEventManager
=
KeyEventManager
(
_keyboard
,
RawKeyboard
.
instance
);
_keyEventManager
=
KeyEventManager
(
_keyboard
,
RawKeyboard
.
instance
);
window
.
onKeyData
=
_keyEventManager
.
handleKeyData
;
platformDispatcher
.
onKeyData
=
_keyEventManager
.
handleKeyData
;
SystemChannels
.
keyEvent
.
setMessageHandler
(
_keyEventManager
.
handleRawKeyMessage
);
SystemChannels
.
keyEvent
.
setMessageHandler
(
_keyEventManager
.
handleRawKeyMessage
);
}
}
...
@@ -225,11 +225,11 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -225,11 +225,11 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
// App life cycle
// App life cycle
/// Initializes the [lifecycleState] with the
/// Initializes the [lifecycleState] with the
/// [dart:ui.
SingletonFlutterWindow
.initialLifecycleState].
/// [dart:ui.
PlatformDispatcher
.initialLifecycleState].
///
///
/// Once the [lifecycleState] is populated through any means (including this
/// Once the [lifecycleState] is populated through any means (including this
/// method), this method will do nothing. This is because the
/// method), this method will do nothing. This is because the
/// [dart:ui.
SingletonFlutterWindow
.initialLifecycleState] may already be
/// [dart:ui.
PlatformDispatcher
.initialLifecycleState] may already be
/// stale and it no longer makes sense to use the initial state at dart vm
/// stale and it no longer makes sense to use the initial state at dart vm
/// startup as the current state anymore.
/// startup as the current state anymore.
///
///
...
@@ -240,7 +240,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -240,7 +240,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
if
(
lifecycleState
!=
null
)
{
if
(
lifecycleState
!=
null
)
{
return
;
return
;
}
}
final
AppLifecycleState
?
state
=
_parseAppLifecycleMessage
(
window
.
initialLifecycleState
);
final
AppLifecycleState
?
state
=
_parseAppLifecycleMessage
(
platformDispatcher
.
initialLifecycleState
);
if
(
state
!=
null
)
{
if
(
state
!=
null
)
{
handleAppLifecycleStateChanged
(
state
);
handleAppLifecycleStateChanged
(
state
);
}
}
...
...
packages/flutter/lib/src/widgets/app.dart
View file @
852bfe2a
...
@@ -1272,15 +1272,15 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
...
@@ -1272,15 +1272,15 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
// If window.defaultRouteName isn't '/', we should assume it was set
// If window.defaultRouteName isn't '/', we should assume it was set
// intentionally via `setInitialRoute`, and should override whatever is in
// intentionally via `setInitialRoute`, and should override whatever is in
// [widget.initialRoute].
// [widget.initialRoute].
String
get
_initialRouteName
=>
WidgetsBinding
.
instance
.
window
.
defaultRouteName
!=
Navigator
.
defaultRouteName
String
get
_initialRouteName
=>
WidgetsBinding
.
instance
.
platformDispatcher
.
defaultRouteName
!=
Navigator
.
defaultRouteName
?
WidgetsBinding
.
instance
.
window
.
defaultRouteName
?
WidgetsBinding
.
instance
.
platformDispatcher
.
defaultRouteName
:
widget
.
initialRoute
??
WidgetsBinding
.
instance
.
window
.
defaultRouteName
;
:
widget
.
initialRoute
??
WidgetsBinding
.
instance
.
platformDispatcher
.
defaultRouteName
;
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_updateRouting
();
_updateRouting
();
_locale
=
_resolveLocales
(
WidgetsBinding
.
instance
.
window
.
locales
,
widget
.
supportedLocales
);
_locale
=
_resolveLocales
(
WidgetsBinding
.
instance
.
platformDispatcher
.
locales
,
widget
.
supportedLocales
);
WidgetsBinding
.
instance
.
addObserver
(
this
);
WidgetsBinding
.
instance
.
addObserver
(
this
);
}
}
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
852bfe2a
...
@@ -287,8 +287,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
...
@@ -287,8 +287,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
// properly setup the [defaultBinaryMessenger] instance.
// properly setup the [defaultBinaryMessenger] instance.
_buildOwner
=
BuildOwner
();
_buildOwner
=
BuildOwner
();
buildOwner
!.
onBuildScheduled
=
_handleBuildScheduled
;
buildOwner
!.
onBuildScheduled
=
_handleBuildScheduled
;
window
.
onLocaleChanged
=
handleLocaleChanged
;
platformDispatcher
.
onLocaleChanged
=
handleLocaleChanged
;
window
.
onAccessibilityFeaturesChanged
=
handleAccessibilityFeaturesChanged
;
platformDispatcher
.
onAccessibilityFeaturesChanged
=
handleAccessibilityFeaturesChanged
;
SystemChannels
.
navigation
.
setMethodCallHandler
(
_handleNavigationInvocation
);
SystemChannels
.
navigation
.
setMethodCallHandler
(
_handleNavigationInvocation
);
assert
(()
{
assert
(()
{
FlutterErrorDetails
.
propertiesTransformers
.
add
(
debugTransformDebugCreator
);
FlutterErrorDetails
.
propertiesTransformers
.
add
(
debugTransformDebugCreator
);
...
@@ -590,7 +590,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
...
@@ -590,7 +590,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
@protected
@protected
@mustCallSuper
@mustCallSuper
void
handleLocaleChanged
()
{
void
handleLocaleChanged
()
{
dispatchLocalesChanged
(
window
.
locales
);
dispatchLocalesChanged
(
platformDispatcher
.
locales
);
}
}
/// Notify all the observers that the locale has changed (using
/// Notify all the observers that the locale has changed (using
...
@@ -1004,7 +1004,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
...
@@ -1004,7 +1004,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
/// method again with the matched locale of the first call omitted from
/// method again with the matched locale of the first call omitted from
/// `supportedLocales`.
/// `supportedLocales`.
Locale
?
computePlatformResolvedLocale
(
List
<
Locale
>
supportedLocales
)
{
Locale
?
computePlatformResolvedLocale
(
List
<
Locale
>
supportedLocales
)
{
return
window
.
computePlatformResolvedLocale
(
supportedLocales
);
return
platformDispatcher
.
computePlatformResolvedLocale
(
supportedLocales
);
}
}
}
}
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
852bfe2a
...
@@ -1943,7 +1943,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -1943,7 +1943,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
final
bool
revealObscuredInput
=
_hasInputConnection
final
bool
revealObscuredInput
=
_hasInputConnection
&&
widget
.
obscureText
&&
widget
.
obscureText
&&
WidgetsBinding
.
instance
.
window
.
brieflyShowPassword
&&
WidgetsBinding
.
instance
.
platformDispatcher
.
brieflyShowPassword
&&
value
.
text
.
length
==
_value
.
text
.
length
+
1
;
&&
value
.
text
.
length
==
_value
.
text
.
length
+
1
;
_obscureShowCharTicksPending
=
revealObscuredInput
?
_kObscureShowLatestCharCursorTicks
:
0
;
_obscureShowCharTicksPending
=
revealObscuredInput
?
_kObscureShowLatestCharCursorTicks
:
0
;
...
@@ -2658,7 +2658,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -2658,7 +2658,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if
(
_obscureShowCharTicksPending
>
0
)
{
if
(
_obscureShowCharTicksPending
>
0
)
{
setState
(()
{
setState
(()
{
_obscureShowCharTicksPending
=
WidgetsBinding
.
instance
.
window
.
brieflyShowPassword
_obscureShowCharTicksPending
=
WidgetsBinding
.
instance
.
platformDispatcher
.
brieflyShowPassword
?
_obscureShowCharTicksPending
-
1
?
_obscureShowCharTicksPending
-
1
:
0
;
:
0
;
});
});
...
@@ -3335,7 +3335,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -3335,7 +3335,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
const
Set
<
TargetPlatform
>
mobilePlatforms
=
<
TargetPlatform
>
{
const
Set
<
TargetPlatform
>
mobilePlatforms
=
<
TargetPlatform
>
{
TargetPlatform
.
android
,
TargetPlatform
.
iOS
,
TargetPlatform
.
fuchsia
,
TargetPlatform
.
android
,
TargetPlatform
.
iOS
,
TargetPlatform
.
fuchsia
,
};
};
final
bool
breiflyShowPassword
=
WidgetsBinding
.
instance
.
window
.
brieflyShowPassword
final
bool
breiflyShowPassword
=
WidgetsBinding
.
instance
.
platformDispatcher
.
brieflyShowPassword
&&
mobilePlatforms
.
contains
(
defaultTargetPlatform
);
&&
mobilePlatforms
.
contains
(
defaultTargetPlatform
);
if
(
breiflyShowPassword
)
{
if
(
breiflyShowPassword
)
{
final
int
?
o
=
_obscureShowCharTicksPending
>
0
?
_obscureLatestCharIndex
:
null
;
final
int
?
o
=
_obscureShowCharTicksPending
>
0
?
_obscureLatestCharIndex
:
null
;
...
...
packages/flutter/lib/src/widgets/media_query.dart
View file @
852bfe2a
...
@@ -134,21 +134,21 @@ class MediaQueryData {
...
@@ -134,21 +134,21 @@ class MediaQueryData {
/// window's metrics change. For example, see
/// window's metrics change. For example, see
/// [WidgetsBindingObserver.didChangeMetrics] or
/// [WidgetsBindingObserver.didChangeMetrics] or
/// [dart:ui.PlatformDispatcher.onMetricsChanged].
/// [dart:ui.PlatformDispatcher.onMetricsChanged].
MediaQueryData
.
fromWindow
(
ui
.
SingletonFlutterWindo
w
window
)
MediaQueryData
.
fromWindow
(
ui
.
FlutterVie
w
window
)
:
size
=
window
.
physicalSize
/
window
.
devicePixelRatio
,
:
size
=
window
.
physicalSize
/
window
.
devicePixelRatio
,
devicePixelRatio
=
window
.
devicePixelRatio
,
devicePixelRatio
=
window
.
devicePixelRatio
,
textScaleFactor
=
window
.
textScaleFactor
,
textScaleFactor
=
window
.
platformDispatcher
.
textScaleFactor
,
platformBrightness
=
window
.
platformBrightness
,
platformBrightness
=
window
.
platform
Dispatcher
.
platform
Brightness
,
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
),
systemGestureInsets
=
EdgeInsets
.
fromWindowPadding
(
window
.
systemGestureInsets
,
window
.
devicePixelRatio
),
systemGestureInsets
=
EdgeInsets
.
fromWindowPadding
(
window
.
systemGestureInsets
,
window
.
devicePixelRatio
),
accessibleNavigation
=
window
.
accessibilityFeatures
.
accessibleNavigation
,
accessibleNavigation
=
window
.
platformDispatcher
.
accessibilityFeatures
.
accessibleNavigation
,
invertColors
=
window
.
accessibilityFeatures
.
invertColors
,
invertColors
=
window
.
platformDispatcher
.
accessibilityFeatures
.
invertColors
,
disableAnimations
=
window
.
accessibilityFeatures
.
disableAnimations
,
disableAnimations
=
window
.
platformDispatcher
.
accessibilityFeatures
.
disableAnimations
,
boldText
=
window
.
accessibilityFeatures
.
boldText
,
boldText
=
window
.
platformDispatcher
.
accessibilityFeatures
.
boldText
,
highContrast
=
window
.
accessibilityFeatures
.
highContrast
,
highContrast
=
window
.
platformDispatcher
.
accessibilityFeatures
.
highContrast
,
alwaysUse24HourFormat
=
window
.
alwaysUse24HourFormat
,
alwaysUse24HourFormat
=
window
.
platformDispatcher
.
alwaysUse24HourFormat
,
navigationMode
=
NavigationMode
.
traditional
,
navigationMode
=
NavigationMode
.
traditional
,
gestureSettings
=
DeviceGestureSettings
.
fromWindow
(
window
),
gestureSettings
=
DeviceGestureSettings
.
fromWindow
(
window
),
displayFeatures
=
window
.
displayFeatures
;
displayFeatures
=
window
.
displayFeatures
;
...
...
packages/flutter/lib/src/widgets/router.dart
View file @
852bfe2a
...
@@ -1368,7 +1368,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid
...
@@ -1368,7 +1368,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid
RouteInformation
get
value
=>
_value
;
RouteInformation
get
value
=>
_value
;
RouteInformation
_value
;
RouteInformation
_value
;
RouteInformation
_valueInEngine
=
RouteInformation
(
location:
WidgetsBinding
.
instance
.
window
.
defaultRouteName
);
RouteInformation
_valueInEngine
=
RouteInformation
(
location:
WidgetsBinding
.
instance
.
platformDispatcher
.
defaultRouteName
);
void
_platformReportsNewRouteInformation
(
RouteInformation
routeInformation
)
{
void
_platformReportsNewRouteInformation
(
RouteInformation
routeInformation
)
{
if
(
_value
==
routeInformation
)
if
(
_value
==
routeInformation
)
...
...
packages/flutter/test/material/app_test.dart
View file @
852bfe2a
...
@@ -442,8 +442,8 @@ void main() {
...
@@ -442,8 +442,8 @@ void main() {
expect
(
dependentBuildCount
,
equals
(
2
));
expect
(
dependentBuildCount
,
equals
(
2
));
// didChangeTextScaleFactor
// didChangeTextScaleFactor
tester
.
binding
.
window
.
textScaleFactorTestValue
=
42
;
tester
.
binding
.
platformDispatcher
.
textScaleFactorTestValue
=
42
;
addTearDown
(
tester
.
binding
.
window
.
clearTextScaleFactorTestValue
);
addTearDown
(
tester
.
binding
.
platformDispatcher
.
clearTextScaleFactorTestValue
);
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -451,8 +451,8 @@ void main() {
...
@@ -451,8 +451,8 @@ void main() {
expect
(
dependentBuildCount
,
equals
(
3
));
expect
(
dependentBuildCount
,
equals
(
3
));
// didChangePlatformBrightness
// didChangePlatformBrightness
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
addTearDown
(
tester
.
binding
.
window
.
clearPlatformBrightnessTestValue
);
addTearDown
(
tester
.
binding
.
platformDispatcher
.
clearPlatformBrightnessTestValue
);
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -460,8 +460,8 @@ void main() {
...
@@ -460,8 +460,8 @@ void main() {
expect
(
dependentBuildCount
,
equals
(
4
));
expect
(
dependentBuildCount
,
equals
(
4
));
// didChangeAccessibilityFeatures
// didChangeAccessibilityFeatures
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
tester
.
binding
.
platformDispatcher
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
addTearDown
(
tester
.
binding
.
window
.
clearAccessibilityFeaturesTestValue
);
addTearDown
(
tester
.
binding
.
platformDispatcher
.
clearAccessibilityFeaturesTestValue
);
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -526,7 +526,7 @@ void main() {
...
@@ -526,7 +526,7 @@ void main() {
testWidgets
(
'MaterialApp uses regular theme when themeMode is light'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses regular theme when themeMode is light'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -549,7 +549,7 @@ void main() {
...
@@ -549,7 +549,7 @@ void main() {
expect
(
appliedTheme
.
brightness
,
Brightness
.
light
);
expect
(
appliedTheme
.
brightness
,
Brightness
.
light
);
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -572,7 +572,7 @@ void main() {
...
@@ -572,7 +572,7 @@ void main() {
testWidgets
(
'MaterialApp uses darkTheme when themeMode is dark'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses darkTheme when themeMode is dark'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -595,7 +595,7 @@ void main() {
...
@@ -595,7 +595,7 @@ void main() {
expect
(
appliedTheme
.
brightness
,
Brightness
.
dark
);
expect
(
appliedTheme
.
brightness
,
Brightness
.
dark
);
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
MaterialApp
(
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -619,7 +619,7 @@ void main() {
...
@@ -619,7 +619,7 @@ void main() {
testWidgets
(
'MaterialApp uses regular theme when themeMode is system and platformBrightness is light'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses regular theme when themeMode is system and platformBrightness is light'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -645,7 +645,7 @@ void main() {
...
@@ -645,7 +645,7 @@ void main() {
testWidgets
(
'MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -670,7 +670,7 @@ void main() {
...
@@ -670,7 +670,7 @@ void main() {
testWidgets
(
'MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -694,7 +694,7 @@ void main() {
...
@@ -694,7 +694,7 @@ void main() {
testWidgets
(
'MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -715,7 +715,7 @@ void main() {
...
@@ -715,7 +715,7 @@ void main() {
testWidgets
(
'MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -739,7 +739,7 @@ void main() {
...
@@ -739,7 +739,7 @@ void main() {
testWidgets
(
'MaterialApp uses dark theme when platformBrightness is dark'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses dark theme when platformBrightness is dark'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a dark platformBrightness.
// Mock the Window to explicitly report a dark platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -764,8 +764,8 @@ void main() {
...
@@ -764,8 +764,8 @@ void main() {
});
});
testWidgets
(
'MaterialApp uses high contrast theme when appropriate'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses high contrast theme when appropriate'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
tester
.
binding
.
platformDispatcher
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -787,12 +787,12 @@ void main() {
...
@@ -787,12 +787,12 @@ void main() {
);
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
blue
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
blue
);
tester
.
binding
.
window
.
clearAccessibilityFeaturesTestValue
();
tester
.
binding
.
platformDispatcher
.
clearAccessibilityFeaturesTestValue
();
});
});
testWidgets
(
'MaterialApp uses high contrast dark theme when appropriate'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses high contrast dark theme when appropriate'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
tester
.
binding
.
platformDispatcher
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -820,12 +820,12 @@ void main() {
...
@@ -820,12 +820,12 @@ void main() {
);
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
green
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
green
);
tester
.
binding
.
window
.
clearAccessibilityFeaturesTestValue
();
tester
.
binding
.
platformDispatcher
.
clearAccessibilityFeaturesTestValue
();
});
});
testWidgets
(
'MaterialApp uses dark theme when no high contrast dark theme is provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp uses dark theme when no high contrast dark theme is provided'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
tester
.
binding
.
platformDispatcher
.
accessibilityFeaturesTestValue
=
FakeAccessibilityFeatures
.
allOn
;
late
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
...
@@ -847,14 +847,14 @@ void main() {
...
@@ -847,14 +847,14 @@ void main() {
);
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
lightGreen
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
lightGreen
);
tester
.
binding
.
window
.
clearAccessibilityFeaturesTestValue
();
tester
.
binding
.
platformDispatcher
.
clearAccessibilityFeaturesTestValue
();
tester
.
binding
.
window
.
clearPlatformBrightnessTestValue
();
tester
.
binding
.
platformDispatcher
.
clearPlatformBrightnessTestValue
();
});
});
testWidgets
(
'MaterialApp switches themes when the Window platformBrightness changes.'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'MaterialApp switches themes when the Window platformBrightness changes.'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a light platformBrightness.
// Mock the Window to explicitly report a light platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
?
themeBeforeBrightnessChange
;
ThemeData
?
themeBeforeBrightnessChange
;
ThemeData
?
themeAfterBrightnessChange
;
ThemeData
?
themeAfterBrightnessChange
;
...
@@ -882,7 +882,7 @@ void main() {
...
@@ -882,7 +882,7 @@ void main() {
// Switch the platformBrightness from light to dark and pump the widget tree
// Switch the platformBrightness from light to dark and pump the widget tree
// to process changes.
// to process changes.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
themeBeforeBrightnessChange
!.
brightness
,
Brightness
.
light
);
expect
(
themeBeforeBrightnessChange
!.
brightness
,
Brightness
.
light
);
...
...
packages/flutter/test/material/bottom_sheet_theme_test.dart
View file @
852bfe2a
...
@@ -272,7 +272,7 @@ void main() {
...
@@ -272,7 +272,7 @@ void main() {
expect
(
lightMaterial
.
color
,
lightBackgroundColor
);
expect
(
lightMaterial
.
color
,
lightBackgroundColor
);
// Simulate the user changing to dark theme
// Simulate the user changing to dark theme
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
final
Material
darkMaterial
=
tester
.
widget
<
Material
>(
final
Material
darkMaterial
=
tester
.
widget
<
Material
>(
...
...
packages/flutter/test/painting/binding_test.dart
View file @
852bfe2a
...
@@ -95,7 +95,6 @@ class TestBindingBase implements BindingBase {
...
@@ -95,7 +95,6 @@ class TestBindingBase implements BindingBase {
}
}
class
TestPaintingBinding
extends
TestBindingBase
with
SchedulerBinding
,
ServicesBinding
,
PaintingBinding
{
class
TestPaintingBinding
extends
TestBindingBase
with
SchedulerBinding
,
ServicesBinding
,
PaintingBinding
{
@override
@override
final
FakeImageCache
imageCache
=
FakeImageCache
();
final
FakeImageCache
imageCache
=
FakeImageCache
();
...
...
packages/flutter/test/services/lifecycle_test.dart
View file @
852bfe2a
...
@@ -13,7 +13,7 @@ void main() {
...
@@ -13,7 +13,7 @@ void main() {
// Mock the Window to provide paused as the AppLifecycleState
// Mock the Window to provide paused as the AppLifecycleState
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
// Use paused as the initial state.
// Use paused as the initial state.
binding
.
window
.
initialLifecycleStateTestValue
=
'AppLifecycleState.paused'
;
binding
.
platformDispatcher
.
initialLifecycleStateTestValue
=
'AppLifecycleState.paused'
;
binding
.
readTestInitialLifecycleStateFromNativeWindow
();
// Re-attempt the initialization.
binding
.
readTestInitialLifecycleStateFromNativeWindow
();
// Re-attempt the initialization.
// The lifecycleState should now be the state we passed above,
// The lifecycleState should now be the state we passed above,
...
...
packages/flutter/test/widgets/binding_first_frame_developer_test.dart
View file @
852bfe2a
...
@@ -22,7 +22,7 @@ void main() {
...
@@ -22,7 +22,7 @@ void main() {
binding
.
drawFrame
();
binding
.
drawFrame
();
// Simulates the engine again.
// Simulates the engine again.
binding
.
window
.
onReportTimings
!(<
FrameTiming
>[]);
binding
.
platformDispatcher
.
onReportTimings
!(<
FrameTiming
>[]);
expect
(
developer
.
getCurrentTag
().
label
,
equals
(
'Default'
));
expect
(
developer
.
getCurrentTag
().
label
,
equals
(
'Default'
));
});
});
...
...
packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart
View file @
852bfe2a
...
@@ -19,14 +19,14 @@ void main() {
...
@@ -19,14 +19,14 @@ void main() {
// Simulates the engine completing a frame render to trigger the
// Simulates the engine completing a frame render to trigger the
// appropriate callback setting [WidgetBinding.firstFrameRasterized].
// appropriate callback setting [WidgetBinding.firstFrameRasterized].
binding
.
window
.
onReportTimings
!(<
FrameTiming
>[]);
binding
.
platformDispatcher
.
onReportTimings
!(<
FrameTiming
>[]);
expect
(
binding
.
firstFrameRasterized
,
isFalse
);
expect
(
binding
.
firstFrameRasterized
,
isFalse
);
binding
.
allowFirstFrame
();
binding
.
allowFirstFrame
();
fakeAsync
.
flushTimers
();
fakeAsync
.
flushTimers
();
// Simulates the engine again.
// Simulates the engine again.
binding
.
window
.
onReportTimings
!(<
FrameTiming
>[]);
binding
.
platformDispatcher
.
onReportTimings
!(<
FrameTiming
>[]);
expect
(
binding
.
firstFrameRasterized
,
isTrue
);
expect
(
binding
.
firstFrameRasterized
,
isTrue
);
});
});
});
});
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
852bfe2a
...
@@ -3685,9 +3685,9 @@ void main() {
...
@@ -3685,9 +3685,9 @@ void main() {
await
tester
.
enterText
(
find
.
byType
(
EditableText
),
'AAA'
);
await
tester
.
enterText
(
find
.
byType
(
EditableText
),
'AAA'
);
await
tester
.
pump
();
await
tester
.
pump
();
tester
.
binding
.
window
.
brieflyShowPasswordTestValue
=
false
;
tester
.
binding
.
platformDispatcher
.
brieflyShowPasswordTestValue
=
false
;
addTearDown
(()
{
addTearDown
(()
{
tester
.
binding
.
window
.
brieflyShowPasswordTestValue
=
true
;
tester
.
binding
.
platformDispatcher
.
brieflyShowPasswordTestValue
=
true
;
});
});
expect
((
findRenderEditable
(
tester
).
text
!
as
TextSpan
).
text
,
'••A'
);
expect
((
findRenderEditable
(
tester
).
text
!
as
TextSpan
).
text
,
'••A'
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
...
...
packages/flutter_test/lib/src/binding.dart
View file @
852bfe2a
...
@@ -160,6 +160,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
...
@@ -160,6 +160,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
TestWindow
get
window
=>
_window
;
TestWindow
get
window
=>
_window
;
final
TestWindow
_window
;
final
TestWindow
_window
;
@override
TestPlatformDispatcher
get
platformDispatcher
=>
_window
.
platformDispatcher
;
@override
@override
TestRestorationManager
get
restorationManager
{
TestRestorationManager
get
restorationManager
{
_restorationManager
??=
createRestorationManager
();
_restorationManager
??=
createRestorationManager
();
...
@@ -1112,8 +1115,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
...
@@ -1112,8 +1115,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override
@override
void
ensureFrameCallbacksRegistered
()
{
void
ensureFrameCallbacksRegistered
()
{
// Leave PlatformDispatcher alone, do nothing.
// Leave PlatformDispatcher alone, do nothing.
assert
(
window
.
onDrawFrame
==
null
);
assert
(
platformDispatcher
.
onDrawFrame
==
null
);
assert
(
window
.
onBeginFrame
==
null
);
assert
(
platformDispatcher
.
onBeginFrame
==
null
);
}
}
@override
@override
...
@@ -1550,7 +1553,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
...
@@ -1550,7 +1553,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
_pendingFrame
=
null
;
_pendingFrame
=
null
;
_expectingFrame
=
false
;
_expectingFrame
=
false
;
}
else
if
(
framePolicy
!=
LiveTestWidgetsFlutterBindingFramePolicy
.
benchmark
)
{
}
else
if
(
framePolicy
!=
LiveTestWidgetsFlutterBindingFramePolicy
.
benchmark
)
{
window
.
scheduleFrame
();
platformDispatcher
.
scheduleFrame
();
}
}
}
}
...
...
packages/flutter_test/lib/src/window.dart
View file @
852bfe2a
This diff is collapsed.
Click to expand it.
packages/flutter_test/test/platform_dispatcher_test.dart
0 → 100644
View file @
852bfe2a
// Copyright 2014 The Flutter 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
'dart:ui'
show
Locale
,
AccessibilityFeatures
,
Brightness
,
PlatformDispatcher
;
import
'package:flutter/widgets.dart'
show
WidgetsBinding
,
WidgetsBindingObserver
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'TestWindow can handle new methods without breaking'
,
()
{
final
dynamic
testPlatformDispatcher
=
TestPlatformDispatcher
(
platformDispatcher:
PlatformDispatcher
.
instance
);
// ignore: avoid_dynamic_calls
expect
(
testPlatformDispatcher
.
someNewProperty
,
null
);
});
testWidgets
(
'TestWindow can fake locale'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
Locale
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
locale
,
fakeValue:
const
Locale
(
'fake_language_code'
),
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
locale
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Locale
fakeValue
)
{
binding
.
platformDispatcher
.
localeTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake locales'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
List
<
Locale
>>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
locales
,
fakeValue:
<
Locale
>[
const
Locale
(
'fake_language_code'
)],
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
locales
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
List
<
Locale
>
fakeValue
)
{
binding
.
platformDispatcher
.
localesTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake text scale factor'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
double
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
textScaleFactor
,
fakeValue:
2.5
,
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
textScaleFactor
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
binding
.
platformDispatcher
.
textScaleFactorTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake clock format'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
bool
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
alwaysUse24HourFormat
,
fakeValue:
!
PlatformDispatcher
.
instance
.
alwaysUse24HourFormat
,
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
alwaysUse24HourFormat
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
bool
fakeValue
)
{
binding
.
platformDispatcher
.
alwaysUse24HourFormatTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake brieflyShowPassword'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
bool
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
brieflyShowPassword
,
fakeValue:
!
PlatformDispatcher
.
instance
.
brieflyShowPassword
,
propertyRetriever:
()
=>
WidgetsBinding
.
instance
.
platformDispatcher
.
brieflyShowPassword
,
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
bool
fakeValue
)
{
binding
.
platformDispatcher
.
brieflyShowPasswordTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake default route name'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
String
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
defaultRouteName
,
fakeValue:
'fake_route'
,
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
defaultRouteName
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
String
fakeValue
)
{
binding
.
platformDispatcher
.
defaultRouteNameTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake accessibility features'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
AccessibilityFeatures
>(
tester:
tester
,
realValue:
PlatformDispatcher
.
instance
.
accessibilityFeatures
,
fakeValue:
const
FakeAccessibilityFeatures
(),
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
accessibilityFeatures
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
AccessibilityFeatures
fakeValue
)
{
binding
.
platformDispatcher
.
accessibilityFeaturesTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can fake platform brightness'
,
(
WidgetTester
tester
)
async
{
verifyThatTestPlatformDispatcherCanFakeProperty
<
Brightness
>(
tester:
tester
,
realValue:
Brightness
.
light
,
fakeValue:
Brightness
.
dark
,
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
platformDispatcher
.
platformBrightness
;
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Brightness
fakeValue
)
{
binding
.
platformDispatcher
.
platformBrightnessTestValue
=
fakeValue
;
},
);
});
testWidgets
(
'TestWindow can clear out fake properties all at once'
,
(
WidgetTester
tester
)
async
{
final
Locale
originalLocale
=
PlatformDispatcher
.
instance
.
locale
;
final
double
originalTextScaleFactor
=
PlatformDispatcher
.
instance
.
textScaleFactor
;
final
TestPlatformDispatcher
testPlatformDispatcher
=
retrieveTestBinding
(
tester
).
platformDispatcher
;
// Set fake values for window properties.
testPlatformDispatcher
.
localeTestValue
=
const
Locale
(
'foobar'
);
testPlatformDispatcher
.
textScaleFactorTestValue
=
3.0
;
// Erase fake window property values.
testPlatformDispatcher
.
clearAllTestValues
();
// Verify that the window once again reports real property values.
expect
(
WidgetsBinding
.
instance
.
platformDispatcher
.
locale
,
originalLocale
);
expect
(
WidgetsBinding
.
instance
.
platformDispatcher
.
textScaleFactor
,
originalTextScaleFactor
);
});
testWidgets
(
'TestWindow sends fake locales when WidgetsBindingObserver notifiers are called'
,
(
WidgetTester
tester
)
async
{
final
List
<
Locale
>
defaultLocales
=
WidgetsBinding
.
instance
.
platformDispatcher
.
locales
;
final
TestObserver
observer
=
TestObserver
();
retrieveTestBinding
(
tester
).
addObserver
(
observer
);
final
List
<
Locale
>
expectedValue
=
<
Locale
>[
const
Locale
(
'fake_language_code'
)];
retrieveTestBinding
(
tester
).
platformDispatcher
.
localesTestValue
=
expectedValue
;
expect
(
observer
.
locales
,
equals
(
expectedValue
));
retrieveTestBinding
(
tester
).
platformDispatcher
.
localesTestValue
=
defaultLocales
;
});
}
void
verifyThatTestPlatformDispatcherCanFakeProperty
<
PlatformDispatcherPropertyType
>({
required
WidgetTester
tester
,
required
PlatformDispatcherPropertyType
?
realValue
,
required
PlatformDispatcherPropertyType
fakeValue
,
required
PlatformDispatcherPropertyType
?
Function
()
propertyRetriever
,
required
Function
(
TestWidgetsFlutterBinding
,
PlatformDispatcherPropertyType
fakeValue
)
propertyFaker
,
})
{
PlatformDispatcherPropertyType
?
propertyBeforeFaking
;
PlatformDispatcherPropertyType
?
propertyAfterFaking
;
propertyBeforeFaking
=
propertyRetriever
();
propertyFaker
(
retrieveTestBinding
(
tester
),
fakeValue
);
propertyAfterFaking
=
propertyRetriever
();
expect
(
propertyBeforeFaking
,
realValue
);
expect
(
propertyAfterFaking
,
fakeValue
);
}
TestWidgetsFlutterBinding
retrieveTestBinding
(
WidgetTester
tester
)
{
final
WidgetsBinding
binding
=
tester
.
binding
;
assert
(
binding
is
TestWidgetsFlutterBinding
);
final
TestWidgetsFlutterBinding
testBinding
=
binding
as
TestWidgetsFlutterBinding
;
return
testBinding
;
}
class
TestObserver
with
WidgetsBindingObserver
{
List
<
Locale
>?
locales
;
Locale
?
locale
;
@override
void
didChangeLocales
(
List
<
Locale
>?
locales
)
{
this
.
locales
=
locales
;
}
}
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