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
0a383fce
Unverified
Commit
0a383fce
authored
May 22, 2018
by
Hans Muller
Committed by
GitHub
May 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix InkRipple.cancel(), added paints..everything (#17787)
parent
dfc0244e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
9 deletions
+105
-9
ink_ripple.dart
packages/flutter/lib/src/material/ink_ripple.dart
+6
-8
ink_paint_test.dart
packages/flutter/test/material/ink_paint_test.dart
+46
-0
mock_canvas.dart
packages/flutter/test/rendering/mock_canvas.dart
+53
-1
No files found.
packages/flutter/lib/src/material/ink_ripple.dart
View file @
0a383fce
...
...
@@ -198,15 +198,13 @@ class InkRipple extends InteractiveInkFeature {
@override
void
cancel
()
{
_fadeInController
.
stop
();
// Watch out: setting _fadeOutController's value to 1.0 w
ould
// trigger a call to _handleAlphaStatusChanged() which w
ould
// Watch out: setting _fadeOutController's value to 1.0 w
ill
// trigger a call to _handleAlphaStatusChanged() which w
ill
// dispose _fadeOutController.
final
double
_fadeOutValue
=
1.0
-
_fadeInController
.
value
;
if
(
_fadeOutValue
<
1.0
)
{
_fadeOutController
..
value
=
_fadeOutValue
..
animateTo
(
1.0
,
duration:
_kCancelDuration
);
}
final
double
fadeOutValue
=
1.0
-
_fadeInController
.
value
;
_fadeOutController
.
value
=
fadeOutValue
;
if
(
fadeOutValue
<
1.0
)
_fadeOutController
.
animateTo
(
1.0
,
duration:
_kCancelDuration
);
}
void
_handleAlphaStatusChanged
(
AnimationStatus
status
)
{
...
...
packages/flutter/test/material/ink_paint_test.dart
View file @
0a383fce
...
...
@@ -278,4 +278,50 @@ void main() {
await
gesture
.
up
();
// generates a tap cancel
await
tester
.
pumpAndSettle
();
});
testWidgets
(
'Cancel an InkRipple that was disposed when its animation ended'
,
(
WidgetTester
tester
)
async
{
const
Color
highlightColor
=
const
Color
(
0xAAFF0000
);
const
Color
splashColor
=
const
Color
(
0xB40000FF
);
// Regression test for https://github.com/flutter/flutter/issues/14391
await
tester
.
pumpWidget
(
new
Material
(
child:
new
Center
(
child:
new
Container
(
width:
100.0
,
height:
100.0
,
child:
new
InkWell
(
splashColor:
splashColor
,
highlightColor:
highlightColor
,
onTap:
()
{
},
radius:
100.0
,
splashFactory:
InkRipple
.
splashFactory
,
),
),
),
),
);
final
Offset
tapDownOffset
=
tester
.
getTopLeft
(
find
.
byType
(
InkWell
));
await
tester
.
tapAt
(
tapDownOffset
);
await
tester
.
pump
();
// start splash
// No delay here so _fadeInController.value=1.0 (InkRipple.dart)
// Generate a tap cancel; Will cancel the ink splash before it started
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tapDownOffset
);
await
tester
.
pump
();
// start gesture
await
gesture
.
moveTo
(
const
Offset
(
0.0
,
0.0
));
await
gesture
.
up
();
// generates a tap cancel
final
RenderBox
box
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
InkWell
)))
as
dynamic
;
expect
(
box
,
paints
..
everything
((
Symbol
method
,
List
<
dynamic
>
arguments
)
{
if
(
method
!=
#drawCircle
)
return
true
;
final
Paint
paint
=
arguments
[
2
];
if
(
paint
.
color
.
alpha
==
0
)
return
true
;
throw
'Expected: paint.color.alpha == 0, found:
${paint.color.alpha}
'
;
}));
});
}
packages/flutter/test/rendering/mock_canvas.dart
View file @
0a383fce
...
...
@@ -48,7 +48,8 @@ Matcher get paintsNothing => new _TestRecordingCanvasPaintsNothingMatcher();
/// Matches objects or functions that assert when they try to paint.
Matcher
get
paintsAssertion
=>
new
_TestRecordingCanvasPaintsAssertionMatcher
();
/// Signature for [PaintPattern.something] predicate argument.
/// Signature for the [PaintPattern.something] and [PaintPattern.everything]
/// predicate argument.
///
/// Used by the [paints] matcher.
///
...
...
@@ -398,6 +399,22 @@ abstract class PaintPattern {
/// displayed from the test framework and should be complete sentence
/// describing the problem.
void
something
(
PaintPatternPredicate
predicate
);
/// Provides a custom matcher.
///
/// Each method call after the last matched call (if any) will be passed to
/// the given predicate, along with the values of its (positional) arguments.
///
/// For each one, the predicate must either return a boolean or throw a [String].
///
/// The predicate will be applied to each [Canvas] call until it returns false
/// or all of the method calls have been tested.
///
/// If the predicate throws a [String], then the [paints] [Matcher] is
/// considered to have failed. The thrown string is used in the message
/// displayed from the test framework and should be complete sentence
/// describing the problem.
void
everything
(
PaintPatternPredicate
predicate
);
}
/// Matches a [Path] that contains (as defined by [Path.contains]) the given
...
...
@@ -728,6 +745,11 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
_predicates
.
add
(
new
_SomethingPaintPredicate
(
predicate
));
}
@override
void
everything
(
PaintPatternPredicate
predicate
)
{
_predicates
.
add
(
new
_EverythingPaintPredicate
(
predicate
));
}
@override
Description
describe
(
Description
description
)
{
if
(
_predicates
.
isEmpty
)
...
...
@@ -1303,6 +1325,36 @@ class _SomethingPaintPredicate extends _PaintPredicate {
String
toString
()
=>
'a "something" step'
;
}
class
_EverythingPaintPredicate
extends
_PaintPredicate
{
_EverythingPaintPredicate
(
this
.
predicate
);
final
PaintPatternPredicate
predicate
;
@override
void
match
(
Iterator
<
RecordedInvocation
>
call
)
{
assert
(
predicate
!=
null
);
while
(
call
.
moveNext
())
{
final
RecordedInvocation
currentCall
=
call
.
current
;
if
(!
currentCall
.
invocation
.
isMethod
)
throw
'It called
$currentCall
, which was not a method, when the paint pattern expected a method call'
;
if
(!
_runPredicate
(
currentCall
.
invocation
.
memberName
,
currentCall
.
invocation
.
positionalArguments
))
return
;
}
}
bool
_runPredicate
(
Symbol
methodName
,
List
<
dynamic
>
arguments
)
{
try
{
return
predicate
(
methodName
,
arguments
);
}
on
String
catch
(
s
)
{
throw
'It painted something that the predicate passed to an "everything" step '
'in the paint pattern considered incorrect:
\n
$s
\n
'
;
}
}
@override
String
toString
()
=>
'an "everything" step'
;
}
class
_FunctionPaintPredicate
extends
_PaintPredicate
{
_FunctionPaintPredicate
(
this
.
symbol
,
this
.
arguments
);
...
...
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