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
a599c08c
Unverified
Commit
a599c08c
authored
Mar 15, 2023
by
Michael Goderbauer
Committed by
GitHub
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remvoe last few references to window singleton (#122644)
Remove last few references to window singleton
parent
0ba64488
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
51 additions
and
46 deletions
+51
-46
binding.dart
packages/flutter/lib/src/gestures/binding.dart
+1
-1
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+4
-3
gesture_binding_resample_event_test.dart
...er/test/gestures/gesture_binding_resample_event_test.dart
+5
-3
menu_anchor_test.dart
packages/flutter/test/material/menu_anchor_test.dart
+2
-8
mouse_tracker_cursor_test.dart
...ges/flutter/test/rendering/mouse_tracker_cursor_test.dart
+3
-2
mouse_tracker_test.dart
packages/flutter/test/rendering/mouse_tracker_test.dart
+3
-2
platform_view_test.dart
packages/flutter/test/rendering/platform_view_test.dart
+3
-2
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+1
-1
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+4
-4
reparent_state_with_layout_builder_test.dart
...test/widgets/reparent_state_with_layout_builder_test.dart
+1
-1
scroll_position_test.dart
packages/flutter/test/widgets/scroll_position_test.dart
+1
-1
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+1
-1
_matchers_web.dart
packages/flutter_test/lib/src/_matchers_web.dart
+3
-2
binding.dart
packages/flutter_test/lib/src/binding.dart
+5
-4
accessibility_window_test.dart
packages/flutter_test/test/accessibility_window_test.dart
+6
-4
live_binding_test.dart
packages/flutter_test/test/live_binding_test.dart
+2
-2
widget_tester_live_device_test.dart
...ges/flutter_test/test/widget_tester_live_device_test.dart
+2
-2
integration_test.dart
packages/integration_test/lib/integration_test.dart
+4
-3
No files found.
packages/flutter/lib/src/gestures/binding.dart
View file @
a599c08c
...
...
@@ -288,7 +288,7 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
// We convert pointer data to logical pixels so that e.g. the touch slop can be
// defined in a device-independent manner.
try
{
_pendingPointerEvents
.
addAll
(
PointerEventConverter
.
expand
(
packet
.
data
,
window
.
devicePixelRatio
));
_pendingPointerEvents
.
addAll
(
PointerEventConverter
.
expand
(
packet
.
data
,
platformDispatcher
.
implicitView
!
.
devicePixelRatio
));
if
(!
locked
)
{
_flushPointerEventQueue
();
}
...
...
packages/flutter/lib/src/rendering/binding.dart
View file @
a599c08c
...
...
@@ -212,7 +212,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
_debugIsRenderViewInitialized
=
true
;
return
true
;
}());
renderView
=
RenderView
(
configuration:
createViewConfiguration
(),
window:
window
);
renderView
=
RenderView
(
configuration:
createViewConfiguration
(),
window:
platformDispatcher
.
implicitView
!
);
renderView
.
prepareInitialFrame
();
}
bool
_debugIsRenderViewInitialized
=
false
;
...
...
@@ -300,9 +300,10 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
/// this to force the display into 800x600 when a test is run on the device
/// using `flutter run`.
ViewConfiguration
createViewConfiguration
()
{
final
double
devicePixelRatio
=
window
.
devicePixelRatio
;
final
FlutterView
view
=
platformDispatcher
.
implicitView
!;
final
double
devicePixelRatio
=
view
.
devicePixelRatio
;
return
ViewConfiguration
(
size:
windo
w
.
physicalSize
/
devicePixelRatio
,
size:
vie
w
.
physicalSize
/
devicePixelRatio
,
devicePixelRatio:
devicePixelRatio
,
);
}
...
...
packages/flutter/test/gestures/gesture_binding_resample_event_test.dart
View file @
a599c08c
...
...
@@ -140,7 +140,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
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
0
].
position
,
Offset
(
0.0
/
_
devicePixelRatio
,
0.0
));
// Second frame callback should have been requested.
callback
=
binding
.
postFrameCallback
;
...
...
@@ -155,8 +155,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
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
10.0
/
GestureBinding
.
instance
.
window
.
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
position
,
Offset
(
10.0
/
_
devicePixelRatio
,
0.0
));
expect
(
events
[
1
].
delta
,
Offset
(
10.0
/
_
devicePixelRatio
,
0.0
));
// Verify that resampling continues without a frame callback.
async
.
elapse
(
frameInterval
*
1.5
);
...
...
@@ -183,3 +183,5 @@ void main() {
GestureBinding
.
instance
.
resamplingEnabled
=
false
;
});
}
double
get
_devicePixelRatio
=>
GestureBinding
.
instance
.
platformDispatcher
.
implicitView
!.
devicePixelRatio
;
packages/flutter/test/material/menu_anchor_test.dart
View file @
a599c08c
...
...
@@ -18,7 +18,6 @@ void main() {
final
List
<
TestMenu
>
opened
=
<
TestMenu
>[];
final
List
<
TestMenu
>
closed
=
<
TestMenu
>[];
final
GlobalKey
menuItemKey
=
GlobalKey
();
late
Size
defaultSize
;
void
onPressed
(
TestMenu
item
)
{
selected
.
add
(
item
);
...
...
@@ -36,11 +35,6 @@ void main() {
focusedMenu
=
(
primaryFocus
?.
debugLabel
??
primaryFocus
).
toString
();
}
setUpAll
(()
{
final
MediaQueryData
mediaQueryData
=
MediaQueryData
.
fromView
(
TestWidgetsFlutterBinding
.
instance
.
window
);
defaultSize
=
mediaQueryData
.
size
;
});
setUp
(()
{
focusedMenu
=
null
;
selected
.
clear
();
...
...
@@ -53,7 +47,7 @@ void main() {
Future
<
void
>
changeSurfaceSize
(
WidgetTester
tester
,
Size
size
)
async
{
await
tester
.
binding
.
setSurfaceSize
(
size
);
addTearDown
(()
async
{
await
tester
.
binding
.
setSurfaceSize
(
defaultSize
);
await
tester
.
binding
.
setSurfaceSize
(
null
);
});
}
...
...
@@ -1395,7 +1389,7 @@ void main() {
testWidgets
(
'menus close on view size change'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
scrollController
=
ScrollController
();
final
MediaQueryData
mediaQueryData
=
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
);
final
MediaQueryData
mediaQueryData
=
MediaQueryData
.
fromView
(
tester
.
vie
w
);
Widget
build
(
Size
size
)
{
return
MaterialApp
(
...
...
packages/flutter/test/rendering/mouse_tracker_cursor_test.dart
View file @
a599c08c
...
...
@@ -438,10 +438,11 @@ ui.PointerData _pointerData(
int
device
=
0
,
PointerDeviceKind
kind
=
PointerDeviceKind
.
mouse
,
})
{
final
double
devicePixelRatio
=
RendererBinding
.
instance
.
platformDispatcher
.
implicitView
!.
devicePixelRatio
;
return
ui
.
PointerData
(
change:
change
,
physicalX:
logicalPosition
.
dx
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalX:
logicalPosition
.
dx
*
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
devicePixelRatio
,
kind:
kind
,
device:
device
,
);
...
...
packages/flutter/test/rendering/mouse_tracker_test.dart
View file @
a599c08c
...
...
@@ -592,10 +592,11 @@ ui.PointerData _pointerData(
int
device
=
0
,
PointerDeviceKind
kind
=
PointerDeviceKind
.
mouse
,
})
{
final
double
devicePixelRatio
=
RendererBinding
.
instance
.
platformDispatcher
.
implicitView
!.
devicePixelRatio
;
return
ui
.
PointerData
(
change:
change
,
physicalX:
logicalPosition
.
dx
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalX:
logicalPosition
.
dx
*
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
devicePixelRatio
,
kind:
kind
,
device:
device
,
);
...
...
packages/flutter/test/rendering/platform_view_test.dart
View file @
a599c08c
...
...
@@ -305,12 +305,13 @@ ui.PointerData _pointerData(
PointerDeviceKind
kind
=
PointerDeviceKind
.
mouse
,
int
pointer
=
0
,
})
{
final
double
devicePixelRatio
=
RendererBinding
.
instance
.
platformDispatcher
.
implicitView
!.
devicePixelRatio
;
return
ui
.
PointerData
(
pointerIdentifier:
pointer
,
embedderId:
pointer
,
change:
change
,
physicalX:
logicalPosition
.
dx
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
RendererBinding
.
instance
.
window
.
devicePixelRatio
,
physicalX:
logicalPosition
.
dx
*
devicePixelRatio
,
physicalY:
logicalPosition
.
dy
*
devicePixelRatio
,
kind:
kind
,
device:
device
,
);
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
a599c08c
...
...
@@ -1098,7 +1098,7 @@ void main() {
});
testWidgets
(
'MediaQueryData.fromWindow is created using window values'
,
(
WidgetTester
tester
)
async
{
final
MediaQueryData
windowData
=
MediaQueryData
.
fromWindow
(
tester
.
binding
.
windo
w
);
final
MediaQueryData
windowData
=
MediaQueryData
.
fromWindow
(
tester
.
vie
w
);
late
MediaQueryData
fromWindowData
;
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/navigator_test.dart
View file @
a599c08c
...
...
@@ -206,7 +206,7 @@ void main() {
const
MaterialPage
<
void
>
page
=
MaterialPage
<
void
>(
child:
Text
(
'page'
));
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Navigator
(
...
...
@@ -221,7 +221,7 @@ void main() {
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Navigator
(
...
...
@@ -2810,7 +2810,7 @@ void main() {
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
...
...
@@ -2849,7 +2849,7 @@ void main() {
};
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
...
...
packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart
View file @
a599c08c
...
...
@@ -96,7 +96,7 @@ void main() {
Widget
deepChild
=
Container
();
await
tester
.
pumpWidget
(
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Column
(
children:
<
Widget
>[
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
...
...
packages/flutter/test/widgets/scroll_position_test.dart
View file @
a599c08c
...
...
@@ -34,7 +34,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Navigator
(
key:
navigatorKey
,
onGenerateRoute:
(
RouteSettings
settings
)
{
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
a599c08c
...
...
@@ -301,7 +301,7 @@ void main() {
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromView
(
tester
.
binding
.
windo
w
),
data:
MediaQueryData
.
fromView
(
tester
.
vie
w
),
child:
Material
(
child:
Center
(
child:
Slider
(
...
...
packages/flutter_test/lib/src/_matchers_web.dart
View file @
a599c08c
...
...
@@ -58,12 +58,13 @@ class MatchesGoldenFile extends AsyncMatcher {
final
Size
size
=
renderObject
.
paintBounds
.
size
;
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
instance
;
final
Element
e
=
binding
.
renderViewElement
!;
final
ui
.
FlutterView
view
=
binding
.
platformDispatcher
.
implicitView
!;
// Unlike `flutter_tester`, we don't have the ability to render an element
// to an image directly. Instead, we will use `window.render()` to render
// only the element being requested, and send a request to the test server
// requesting it to take a screenshot through the browser's debug interface.
_renderElement
(
binding
.
windo
w
,
renderObject
);
_renderElement
(
vie
w
,
renderObject
);
final
String
?
result
=
await
binding
.
runAsync
<
String
?>(()
async
{
if
(
autoUpdateGoldenFiles
)
{
await
webGoldenComparator
.
update
(
size
.
width
,
size
.
height
,
key
);
...
...
@@ -76,7 +77,7 @@ class MatchesGoldenFile extends AsyncMatcher {
return
ex
.
message
;
}
},
additionalTime:
const
Duration
(
seconds:
22
));
_renderElement
(
binding
.
windo
w
,
_findRepaintBoundary
(
e
));
_renderElement
(
vie
w
,
_findRepaintBoundary
(
e
));
return
result
;
}
...
...
packages/flutter_test/lib/src/binding.dart
View file @
a599c08c
...
...
@@ -485,8 +485,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
@override
ViewConfiguration
createViewConfiguration
()
{
final
double
devicePixelRatio
=
window
.
devicePixelRatio
;
final
Size
size
=
_surfaceSize
??
window
.
physicalSize
/
devicePixelRatio
;
final
FlutterView
view
=
platformDispatcher
.
implicitView
!;
final
double
devicePixelRatio
=
view
.
devicePixelRatio
;
final
Size
size
=
_surfaceSize
??
view
.
physicalSize
/
devicePixelRatio
;
return
ViewConfiguration
(
size:
size
,
devicePixelRatio:
devicePixelRatio
,
...
...
@@ -1730,7 +1731,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
renderView
=
_LiveTestRenderView
(
configuration:
createViewConfiguration
(),
onNeedPaint:
_handleViewNeedsPaint
,
window:
window
,
window:
platformDispatcher
.
implicitView
!
,
);
renderView
.
prepareInitialFrame
();
}
...
...
@@ -1921,7 +1922,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
ViewConfiguration
createViewConfiguration
()
{
return
TestViewConfiguration
.
fromView
(
size:
_surfaceSize
??
_kDefaultTestViewportSize
,
view:
window
,
view:
platformDispatcher
.
implicitView
!
,
);
}
...
...
packages/flutter_test/test/accessibility_window_test.dart
View file @
a599c08c
...
...
@@ -7,8 +7,9 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
testWidgets
(
'Fails correctly with configured screen size - small'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
devicePixelRatioTestValue
=
1.2
;
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
250
,
300
);
tester
.
view
.
devicePixelRatio
=
1.2
;
tester
.
view
.
physicalSize
=
const
Size
(
250
,
300
);
addTearDown
(
tester
.
view
.
reset
);
final
Widget
invalidButton
=
ElevatedButton
(
onPressed:
()
{},
...
...
@@ -25,8 +26,9 @@ void main() {
});
testWidgets
(
'Fails correctly with configured screen size - large'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
devicePixelRatioTestValue
=
4.2
;
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
2500
,
3000
);
tester
.
view
.
devicePixelRatio
=
4.2
;
tester
.
view
.
physicalSize
=
const
Size
(
2500
,
3000
);
addTearDown
(
tester
.
view
.
reset
);
final
Widget
invalidButton
=
ElevatedButton
(
onPressed:
()
{},
...
...
packages/flutter_test/test/live_binding_test.dart
View file @
a599c08c
...
...
@@ -71,8 +71,8 @@ void main() {
testWidgets
(
'setSurfaceSize works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Center
(
child:
Text
(
'Test'
))));
final
Size
windowCenter
=
tester
.
binding
.
windo
w
.
physicalSize
/
tester
.
binding
.
windo
w
.
devicePixelRatio
/
final
Size
windowCenter
=
tester
.
vie
w
.
physicalSize
/
tester
.
vie
w
.
devicePixelRatio
/
2
;
final
double
windowCenterX
=
windowCenter
.
width
;
final
double
windowCenterY
=
windowCenter
.
height
;
...
...
packages/flutter_test/test/widget_tester_live_device_test.dart
View file @
a599c08c
...
...
@@ -34,8 +34,8 @@ void main() {
),
);
final
Size
windowCenter
=
tester
.
binding
.
windo
w
.
physicalSize
/
tester
.
binding
.
windo
w
.
devicePixelRatio
/
final
Size
windowCenter
=
tester
.
vie
w
.
physicalSize
/
tester
.
vie
w
.
devicePixelRatio
/
2
;
final
double
windowCenterX
=
windowCenter
.
width
;
final
double
windowCenterY
=
windowCenter
.
height
;
...
...
packages/integration_test/lib/integration_test.dart
View file @
a599c08c
...
...
@@ -118,11 +118,12 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab
@override
ViewConfiguration
createViewConfiguration
()
{
final
double
devicePixelRatio
=
window
.
devicePixelRatio
;
final
Size
size
=
_surfaceSize
??
window
.
physicalSize
/
devicePixelRatio
;
final
FlutterView
view
=
platformDispatcher
.
implicitView
!;
final
double
devicePixelRatio
=
view
.
devicePixelRatio
;
final
Size
size
=
_surfaceSize
??
view
.
physicalSize
/
devicePixelRatio
;
return
TestViewConfiguration
.
fromView
(
size:
size
,
view:
windo
w
,
view:
vie
w
,
);
}
...
...
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