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
92a1a8ba
Unverified
Commit
92a1a8ba
authored
Mar 02, 2023
by
Michael Goderbauer
Committed by
GitHub
Mar 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to FlutterView.gestureSettings (#121749)
parent
5cf1e5f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
11 deletions
+25
-11
gesture_settings.dart
packages/flutter/lib/src/gestures/gesture_settings.dart
+1
-1
gesture_config_regression_test.dart
...flutter/test/gestures/gesture_config_regression_test.dart
+5
-6
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+4
-4
window.dart
packages/flutter_test/lib/src/window.dart
+15
-0
No files found.
packages/flutter/lib/src/gestures/gesture_settings.dart
View file @
92a1a8ba
...
...
@@ -26,7 +26,7 @@ class DeviceGestureSettings {
/// Create a new [DeviceGestureSettings] from the provided [view].
factory
DeviceGestureSettings
.
fromView
(
ui
.
FlutterView
view
)
{
final
double
?
physicalTouchSlop
=
view
.
viewConfiguration
.
gestureSettings
.
physicalTouchSlop
;
final
double
?
physicalTouchSlop
=
view
.
gestureSettings
.
physicalTouchSlop
;
return
DeviceGestureSettings
(
touchSlop:
physicalTouchSlop
==
null
?
null
:
physicalTouchSlop
/
view
.
devicePixelRatio
);
...
...
packages/flutter/test/gestures/gesture_config_regression_test.dart
View file @
92a1a8ba
...
...
@@ -90,9 +90,7 @@ class NestedDraggableCase extends StatelessWidget {
void
main
(
)
{
testWidgets
(
'Scroll Views get the same ScrollConfiguration as GestureDetectors'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ui
.
ViewConfiguration
(
gestureSettings:
ui
.
GestureSettings
(
physicalTouchSlop:
4
),
);
tester
.
binding
.
window
.
gestureSettingsTestValue
=
const
ui
.
GestureSettings
(
physicalTouchSlop:
4
);
final
TestResult
result
=
TestResult
();
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -110,12 +108,12 @@ void main() {
expect
(
result
.
dragStarted
,
true
);
expect
(
result
.
dragUpdate
,
true
);
tester
.
binding
.
window
.
clearGestureSettingsTestValue
();
});
testWidgets
(
'Scroll Views get the same ScrollConfiguration as Draggables'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ui
.
ViewConfiguration
(
gestureSettings:
ui
.
GestureSettings
(
physicalTouchSlop:
4
),
);
tester
.
binding
.
window
.
gestureSettingsTestValue
=
const
ui
.
GestureSettings
(
physicalTouchSlop:
4
);
final
TestResult
result
=
TestResult
();
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -133,5 +131,6 @@ void main() {
expect
(
result
.
dragStarted
,
true
);
expect
(
result
.
dragUpdate
,
true
);
tester
.
binding
.
window
.
clearGestureSettingsTestValue
();
});
}
packages/flutter/test/widgets/media_query_test.dart
View file @
92a1a8ba
...
...
@@ -1326,12 +1326,10 @@ void main() {
});
testWidgets
(
'MediaQueryData.gestureSettings is set from window.viewConfiguration'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
viewConfigurationTestValue
=
const
ViewConfiguration
(
gestureSettings:
GestureSettings
(
physicalDoubleTapSlop:
100
,
physicalTouchSlop:
100
),
);
tester
.
binding
.
window
.
gestureSettingsTestValue
=
const
GestureSettings
(
physicalDoubleTapSlop:
100
,
physicalTouchSlop:
100
);
expect
(
MediaQueryData
.
fromView
(
tester
.
binding
.
window
).
gestureSettings
.
touchSlop
,
closeTo
(
33.33
,
0.1
));
// Repeating, of course
tester
.
binding
.
window
.
viewConfigurationTestValue
=
null
;
tester
.
binding
.
window
.
clearGestureSettingsTestValue
()
;
});
testWidgets
(
'MediaQuery can be partially depended-on'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1544,6 +1542,8 @@ class TestView implements FlutterView {
final
ViewConfiguration
viewConfiguration
=
const
ViewConfiguration
();
@override
final
List
<
DisplayFeature
>
displayFeatures
=
<
DisplayFeature
>[];
@override
final
GestureSettings
gestureSettings
=
const
GestureSettings
();
@override
dynamic
noSuchMethod
(
Invocation
invocation
)
=>
super
.
noSuchMethod
(
invocation
);
...
...
packages/flutter_test/lib/src/window.dart
View file @
92a1a8ba
...
...
@@ -143,6 +143,20 @@ class TestWindow implements ui.SingletonFlutterWindow {
onMetricsChanged
?.
call
();
}
@override
ui
.
GestureSettings
get
gestureSettings
=>
_gestureSettings
??
_window
.
gestureSettings
;
ui
.
GestureSettings
?
_gestureSettings
;
/// Hides the real gesture settings and reports the given [gestureSettingsTestValue] instead.
set
gestureSettingsTestValue
(
ui
.
GestureSettings
gestureSettingsTestValue
)
{
// ignore: avoid_setters_without_getters
_gestureSettings
=
gestureSettingsTestValue
;
onMetricsChanged
?.
call
();
}
/// Deletes any existing test gesture settings and returns to using the real gesture settings.
void
clearGestureSettingsTestValue
()
{
_paddingTestValue
=
null
;
onMetricsChanged
?.
call
();
}
@override
List
<
ui
.
DisplayFeature
>
get
displayFeatures
=>
_displayFeaturesTestValue
??
_window
.
displayFeatures
;
List
<
ui
.
DisplayFeature
>?
_displayFeaturesTestValue
;
...
...
@@ -508,6 +522,7 @@ class TestWindow implements ui.SingletonFlutterWindow {
void
clearAllTestValues
()
{
clearDevicePixelRatioTestValue
();
clearPaddingTestValue
();
clearGestureSettingsTestValue
();
clearDisplayFeaturesTestValue
();
clearPhysicalSizeTestValue
();
clearViewInsetsTestValue
();
...
...
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