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
aa4b4d35
Unverified
Commit
aa4b4d35
authored
Jul 20, 2020
by
Ming Lyu (CareF)
Committed by
GitHub
Jul 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LiveTestWidgetsFlutterBinding support for non-touch event (#61872)
parent
3577da53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
binding.dart
packages/flutter_test/lib/src/binding.dart
+14
-10
live_binding_test.dart
packages/flutter_test/test/live_binding_test.dart
+13
-0
No files found.
packages/flutter_test/lib/src/binding.dart
View file @
aa4b4d35
...
...
@@ -1468,6 +1468,11 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
/// Events dispatched by [TestGesture] are not affected by this.
HitTestDispatcher
deviceEventDispatcher
;
/// Dispatch an event to a hit test result's path.
///
/// Apart from forwarding the event to [GestureBinding.dispatchEvent],
/// This also paint all events that's down on the screen.
@override
void
dispatchEvent
(
PointerEvent
event
,
...
...
@@ -1476,20 +1481,19 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
})
{
switch
(
source
)
{
case
TestBindingEventSource
.
test
:
if
(!
renderView
.
_pointers
.
containsKey
(
event
.
pointer
))
{
assert
(
event
.
down
||
event
is
PointerAddedEvent
);
if
(
event
.
down
)
{
renderView
.
_pointers
[
event
.
pointer
]
=
_LiveTestPointerRecord
(
event
.
pointer
,
event
.
position
,
);
}
}
else
{
if
(
renderView
.
_pointers
.
containsKey
(
event
.
pointer
))
{
renderView
.
_pointers
[
event
.
pointer
].
position
=
event
.
position
;
if
(!
event
.
down
)
renderView
.
_pointers
[
event
.
pointer
].
decay
=
_kPointerDecay
;
_handleViewNeedsPaint
();
}
else
if
(
event
.
down
)
{
assert
(
event
is
PointerDownEvent
);
renderView
.
_pointers
[
event
.
pointer
]
=
_LiveTestPointerRecord
(
event
.
pointer
,
event
.
position
,
);
_handleViewNeedsPaint
();
}
_handleViewNeedsPaint
();
super
.
dispatchEvent
(
event
,
hitTestResult
,
source
:
source
);
break
;
case
TestBindingEventSource
.
device
:
...
...
packages/flutter_test/test/live_binding_test.dart
View file @
aa4b4d35
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -16,4 +18,15 @@ void main() {
// starts with a PointerAddedEvent.
await
gesture
.
addPointer
();
});
testWidgets
(
'Input PointerHoverEvent'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'Test'
)));
await
tester
.
pump
();
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
final
Offset
location
=
tester
.
getCenter
(
find
.
text
(
'Test'
));
// for mouse input without a down event, moveTo generates a hover event
await
gesture
.
moveTo
(
location
);
await
gesture
.
removePointer
();
});
}
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