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
3e7fe378
Unverified
Commit
3e7fe378
authored
Jul 21, 2020
by
Ming Lyu (CareF)
Committed by
GitHub
Jul 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "LiveTestWidgetsFlutterBinding support for non-touch event" (#61901)
parent
aa9119e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
binding.dart
packages/flutter_test/lib/src/binding.dart
+14
-10
live_binding_test.dart
packages/flutter_test/test/live_binding_test.dart
+22
-0
No files found.
packages/flutter_test/lib/src/binding.dart
View file @
3e7fe378
...
...
@@ -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 @
3e7fe378
...
...
@@ -2,7 +2,10 @@
// 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/gestures.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
// This file is for testings that require a `LiveTestWidgetsFlutterBinding`
...
...
@@ -15,5 +18,24 @@ void main() {
// This mimics the start of a gesture as seen on a device, where inputs
// starts with a PointerAddedEvent.
await
gesture
.
addPointer
();
// The expected result of the test is not to trigger any assert.
});
testWidgets
(
'Input PointerHoverEvent'
,
(
WidgetTester
tester
)
async
{
PointerHoverEvent
hoverEvent
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MouseRegion
(
child:
const
Text
(
'Test'
),
onHover:
(
PointerHoverEvent
event
){
hoverEvent
=
event
;
},
)));
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
);
expect
(
hoverEvent
,
isNotNull
);
expect
(
hoverEvent
.
position
,
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