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
7f2c1cd7
Unverified
Commit
7f2c1cd7
authored
Mar 03, 2022
by
Michael Goderbauer
Committed by
GitHub
Mar 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `PlatformDispatcher.instance` over `window` where possible (#99496)
parent
a4aeb778
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
175 additions
and
197 deletions
+175
-197
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+5
-5
icon_color_test.dart
dev/benchmarks/test_apps/stocks/test/icon_color_test.dart
+2
-4
main.dart
...ion_tests/ios_add2app_life_cycle/flutterapp/lib/main.dart
+3
-5
route.dart
dev/integration_tests/ui/lib/route.dart
+1
-1
canvas.dart
examples/layers/raw/canvas.dart
+3
-2
hello_world.dart
examples/layers/raw/hello_world.dart
+2
-2
spinning_square.dart
examples/layers/raw/spinning_square.dart
+4
-3
text.dart
examples/layers/raw/text.dart
+3
-2
touch_input.dart
examples/layers/raw/touch_input.dart
+4
-4
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+1
-2
time_picker.dart
packages/flutter/lib/src/material/time_picker.dart
+1
-2
animation_controller_test.dart
...ges/flutter/test/animation/animation_controller_test.dart
+4
-5
animations_test.dart
packages/flutter/test/animation/animations_test.dart
+4
-5
service_extensions_test.dart
...ages/flutter/test/foundation/service_extensions_test.dart
+3
-3
gesture_binding_resample_event_on_widget_test.dart
...stures/gesture_binding_resample_event_on_widget_test.dart
+7
-7
gesture_binding_resample_event_test.dart
...er/test/gestures/gesture_binding_resample_event_test.dart
+4
-4
gesture_binding_test.dart
packages/flutter/test/gestures/gesture_binding_test.dart
+17
-17
locking_test.dart
packages/flutter/test/gestures/locking_test.dart
+1
-1
chip_test.dart
packages/flutter/test/material/chip_test.dart
+1
-3
dropdown_form_field_test.dart
packages/flutter/test/material/dropdown_form_field_test.dart
+1
-2
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+1
-2
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+2
-2
range_slider_test.dart
packages/flutter/test/material/range_slider_test.dart
+1
-1
slider_theme_test.dart
packages/flutter/test/material/slider_theme_test.dart
+2
-4
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+2
-2
independent_layout_test.dart
packages/flutter/test/rendering/independent_layout_test.dart
+2
-4
layers_test.dart
packages/flutter/test/rendering/layers_test.dart
+2
-2
mouse_tracker_cursor_test.dart
...ges/flutter/test/rendering/mouse_tracker_cursor_test.dart
+30
-30
mouse_tracker_test.dart
packages/flutter/test/rendering/mouse_tracker_test.dart
+32
-32
platform_view_test.dart
packages/flutter/test/rendering/platform_view_test.dart
+7
-7
view_test.dart
packages/flutter/test/rendering/view_test.dart
+1
-1
scheduler_test.dart
packages/flutter/test/scheduler/scheduler_test.dart
+4
-5
annotated_region_test.dart
packages/flutter/test/widgets/annotated_region_test.dart
+4
-6
binding_frame_scheduling_test.dart
...s/flutter/test/widgets/binding_frame_scheduling_test.dart
+9
-9
reparent_state_with_layout_builder_test.dart
...test/widgets/reparent_state_with_layout_builder_test.dart
+1
-3
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+1
-3
widgets_test.dart
packages/flutter_localizations/test/widgets_test.dart
+2
-4
_callback_io.dart
packages/integration_test/lib/_callback_io.dart
+1
-1
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
7f2c1cd7
...
...
@@ -262,7 +262,7 @@ abstract class SceneBuilderRecorder extends Recorder {
final
Completer
<
Profile
>
profileCompleter
=
Completer
<
Profile
>();
_profile
=
Profile
(
name:
name
);
window
.
onBeginFrame
=
(
_
)
{
PlatformDispatcher
.
instance
.
onBeginFrame
=
(
_
)
{
try
{
startMeasureFrame
(
profile
!);
onBeginFrame
();
...
...
@@ -271,7 +271,7 @@ abstract class SceneBuilderRecorder extends Recorder {
rethrow
;
}
};
window
.
onDrawFrame
=
()
{
PlatformDispatcher
.
instance
.
onDrawFrame
=
()
{
try
{
_profile
!.
record
(
'drawFrameDuration'
,
()
{
final
SceneBuilder
sceneBuilder
=
SceneBuilder
();
...
...
@@ -286,7 +286,7 @@ abstract class SceneBuilderRecorder extends Recorder {
endMeasureFrame
();
if
(
shouldContinue
())
{
window
.
scheduleFrame
();
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
else
{
profileCompleter
.
complete
(
_profile
);
}
...
...
@@ -295,7 +295,7 @@ abstract class SceneBuilderRecorder extends Recorder {
rethrow
;
}
};
window
.
scheduleFrame
();
PlatformDispatcher
.
instance
.
scheduleFrame
();
return
profileCompleter
.
future
;
}
}
...
...
@@ -403,7 +403,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
profile
!.
addDataPoint
(
'drawFrameDuration'
,
_drawFrameStopwatch
.
elapsed
,
reported:
true
);
if
(
shouldContinue
())
{
window
.
scheduleFrame
();
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
else
{
for
(
final
VoidCallback
fn
in
_didStopCallbacks
)
fn
();
...
...
dev/benchmarks/test_apps/stocks/test/icon_color_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
window
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:stocks/main.dart'
as
stocks
;
...
...
@@ -61,8 +59,8 @@ void main() {
expect
(
find
.
text
(
'Account Balance'
),
findsNothing
);
// drag the drawer out
final
Offset
left
=
Offset
(
0.0
,
(
ui
.
window
.
physicalSize
/
ui
.
window
.
devicePixelRatio
).
height
/
2.0
);
final
Offset
right
=
Offset
((
ui
.
window
.
physicalSize
/
ui
.
window
.
devicePixelRatio
).
width
,
left
.
dy
);
final
Offset
left
=
Offset
(
0.0
,
(
WidgetsBinding
.
instance
.
window
.
physicalSize
/
WidgetsBinding
.
instance
.
window
.
devicePixelRatio
).
height
/
2.0
);
final
Offset
right
=
Offset
((
WidgetsBinding
.
instance
.
window
.
physicalSize
/
WidgetsBinding
.
instance
.
window
.
devicePixelRatio
).
width
,
left
.
dy
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
left
);
await
tester
.
pump
();
await
gesture
.
moveTo
(
right
);
...
...
dev/integration_tests/ios_add2app_life_cycle/flutterapp/lib/main.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:collection/collection.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -14,8 +12,8 @@ VoidCallback? originalSemanticsListener;
void
main
(
)
{
WidgetsFlutterBinding
.
ensureInitialized
();
// Disconnects semantics listener for testing purposes.
originalSemanticsListener
=
ui
.
window
.
onSemanticsEnabledChanged
;
ui
.
window
.
onSemanticsEnabledChanged
=
null
;
originalSemanticsListener
=
WidgetsBinding
.
instance
.
platformDispatcher
.
onSemanticsEnabledChanged
;
RendererBinding
.
instance
.
platformDispatcher
.
onSemanticsEnabledChanged
=
null
;
RendererBinding
.
instance
.
setSemanticsEnabled
(
false
);
// If the test passes, LifeCycleSpy will rewire the semantics listener back.
runApp
(
const
LifeCycleSpy
());
...
...
@@ -71,7 +69,7 @@ class _LifeCycleSpyState extends State<LifeCycleSpy> with WidgetsBindingObserver
if
(
const
ListEquality
<
AppLifecycleState
?>().
equals
(
_actualLifeCycleSequence
,
_expectedLifeCycleSequence
))
{
// Rewires the semantics harness if test passes.
RendererBinding
.
instance
.
setSemanticsEnabled
(
true
);
ui
.
window
.
onSemanticsEnabledChanged
=
originalSemanticsListener
;
RendererBinding
.
instance
.
platformDispatcher
.
onSemanticsEnabledChanged
=
originalSemanticsListener
;
}
return
const
MaterialApp
(
title:
'Flutter View'
,
...
...
dev/integration_tests/ui/lib/route.dart
View file @
7f2c1cd7
...
...
@@ -10,6 +10,6 @@ import 'package:flutter_driver/driver_extension.dart';
void
main
(
)
{
enableFlutterDriverExtension
(
handler:
(
String
?
message
)
async
{
return
ui
.
window
.
defaultRouteName
;
return
ui
.
PlatformDispatcher
.
instance
.
defaultRouteName
;
});
}
examples/layers/raw/canvas.dart
View file @
7f2c1cd7
...
...
@@ -122,6 +122,7 @@ void beginFrame(Duration timeStamp) {
}
void
main
(
)
{
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
..
onBeginFrame
=
beginFrame
..
scheduleFrame
();
}
examples/layers/raw/hello_world.dart
View file @
7f2c1cd7
...
...
@@ -42,9 +42,9 @@ void beginFrame(Duration timeStamp) {
// calls main() as soon as it has loaded your code.
void
main
(
)
{
// The engine calls onBeginFrame whenever it wants us to produce a frame.
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
PlatformDispatcher
.
instance
.
onBeginFrame
=
beginFrame
;
// Here we kick off the whole process by asking the engine to schedule a new
// frame. The engine will eventually call onBeginFrame when it is time for us
// to actually produce the frame.
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
examples/layers/raw/spinning_square.dart
View file @
7f2c1cd7
...
...
@@ -52,10 +52,11 @@ void beginFrame(Duration timeStamp) {
// After rendering the current frame of the animation, we ask the engine to
// schedule another frame. The engine will call beginFrame again when its time
// to produce the next frame.
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
void
main
(
)
{
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
..
onBeginFrame
=
beginFrame
..
scheduleFrame
();
}
examples/layers/raw/text.dart
View file @
7f2c1cd7
...
...
@@ -89,6 +89,7 @@ void main() {
..
layout
(
const
ui
.
ParagraphConstraints
(
width:
180.0
));
// Finally, we register our beginFrame callback and kick off the first frame.
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
..
onBeginFrame
=
beginFrame
..
scheduleFrame
();
}
examples/layers/raw/touch_input.dart
View file @
7f2c1cd7
...
...
@@ -94,7 +94,7 @@ void handlePointerDataPacket(ui.PointerDataPacket packet) {
// point where the engine calls onBeginFrame, which signals the boundary
// between one frame and another.
color
=
const
ui
.
Color
(
0xFF00FF00
);
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
}
}
...
...
@@ -104,12 +104,12 @@ void handlePointerDataPacket(ui.PointerDataPacket packet) {
void
main
(
)
{
color
=
const
ui
.
Color
(
0xFF00FF00
);
// The engine calls onBeginFrame whenever it wants us to produce a frame.
ui
.
window
.
onBeginFrame
=
beginFrame
;
ui
.
PlatformDispatcher
.
instance
.
onBeginFrame
=
beginFrame
;
// The engine calls onPointerDataPacket whenever it had updated information
// about the pointers directed at our app.
ui
.
window
.
onPointerDataPacket
=
handlePointerDataPacket
;
ui
.
PlatformDispatcher
.
instance
.
onPointerDataPacket
=
handlePointerDataPacket
;
// Here we kick off the whole process by asking the engine to schedule a new
// frame. The engine will eventually call onBeginFrame when it is time for us
// to actually produce the frame.
ui
.
window
.
scheduleFrame
();
ui
.
PlatformDispatcher
.
instance
.
scheduleFrame
();
}
packages/flutter/lib/src/material/dropdown.dart
View file @
7f2c1cd7
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:ui'
show
window
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -1360,7 +1359,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
if
(
result
==
null
)
{
// If there's no MediaQuery, then use the window aspect to determine
// orientation.
final
Size
size
=
window
.
physicalSize
;
final
Size
size
=
WidgetsBinding
.
instance
.
window
.
physicalSize
;
result
=
size
.
width
>
size
.
height
?
Orientation
.
landscape
:
Orientation
.
portrait
;
}
return
result
;
...
...
packages/flutter/lib/src/material/time_picker.dart
View file @
7f2c1cd7
...
...
@@ -4,7 +4,6 @@
import
'dart:async'
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -1746,7 +1745,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
//
// TODO(rami-a): Once https://github.com/flutter/flutter/issues/67571 is
// resolved, remove the window check for semantics being enabled on web.
final
String
?
hintText
=
MediaQuery
.
of
(
context
).
accessibleNavigation
||
ui
.
window
.
semanticsEnabled
final
String
?
hintText
=
MediaQuery
.
of
(
context
).
accessibleNavigation
||
WidgetsBinding
.
instance
.
window
.
semanticsEnabled
?
widget
.
semanticHintText
:
(
focusNode
.
hasFocus
?
null
:
_formattedValue
);
inputDecoration
=
inputDecoration
.
copyWith
(
...
...
packages/flutter/test/animation/animation_controller_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/physics.dart'
;
import
'package:flutter/scheduler.dart'
;
...
...
@@ -16,9 +14,10 @@ import '../scheduler/scheduler_tester.dart';
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
ui
.
window
.
onBeginFrame
=
null
;
ui
.
window
.
onDrawFrame
=
null
;
WidgetsBinding
.
instance
..
resetEpoch
()
..
platformDispatcher
.
onBeginFrame
=
null
..
platformDispatcher
.
onDrawFrame
=
null
;
});
test
(
'Can set value during status callback'
,
()
{
...
...
packages/flutter/test/animation/animations_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -17,9 +15,10 @@ class BogusCurve extends Curve {
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
ui
.
window
.
onBeginFrame
=
null
;
ui
.
window
.
onDrawFrame
=
null
;
WidgetsBinding
.
instance
..
resetEpoch
()
..
platformDispatcher
.
onBeginFrame
=
null
..
platformDispatcher
.
onDrawFrame
=
null
;
});
test
(
'toString control test'
,
()
{
...
...
packages/flutter/test/foundation/service_extensions_test.dart
View file @
7f2c1cd7
...
...
@@ -80,10 +80,10 @@ class TestServiceExtensionsBinding extends BindingBase
}
Future
<
void
>
doFrame
()
async
{
frameScheduled
=
false
;
ui
.
window
.
onBeginFrame
?.
call
(
Duration
.
zero
);
binding
.
platformDispatcher
.
onBeginFrame
?.
call
(
Duration
.
zero
);
await
flushMicrotasks
();
ui
.
window
.
onDrawFrame
?.
call
();
ui
.
window
.
onReportTimings
?.
call
(<
ui
.
FrameTiming
>[]);
binding
.
platformDispatcher
.
onDrawFrame
?.
call
();
binding
.
platformDispatcher
.
onReportTimings
?.
call
(<
ui
.
FrameTiming
>[]);
}
@override
...
...
packages/flutter/test/gestures/gesture_binding_resample_event_on_widget_test.dart
View file @
7f2c1cd7
...
...
@@ -93,7 +93,7 @@ void main() {
GestureBinding
.
instance
.
resamplingEnabled
=
true
;
const
Duration
kSamplingOffset
=
Duration
(
milliseconds:
-
5
);
GestureBinding
.
instance
.
samplingOffset
=
kSamplingOffset
;
ui
.
window
.
onPointerDataPacket
!(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
packet
);
expect
(
events
.
length
,
0
);
requestFrame
();
...
...
@@ -101,7 +101,7 @@ void main() {
expect
(
events
.
length
,
1
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
0
].
timeStamp
,
currentTestFrameTime
()
+
kSamplingOffset
);
expect
(
events
[
0
].
position
,
Offset
(
7.5
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
0
].
position
,
Offset
(
7.5
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
// Now the system time is epoch + 20ms
requestFrame
();
...
...
@@ -109,8 +109,8 @@ void main() {
expect
(
events
.
length
,
2
);
expect
(
events
[
1
].
timeStamp
,
currentTestFrameTime
()
+
kSamplingOffset
);
expect
(
events
[
1
],
isA
<
PointerMoveEvent
>());
expect
(
events
[
1
].
position
,
Offset
(
22.5
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
15.0
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
position
,
Offset
(
22.5
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
15.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
// Now the system time is epoch + 30ms
requestFrame
();
...
...
@@ -118,8 +118,8 @@ void main() {
expect
(
events
.
length
,
4
);
expect
(
events
[
2
].
timeStamp
,
currentTestFrameTime
()
+
kSamplingOffset
);
expect
(
events
[
2
],
isA
<
PointerMoveEvent
>());
expect
(
events
[
2
].
position
,
Offset
(
37.5
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
2
].
delta
,
Offset
(
15.0
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
2
].
position
,
Offset
(
37.5
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
2
].
delta
,
Offset
(
15.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
3
].
timeStamp
,
currentTestFrameTime
()
+
kSamplingOffset
);
expect
(
events
[
3
],
isA
<
PointerUpEvent
>());
});
...
...
@@ -134,7 +134,7 @@ void main() {
],
);
GestureBinding
.
instance
.
resamplingEnabled
=
true
;
ui
.
window
.
onPointerDataPacket
!(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
packet
);
// Expected to stop resampling, but the timer keeps active if _timer?.cancel() not be called.
GestureBinding
.
instance
.
resamplingEnabled
=
false
;
...
...
packages/flutter/test/gestures/gesture_binding_resample_event_test.dart
View file @
7f2c1cd7
...
...
@@ -122,7 +122,7 @@ void main() {
final
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
binding
.
callback
=
events
.
add
;
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
// No pointer events should have been dispatched yet.
expect
(
events
.
length
,
0
);
...
...
@@ -139,7 +139,7 @@ void main() {
expect
(
events
.
length
,
1
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
0
].
timeStamp
,
binding
.
frameTime
!
+
samplingOffset
);
expect
(
events
[
0
].
position
,
Offset
(
0.0
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
0
].
position
,
Offset
(
0.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
// Second frame callback should have been requested.
callback
=
binding
.
postFrameCallback
;
...
...
@@ -154,8 +154,8 @@ void main() {
expect
(
events
.
length
,
2
);
expect
(
events
[
1
],
isA
<
PointerMoveEvent
>());
expect
(
events
[
1
].
timeStamp
,
binding
.
frameTime
!
+
samplingOffset
);
expect
(
events
[
1
].
position
,
Offset
(
10.0
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
10.0
/
ui
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
position
,
Offset
(
10.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
10.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
// Verify that resampling continues without a frame callback.
async
.
elapse
(
frameInterval
*
1.5
);
...
...
packages/flutter/test/gestures/gesture_binding_test.dart
View file @
7f2c1cd7
...
...
@@ -59,7 +59,7 @@ void main() {
final
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
binding
.
callback
=
events
.
add
;
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
expect
(
events
.
length
,
2
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
1
],
isA
<
PointerUpEvent
>());
...
...
@@ -77,7 +77,7 @@ void main() {
final
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
binding
.
callback
=
events
.
add
;
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
expect
(
events
.
length
,
3
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
1
],
isA
<
PointerMoveEvent
>());
...
...
@@ -102,7 +102,7 @@ void main() {
final
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
binding
.
callback
=
events
.
add
;
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
expect
(
events
.
length
,
3
);
expect
(
events
[
0
],
isA
<
PointerHoverEvent
>());
expect
(
events
[
1
],
isA
<
PointerHoverEvent
>());
...
...
@@ -127,7 +127,7 @@ void main() {
final
List
<
PointerEvent
>
events
=
<
PointerEvent
>[];
binding
.
callback
=
events
.
add
;
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
expect
(
events
.
length
,
2
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
1
],
isA
<
PointerCancelEvent
>());
...
...
@@ -148,7 +148,7 @@ void main() {
binding
.
cancelPointer
(
event
.
pointer
);
};
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
expect
(
events
.
length
,
2
);
expect
(
events
[
0
],
isA
<
PointerDownEvent
>());
expect
(
events
[
1
],
isA
<
PointerCancelEvent
>());
...
...
@@ -165,7 +165,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -183,7 +183,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
2
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -191,7 +191,7 @@ void main() {
});
test
(
'Should synthesize kPrimaryButton for touch when no button is set'
,
()
{
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
ui
.
window
.
devicePixelRatio
;
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
GestureBinding
.
instance
.
window
.
devicePixelRatio
;
final
ui
.
PointerDataPacket
packet
=
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
ui
.
PointerData
(
change:
ui
.
PointerChange
.
add
,
physicalX:
location
.
dx
,
physicalY:
location
.
dy
),
...
...
@@ -202,7 +202,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -218,7 +218,7 @@ void main() {
});
test
(
'Should not synthesize kPrimaryButton for touch when a button is set'
,
()
{
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
ui
.
window
.
devicePixelRatio
;
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
GestureBinding
.
instance
.
window
.
devicePixelRatio
;
final
ui
.
PointerDataPacket
packet
=
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
ui
.
PointerData
(
change:
ui
.
PointerChange
.
add
,
physicalX:
location
.
dx
,
physicalY:
location
.
dy
),
...
...
@@ -229,7 +229,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -245,7 +245,7 @@ void main() {
});
test
(
'Should synthesize kPrimaryButton for stylus when no button is set'
,
()
{
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
ui
.
window
.
devicePixelRatio
;
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
GestureBinding
.
instance
.
window
.
devicePixelRatio
;
for
(
final
PointerDeviceKind
kind
in
<
PointerDeviceKind
>[
PointerDeviceKind
.
stylus
,
PointerDeviceKind
.
invertedStylus
,
...
...
@@ -261,7 +261,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -278,7 +278,7 @@ void main() {
});
test
(
'Should synthesize kPrimaryButton for unknown devices when no button is set'
,
()
{
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
ui
.
window
.
devicePixelRatio
;
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
GestureBinding
.
instance
.
window
.
devicePixelRatio
;
const
PointerDeviceKind
kind
=
PointerDeviceKind
.
unknown
;
final
ui
.
PointerDataPacket
packet
=
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
...
...
@@ -290,7 +290,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
@@ -306,7 +306,7 @@ void main() {
});
test
(
'Should not synthesize kPrimaryButton for mouse'
,
()
{
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
ui
.
window
.
devicePixelRatio
;
final
Offset
location
=
const
Offset
(
10.0
,
10.0
)
*
GestureBinding
.
instance
.
window
.
devicePixelRatio
;
for
(
final
PointerDeviceKind
kind
in
<
PointerDeviceKind
>[
PointerDeviceKind
.
mouse
,
])
{
...
...
@@ -320,7 +320,7 @@ void main() {
],
);
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
ui
.
window
.
devicePixelRatio
).
toList
();
final
List
<
PointerEvent
>
events
=
PointerEventConverter
.
expand
(
packet
.
data
,
GestureBinding
.
instance
.
window
.
devicePixelRatio
).
toList
();
expect
(
events
.
length
,
5
);
expect
(
events
[
0
],
isA
<
PointerAddedEvent
>());
...
...
packages/flutter/test/gestures/locking_test.dart
View file @
7f2c1cd7
...
...
@@ -30,7 +30,7 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding {
Future
<
void
>
test
(
VoidCallback
callback
)
{
assert
(
callback
!=
null
);
return
_binding
.
lockEvents
(()
async
{
ui
.
window
.
onPointerDataPacket
?.
call
(
packet
);
GestureBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
?.
call
(
packet
);
callback
();
});
}
...
...
packages/flutter/test/material/chip_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -84,7 +82,7 @@ Widget _wrapForChip({
home:
Directionality
(
textDirection:
textDirection
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
Material
(
child:
child
),
),
),
...
...
packages/flutter/test/material/dropdown_form_field_test.dart
View file @
7f2c1cd7
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:math'
as
math
;
import
'dart:ui'
show
window
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -91,7 +90,7 @@ class _TestAppState extends State<TestApp> {
DefaultMaterialLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
size:
widget
.
mediaSize
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
size:
widget
.
mediaSize
),
child:
Directionality
(
textDirection:
widget
.
textDirection
,
child:
Navigator
(
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
7f2c1cd7
...
...
@@ -13,7 +13,6 @@
@Tags
(<
String
>[
'reduced-test-set'
,
'no-shuffle'
])
import
'dart:math'
as
math
;
import
'dart:ui'
show
window
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -218,7 +217,7 @@ class _TestAppState extends State<TestApp> {
DefaultMaterialLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
size:
widget
.
mediaSize
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
size:
widget
.
mediaSize
),
child:
Directionality
(
textDirection:
widget
.
textDirection
,
child:
Navigator
(
...
...
packages/flutter/test/material/popup_menu_test.dart
View file @
7f2c1cd7
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
,
SemanticsFlag
;
import
'dart:ui'
show
SemanticsFlag
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -2595,7 +2595,7 @@ class _TestAppState extends State<TestApp> {
DefaultMaterialLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
child:
Directionality
(
textDirection:
widget
.
textDirection
,
child:
Navigator
(
...
...
packages/flutter/test/material/range_slider_test.dart
View file @
7f2c1cd7
...
...
@@ -1548,7 +1548,7 @@ void main() {
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
textScaleFactor:
2.0
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
textScaleFactor:
2.0
),
child:
Material
(
child:
Center
(
child:
Theme
(
...
...
packages/flutter/test/material/slider_theme_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -378,7 +376,7 @@ void main() {
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
textScaleFactor:
textScale
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
textScaleFactor:
textScale
),
child:
Material
(
child:
Row
(
children:
<
Widget
>[
...
...
@@ -555,7 +553,7 @@ void main() {
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
).
copyWith
(
textScaleFactor:
textScale
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
textScaleFactor:
textScale
),
child:
Material
(
child:
Row
(
children:
<
Widget
>[
...
...
packages/flutter/test/material/text_field_test.dart
View file @
7f2c1cd7
...
...
@@ -13,7 +13,7 @@
@Tags
(<
String
>[
'reduced-test-set'
,
'no-shuffle'
])
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
show
window
,
BoxHeightStyle
,
BoxWidthStyle
,
WindowPadding
;
import
'dart:ui'
as
ui
show
BoxHeightStyle
,
BoxWidthStyle
,
WindowPadding
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -6454,7 +6454,7 @@ void main() {
MaterialApp
(
home:
Scaffold
(
body:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
ui
.
window
).
copyWith
(
textScaleFactor:
4.0
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
).
copyWith
(
textScaleFactor:
4.0
),
child:
Center
(
child:
TextField
(
decoration:
const
InputDecoration
(
labelText:
'Label'
,
border:
UnderlineInputBorder
()),
...
...
packages/flutter/test/rendering/independent_layout_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
window
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -46,7 +44,7 @@ void main() {
expect
(
offscreen
.
child
.
hasSize
,
isFalse
);
expect
(
offscreen
.
painted
,
isFalse
);
// Attach the offscreen to a custom render view and owner
final
RenderView
renderView
=
RenderView
(
configuration:
testConfiguration
,
window:
ui
.
window
);
final
RenderView
renderView
=
RenderView
(
configuration:
testConfiguration
,
window:
RendererBinding
.
instance
.
window
);
final
PipelineOwner
pipelineOwner
=
PipelineOwner
();
renderView
.
attach
(
pipelineOwner
);
renderView
.
child
=
offscreen
.
root
;
...
...
@@ -76,7 +74,7 @@ void main() {
expect
(
offscreen
.
child
.
hasSize
,
isFalse
);
expect
(
offscreen
.
painted
,
isFalse
);
// Attach the offscreen to a custom render view and owner
final
RenderView
renderView
=
RenderView
(
configuration:
testConfiguration
,
window:
ui
.
window
);
final
RenderView
renderView
=
RenderView
(
configuration:
testConfiguration
,
window:
RendererBinding
.
instance
.
window
);
final
PipelineOwner
pipelineOwner
=
PipelineOwner
();
renderView
.
attach
(
pipelineOwner
);
renderView
.
child
=
offscreen
.
root
;
...
...
packages/flutter/test/rendering/layers_test.dart
View file @
7f2c1cd7
...
...
@@ -169,7 +169,7 @@ void main() {
test
(
'switching layer link of an attached leader layer should not crash'
,
()
{
final
LayerLink
link
=
LayerLink
();
final
LeaderLayer
leaderLayer
=
LeaderLayer
(
link:
link
);
final
RenderView
view
=
RenderView
(
configuration:
const
ViewConfiguration
(),
window:
window
);
final
RenderView
view
=
RenderView
(
configuration:
const
ViewConfiguration
(),
window:
RendererBinding
.
instance
.
window
);
leaderLayer
.
attach
(
view
);
final
LayerLink
link2
=
LayerLink
();
leaderLayer
.
link
=
link2
;
...
...
@@ -182,7 +182,7 @@ void main() {
final
LayerLink
link
=
LayerLink
();
final
LeaderLayer
leaderLayer1
=
LeaderLayer
(
link:
link
);
final
LeaderLayer
leaderLayer2
=
LeaderLayer
(
link:
link
);
final
RenderView
view
=
RenderView
(
configuration:
const
ViewConfiguration
(),
window:
window
);
final
RenderView
view
=
RenderView
(
configuration:
const
ViewConfiguration
(),
window:
RendererBinding
.
instance
.
window
);
leaderLayer1
.
attach
(
view
);
leaderLayer2
.
attach
(
view
);
leaderLayer2
.
detach
();
...
...
packages/flutter/test/rendering/mouse_tracker_cursor_test.dart
View file @
7f2c1cd7
This diff is collapsed.
Click to expand it.
packages/flutter/test/rendering/mouse_tracker_test.dart
View file @
7f2c1cd7
This diff is collapsed.
Click to expand it.
packages/flutter/test/rendering/platform_view_test.dart
View file @
7f2c1cd7
...
...
@@ -78,7 +78,7 @@ void main() {
layout
(
platformViewRenderBox
);
pumpFrame
(
phase:
EnginePhase
.
flushSemantics
);
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
RendererBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
),
_pointerData
(
ui
.
PointerChange
.
hover
,
const
Offset
(
10
,
10
)),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
)),
...
...
@@ -91,7 +91,7 @@ void main() {
layout
(
platformViewRenderBox
);
pumpFrame
(
phase:
EnginePhase
.
flushSemantics
);
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
RendererBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
),
_pointerData
(
ui
.
PointerChange
.
hover
,
const
Offset
(
10
,
10
)),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
)),
...
...
@@ -124,7 +124,7 @@ void main() {
FakeAsync
().
run
((
FakeAsync
async
)
{
// Put one pointer down.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
RendererBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
down
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
...
...
@@ -132,7 +132,7 @@ void main() {
async
.
flushMicrotasks
();
// Put another pointer down and then cancel it.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
RendererBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
down
,
const
Offset
(
20
,
10
),
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
cancel
,
const
Offset
(
20
,
10
),
pointer:
2
,
kind:
PointerDeviceKind
.
touch
),
...
...
@@ -140,7 +140,7 @@ void main() {
async
.
flushMicrotasks
();
// The first pointer can still moving without crashing.
ui
.
window
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
RendererBinding
.
instance
.
platformDispatcher
.
onPointerDataPacket
!(
ui
.
PointerDataPacket
(
data:
<
ui
.
PointerData
>[
_pointerData
(
ui
.
PointerChange
.
add
,
Offset
.
zero
,
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
move
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
_pointerData
(
ui
.
PointerChange
.
remove
,
const
Offset
(
10
,
10
),
pointer:
1
,
kind:
PointerDeviceKind
.
touch
),
...
...
@@ -202,8 +202,8 @@ ui.PointerData _pointerData(
pointerIdentifier:
pointer
,
embedderId:
pointer
,
change:
change
,
physicalX:
logicalPosition
.
dx
*
ui
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
ui
.
window
.
devicePixelRatio
,
physicalX:
logicalPosition
.
dx
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
kind:
kind
,
device:
device
,
);
...
...
packages/flutter/test/rendering/view_test.dart
View file @
7f2c1cd7
...
...
@@ -32,7 +32,7 @@ void main() {
});
test
(
'does not replace the root layer unnecessarily'
,
()
{
final
ui
.
FlutterView
window
=
TestWindow
(
window:
ui
.
window
);
final
ui
.
FlutterView
window
=
TestWindow
(
window:
RendererBinding
.
instance
.
window
);
final
RenderView
view
=
RenderView
(
configuration:
createViewConfiguration
(),
window:
window
,
...
...
packages/flutter/test/scheduler/scheduler_test.dart
View file @
7f2c1cd7
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:ui'
show
window
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/scheduler.dart'
;
...
...
@@ -141,7 +140,7 @@ void main() {
});
test
(
'Flutter.Frame event fired'
,
()
async
{
window
.
onReportTimings
!(<
FrameTiming
>[
FrameTiming
(
SchedulerBinding
.
instance
.
platformDispatcher
.
onReportTimings
!(<
FrameTiming
>[
FrameTiming
(
vsyncStart:
5000
,
buildStart:
10000
,
buildFinish:
15000
,
...
...
@@ -171,7 +170,7 @@ void main() {
SchedulerBinding
.
instance
.
addTimingsCallback
((
List
<
FrameTiming
>
timings
)
{
throw
Exception
(
'Test'
);
});
window
.
onReportTimings
!(<
FrameTiming
>[]);
SchedulerBinding
.
instance
.
platformDispatcher
.
onReportTimings
!(<
FrameTiming
>[]);
expect
(
errorCaught
!.
exceptionAsString
(),
equals
(
'Exception: Test'
));
});
...
...
@@ -233,9 +232,9 @@ void main() {
// Simulate an animation frame firing between warm-up begin frame and warm-up draw frame.
// Expect a timer that reschedules the frame.
expect
(
scheduler
.
hasScheduledFrame
,
isFalse
);
window
.
onBeginFrame
!(
Duration
.
zero
);
SchedulerBinding
.
instance
.
platformDispatcher
.
onBeginFrame
!(
Duration
.
zero
);
expect
(
scheduler
.
hasScheduledFrame
,
isFalse
);
window
.
onDrawFrame
!();
SchedulerBinding
.
instance
.
platformDispatcher
.
onDrawFrame
!();
expect
(
scheduler
.
hasScheduledFrame
,
isFalse
);
// The draw frame part of the warm-up frame will run the post-frame
...
...
packages/flutter/test/widgets/annotated_region_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -31,13 +29,13 @@ void main() {
),
);
int
?
result
=
RendererBinding
.
instance
.
renderView
.
debugLayer
!.
find
<
int
>(
Offset
(
10.0
*
window
.
devicePixelRatio
,
10.0
*
window
.
devicePixelRatio
,
10.0
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
10.0
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
));
expect
(
result
,
null
);
result
=
RendererBinding
.
instance
.
renderView
.
debugLayer
!.
find
<
int
>(
Offset
(
50.0
*
window
.
devicePixelRatio
,
50.0
*
window
.
devicePixelRatio
,
50.0
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
50.0
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
));
expect
(
result
,
1
);
});
...
...
packages/flutter/test/widgets/binding_frame_scheduling_test.dart
View file @
7f2c1cd7
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
;
import
'dart:ui'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -14,26 +14,26 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/39494.
// Preconditions.
expect
(
window
.
onBeginFrame
,
isNull
);
expect
(
window
.
onDrawFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onBeginFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onDrawFrame
,
isNull
);
// Instantiation does nothing with regards to frame scheduling.
expect
(
WidgetsFlutterBinding
.
ensureInitialized
(),
isA
<
WidgetsFlutterBinding
>());
expect
(
SchedulerBinding
.
instance
.
hasScheduledFrame
,
isFalse
);
expect
(
window
.
onBeginFrame
,
isNull
);
expect
(
window
.
onDrawFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onBeginFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onDrawFrame
,
isNull
);
// Framework starts with detached statue. Sends resumed signal to enable frame.
final
ByteData
message
=
const
StringCodec
().
encodeMessage
(
'AppLifecycleState.resumed'
)!;
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/lifecycle'
,
message
,
(
_
)
{
});
expect
(
window
.
onBeginFrame
,
isNull
);
expect
(
window
.
onDrawFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onBeginFrame
,
isNull
);
expect
(
PlatformDispatcher
.
instance
.
onDrawFrame
,
isNull
);
expect
(
SchedulerBinding
.
instance
.
hasScheduledFrame
,
isFalse
);
// Frame callbacks are registered lazily (and a frame scheduled) when the root widget is attached.
WidgetsBinding
.
instance
.
attachRootWidget
(
const
Placeholder
());
expect
(
window
.
onBeginFrame
,
isNotNull
);
expect
(
window
.
onDrawFrame
,
isNotNull
);
expect
(
PlatformDispatcher
.
instance
.
onBeginFrame
,
isNotNull
);
expect
(
PlatformDispatcher
.
instance
.
onDrawFrame
,
isNotNull
);
expect
(
SchedulerBinding
.
instance
.
hasScheduledFrame
,
isTrue
);
});
}
packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
show
window
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -98,7 +96,7 @@ void main() {
Widget
deepChild
=
Container
();
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
ui
.
window
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
child:
Column
(
children:
<
Widget
>[
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
show
window
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -301,7 +299,7 @@ void main() {
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
child:
Material
(
child:
Center
(
child:
Slider
(
...
...
packages/flutter_localizations/test/widgets_test.dart
View file @
7f2c1cd7
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_localizations/flutter_localizations.dart'
;
...
...
@@ -689,8 +687,8 @@ void main() {
const
OnlyRTLDefaultWidgetsLocalizationsDelegate
(),
],
buildContent:
(
BuildContext
context
)
{
final
Locale
locale1
=
ui
.
window
.
locales
.
first
;
final
Locale
locale2
=
ui
.
window
.
locales
[
1
];
final
Locale
locale1
=
WidgetsBinding
.
instance
.
platformDispatcher
.
locales
.
first
;
final
Locale
locale2
=
WidgetsBinding
.
instance
.
platformDispatcher
.
locales
[
1
];
return
Text
(
'
$locale1
$locale2
'
);
},
)
...
...
packages/integration_test/lib/_callback_io.dart
View file @
7f2c1cd7
...
...
@@ -109,7 +109,7 @@ class IOCallbackManager implements CallbackManager {
Future
<
dynamic
>
_onMethodChannelCall
(
MethodCall
call
)
async
{
switch
(
call
.
method
)
{
case
'scheduleFrame'
:
window
.
scheduleFrame
();
PlatformDispatcher
.
instance
.
scheduleFrame
();
break
;
}
return
null
;
...
...
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