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
05eef4a9
Commit
05eef4a9
authored
Jun 23, 2016
by
Adam Barth
Committed by
GitHub
Jun 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get to 100% test coverage for src/animation/animations.dart (#4721)
parent
84095264
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
16 deletions
+90
-16
animations.dart
packages/flutter/lib/src/animation/animations.dart
+11
-15
animations_test.dart
packages/flutter/test/animation/animations_test.dart
+79
-1
No files found.
packages/flutter/lib/src/animation/animations.dart
View file @
05eef4a9
...
...
@@ -281,13 +281,13 @@ class ReverseAnimation extends Animation<double>
double
get
value
=>
1.0
-
parent
.
value
;
AnimationStatus
_reverseStatus
(
AnimationStatus
status
)
{
assert
(
status
!=
null
);
switch
(
status
)
{
case
AnimationStatus
.
forward
:
return
AnimationStatus
.
reverse
;
case
AnimationStatus
.
reverse
:
return
AnimationStatus
.
forward
;
case
AnimationStatus
.
completed
:
return
AnimationStatus
.
dismissed
;
case
AnimationStatus
.
dismissed
:
return
AnimationStatus
.
completed
;
}
assert
(
status
!=
null
);
return
null
;
}
...
...
@@ -399,7 +399,7 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
if
(
reverseCurve
==
null
)
return
'
$parent
\
u27A9
$curve
'
;
if
(
_useForwardCurve
)
return
'
$parent
\
u27A9
$curve
\
u2092
\
u2099/
$reverseCurve
'
;
return
'
$parent
\
u27A9
$curve
\
u2092
\
u2099/
$reverseCurve
'
;
return
'
$parent
\
u27A9
$curve
/
$reverseCurve
\
u2092
\
u2099'
;
}
}
...
...
@@ -438,8 +438,7 @@ class TrainHoppingAnimation extends Animation<double>
}
_currentTrain
.
addStatusListener
(
_statusChangeHandler
);
_currentTrain
.
addListener
(
_valueChangeHandler
);
if
(
_nextTrain
!=
null
)
_nextTrain
.
addListener
(
_valueChangeHandler
);
_nextTrain
?.
addListener
(
_valueChangeHandler
);
assert
(
_mode
!=
null
);
}
...
...
@@ -479,14 +478,13 @@ class TrainHoppingAnimation extends Animation<double>
break
;
}
if
(
hop
)
{
_currentTrain
.
removeStatusListener
(
_statusChangeHandler
);
_currentTrain
.
removeListener
(
_valueChangeHandler
);
_currentTrain
..
removeStatusListener
(
_statusChangeHandler
)
..
removeListener
(
_valueChangeHandler
);
_currentTrain
=
_nextTrain
;
// TODO(hixie): This should be setting a status listener on the next
// train, not a value listener, and it should pass in _statusChangeHandler,
// not _valueChangeHandler
_nextTrain
.
addListener
(
_valueChangeHandler
);
_statusChangeHandler
(
_nextTrain
.
status
);
_nextTrain
=
null
;
_currentTrain
.
addStatusListener
(
_statusChangeHandler
);
_statusChangeHandler
(
_currentTrain
.
status
);
}
}
double
newValue
=
value
;
...
...
@@ -510,10 +508,8 @@ class TrainHoppingAnimation extends Animation<double>
_currentTrain
.
removeStatusListener
(
_statusChangeHandler
);
_currentTrain
.
removeListener
(
_valueChangeHandler
);
_currentTrain
=
null
;
if
(
_nextTrain
!=
null
)
{
_nextTrain
.
removeListener
(
_valueChangeHandler
);
_nextTrain
=
null
;
}
_nextTrain
?.
removeListener
(
_valueChangeHandler
);
_nextTrain
=
null
;
}
@override
...
...
packages/flutter/test/animation/animations_test.dart
View file @
05eef4a9
...
...
@@ -15,9 +15,30 @@ void main() {
test
(
'toString control test'
,
()
{
expect
(
kAlwaysCompleteAnimation
.
toString
(),
isOneLineDescription
);
expect
(
kAlwaysDismissedAnimation
.
toString
(),
isOneLineDescription
);
expect
(
new
AlwaysStoppedAnimation
<
double
>(
0.5
).
toString
(),
isOneLineDescription
);
CurvedAnimation
curvedAnimation
=
new
CurvedAnimation
(
parent:
kAlwaysDismissedAnimation
,
curve:
Curves
.
ease
);
expect
(
curvedAnimation
.
toString
(),
isOneLineDescription
);
curvedAnimation
.
reverseCurve
=
Curves
.
elasticOut
;
expect
(
curvedAnimation
.
toString
(),
isOneLineDescription
);
AnimationController
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
500
)
);
controller
..
value
=
0.5
..
reverse
();
curvedAnimation
=
new
CurvedAnimation
(
parent:
controller
,
curve:
Curves
.
ease
,
reverseCurve:
Curves
.
elasticOut
);
expect
(
curvedAnimation
.
toString
(),
isOneLineDescription
);
controller
.
stop
();
});
test
(
'toString control test'
,
()
{
test
(
'
ProxyAnimation.
toString control test'
,
()
{
ProxyAnimation
animation
=
new
ProxyAnimation
();
expect
(
animation
.
value
,
0.0
);
expect
(
animation
.
status
,
AnimationStatus
.
dismissed
);
...
...
@@ -25,4 +46,61 @@ void main() {
animation
.
parent
=
kAlwaysDismissedAnimation
;
expect
(
animation
.
toString
(),
isOneLineDescription
);
});
test
(
'ProxyAnimation set parent generates value changed'
,
()
{
AnimationController
controller
=
new
AnimationController
();
controller
.
value
=
0.5
;
bool
didReceiveCallback
=
false
;
ProxyAnimation
animation
=
new
ProxyAnimation
()
..
addListener
(()
{
didReceiveCallback
=
true
;
});
expect
(
didReceiveCallback
,
isFalse
);
animation
.
parent
=
controller
;
expect
(
didReceiveCallback
,
isTrue
);
didReceiveCallback
=
false
;
expect
(
didReceiveCallback
,
isFalse
);
controller
.
value
=
0.6
;
expect
(
didReceiveCallback
,
isTrue
);
});
test
(
'ReverseAnimation calls listeners'
,
()
{
AnimationController
controller
=
new
AnimationController
();
controller
.
value
=
0.5
;
bool
didReceiveCallback
=
false
;
void
listener
()
{
didReceiveCallback
=
true
;
}
ReverseAnimation
animation
=
new
ReverseAnimation
(
controller
)
..
addListener
(
listener
);
expect
(
didReceiveCallback
,
isFalse
);
controller
.
value
=
0.6
;
expect
(
didReceiveCallback
,
isTrue
);
didReceiveCallback
=
false
;
animation
.
removeListener
(
listener
);
expect
(
didReceiveCallback
,
isFalse
);
controller
.
value
=
0.7
;
expect
(
didReceiveCallback
,
isFalse
);
expect
(
animation
.
toString
(),
isOneLineDescription
);
});
test
(
'TrainHoppingAnimation'
,
()
{
AnimationController
currentTrain
=
new
AnimationController
();
AnimationController
nextTrain
=
new
AnimationController
();
currentTrain
.
value
=
0.5
;
nextTrain
.
value
=
0.75
;
bool
didSwitchTrains
=
false
;
TrainHoppingAnimation
animation
=
new
TrainHoppingAnimation
(
currentTrain
,
nextTrain
,
onSwitchedTrain:
()
{
didSwitchTrains
=
true
;
});
expect
(
didSwitchTrains
,
isFalse
);
expect
(
animation
.
value
,
0.5
);
expect
(
animation
.
toString
(),
isOneLineDescription
);
nextTrain
.
value
=
0.25
;
expect
(
didSwitchTrains
,
isTrue
);
expect
(
animation
.
value
,
0.25
);
expect
(
animation
.
toString
(),
isOneLineDescription
);
expect
(
animation
.
toString
(),
contains
(
'no next'
));
});
}
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