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
dacfdb64
Commit
dacfdb64
authored
May 18, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track fake pointers in live test runs (#4011)
parent
80ed23e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
1 deletion
+79
-1
binding.dart
packages/flutter_test/lib/src/binding.dart
+78
-1
test_pointer.dart
packages/flutter_test/lib/src/test_pointer.dart
+1
-0
No files found.
packages/flutter_test/lib/src/binding.dart
View file @
dacfdb64
...
@@ -580,11 +580,30 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
...
@@ -580,11 +580,30 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
}
}
}
}
@override
void
initRenderView
()
{
assert
(
renderView
==
null
);
renderView
=
new
_LiveTestRenderView
(
configuration:
createViewConfiguration
());
renderView
.
scheduleInitialFrame
();
}
@override
_LiveTestRenderView
get
renderView
=>
super
.
renderView
;
@override
@override
void
dispatchEvent
(
PointerEvent
event
,
HitTestResult
result
,
{
void
dispatchEvent
(
PointerEvent
event
,
HitTestResult
result
,
{
TestBindingEventSource
source
:
TestBindingEventSource
.
device
TestBindingEventSource
source
:
TestBindingEventSource
.
device
})
{
})
{
if
(
source
==
TestBindingEventSource
.
test
)
{
if
(
source
==
TestBindingEventSource
.
test
)
{
if
(!
renderView
.
_pointers
.
containsKey
(
event
.
pointer
))
{
assert
(
event
.
down
);
renderView
.
_pointers
[
event
.
pointer
]
=
new
_LiveTestPointerRecord
(
event
.
pointer
,
event
.
position
);
}
else
{
renderView
.
_pointers
[
event
.
pointer
].
position
=
event
.
position
;
if
(!
event
.
down
)
renderView
.
_pointers
[
event
.
pointer
].
decay
=
_kPointerDecay
;
}
renderView
.
markNeedsPaint
();
super
.
dispatchEvent
(
event
,
result
,
source
:
source
);
super
.
dispatchEvent
(
event
,
result
,
source
:
source
);
return
;
return
;
}
}
...
@@ -665,9 +684,67 @@ class _TestViewConfiguration extends ViewConfiguration {
...
@@ -665,9 +684,67 @@ class _TestViewConfiguration extends ViewConfiguration {
String
toString
()
=>
'TestViewConfiguration'
;
String
toString
()
=>
'TestViewConfiguration'
;
}
}
const
int
_kPointerDecay
=
-
2
;
class
_LiveTestPointerRecord
{
_LiveTestPointerRecord
(
int
pointer
,
this
.
position
)
:
pointer
=
pointer
,
color
=
new
HSVColor
.
fromAHSV
(
0.8
,
(
35.0
*
pointer
)
%
360.0
,
1.0
,
1.0
).
toColor
(),
decay
=
1
;
final
int
pointer
;
final
Color
color
;
Point
position
;
int
decay
;
// >0 means down, <0 means up, increases by one each time, removed at 0
}
class
_LiveTestRenderView
extends
RenderView
{
_LiveTestRenderView
({
ViewConfiguration
configuration
})
:
super
(
configuration:
configuration
);
final
Map
<
int
,
_LiveTestPointerRecord
>
_pointers
=
<
int
,
_LiveTestPointerRecord
>{};
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
assert
(
offset
==
Offset
.
zero
);
super
.
paint
(
context
,
offset
);
if
(
_pointers
.
isNotEmpty
)
{
final
double
radius
=
configuration
.
size
.
shortestSide
*
0.05
;
final
Path
path
=
new
Path
()
..
addOval
(
new
Rect
.
fromCircle
(
center:
Point
.
origin
,
radius:
radius
))
..
moveTo
(
0.0
,
-
radius
*
2.0
)
..
lineTo
(
0.0
,
radius
*
2.0
)
..
moveTo
(-
radius
*
2.0
,
0.0
)
..
lineTo
(
radius
*
2.0
,
0.0
);
final
Canvas
canvas
=
context
.
canvas
;
final
Paint
paint
=
new
Paint
()
..
strokeWidth
=
radius
/
10.0
..
style
=
PaintingStyle
.
stroke
;
bool
dirty
=
false
;
for
(
int
pointer
in
_pointers
.
keys
)
{
_LiveTestPointerRecord
record
=
_pointers
[
pointer
];
paint
.
color
=
record
.
color
.
withOpacity
(
record
.
decay
<
0
?
(
record
.
decay
/
(
_kPointerDecay
-
1
))
:
1.0
);
canvas
.
drawPath
(
path
.
shift
(
record
.
position
.
toOffset
()),
paint
);
if
(
record
.
decay
<
0
)
dirty
=
true
;
record
.
decay
+=
1
;
}
_pointers
.
keys
.
where
((
int
pointer
)
=>
_pointers
[
pointer
].
decay
==
0
)
.
toList
()
.
forEach
((
int
pointer
)
{
_pointers
.
remove
(
pointer
);
});
if
(
dirty
)
scheduleMicrotask
(
markNeedsPaint
);
}
}
}
class
_EmptyStack
implements
StackTrace
{
class
_EmptyStack
implements
StackTrace
{
const
_EmptyStack
.
_
();
const
_EmptyStack
.
_
();
static
const
_EmptyStack
instance
=
const
_EmptyStack
.
_
();
static
const
_EmptyStack
instance
=
const
_EmptyStack
.
_
();
@override
@override
String
toString
()
=>
''
;
String
toString
()
=>
''
;
}
}
\ No newline at end of file
packages/flutter_test/lib/src/test_pointer.dart
View file @
dacfdb64
...
@@ -66,6 +66,7 @@ class TestPointer {
...
@@ -66,6 +66,7 @@ class TestPointer {
return
new
PointerMoveEvent
(
return
new
PointerMoveEvent
(
timeStamp:
timeStamp
,
timeStamp:
timeStamp
,
pointer:
pointer
,
pointer:
pointer
,
down:
_isDown
,
position:
newLocation
,
position:
newLocation
,
delta:
delta
delta:
delta
);
);
...
...
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