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
0d958f03
Commit
0d958f03
authored
Mar 07, 2017
by
Hans Muller
Committed by
GitHub
Mar 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a hero test (#8629)
parent
81b81d30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
1 deletion
+104
-1
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+104
-1
No files found.
packages/flutter/test/widgets/heroes_test.dart
View file @
0d958f03
...
...
@@ -180,7 +180,7 @@ void main() {
expect
(
find
.
byKey
(
thirdKey
),
isInCard
);
});
testWidgets
(
'
Heroes animate
'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
Destination hero is rebuilt midflight
'
,
(
WidgetTester
tester
)
async
{
final
MutatingRoute
route
=
new
MutatingRoute
();
await
tester
.
pumpWidget
(
new
MaterialApp
(
...
...
@@ -540,4 +540,107 @@ void main() {
expect
(
find
.
byKey
(
secondKey
),
isInCard
);
expect
(
find
.
byKey
(
firstKey
),
findsNothing
);
});
testWidgets
(
'Destination hero disappears mid-flight'
,
(
WidgetTester
tester
)
async
{
final
Key
homeHeroKey
=
const
Key
(
'home hero'
);
final
Key
routeHeroKey
=
const
Key
(
'route hero'
);
bool
routeIncludesHero
=
true
;
StateSetter
heroCardSetState
;
// Show a 200x200 Hero tagged 'H', with key routeHeroKey
final
MaterialPageRoute
<
Null
>
route
=
new
MaterialPageRoute
<
Null
>(
builder:
(
BuildContext
context
)
{
return
new
Material
(
child:
new
ListView
(
children:
<
Widget
>[
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
heroCardSetState
=
setState
;
return
new
Card
(
child:
routeIncludesHero
?
new
Hero
(
tag:
'H'
,
child:
new
Container
(
key:
routeHeroKey
,
height:
200.0
,
width:
200.0
))
:
new
Container
(
height:
200.0
,
width:
200.0
),
);
},
),
new
FlatButton
(
child:
new
Text
(
'POP'
),
onPressed:
()
{
Navigator
.
pop
(
context
);
}
),
],
)
);
},
);
// Show a 100x100 Hero tagged 'H' with key homeHeroKey
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
body:
new
Builder
(
builder:
(
BuildContext
context
)
{
// Navigator.push() needs context
return
new
ListView
(
children:
<
Widget
>
[
new
Card
(
child:
new
Hero
(
tag:
'H'
,
child:
new
Container
(
key:
homeHeroKey
,
height:
100.0
,
width:
100.0
)),
),
new
FlatButton
(
child:
new
Text
(
'PUSH'
),
onPressed:
()
{
Navigator
.
push
(
context
,
route
);
}
),
],
);
},
),
),
)
);
// Pushes route
await
tester
.
tap
(
find
.
text
(
'PUSH'
));
await
tester
.
pump
();
await
tester
.
pump
();
final
double
initialHeight
=
tester
.
getSize
(
find
.
byKey
(
routeHeroKey
)).
height
;
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
double
midflightHeight
=
tester
.
getSize
(
find
.
byKey
(
routeHeroKey
)).
height
;
expect
(
midflightHeight
,
greaterThan
(
initialHeight
));
expect
(
midflightHeight
,
lessThan
(
200.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
await
tester
.
pump
();
double
finalHeight
=
tester
.
getSize
(
find
.
byKey
(
routeHeroKey
)).
height
;
expect
(
finalHeight
,
200.0
);
// Complete the flight
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
// Rebuild route with its Hero
heroCardSetState
(()
{
routeIncludesHero
=
true
;
});
await
tester
.
pump
();
// Pops route
await
tester
.
tap
(
find
.
text
(
'POP'
));
await
tester
.
pump
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
midflightHeight
=
tester
.
getSize
(
find
.
byKey
(
homeHeroKey
)).
height
;
expect
(
midflightHeight
,
lessThan
(
finalHeight
));
expect
(
midflightHeight
,
greaterThan
(
100.0
));
// Remove the destination hero midlfight
heroCardSetState
(()
{
routeIncludesHero
=
false
;
});
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
finalHeight
=
tester
.
getSize
(
find
.
byKey
(
homeHeroKey
)).
height
;
expect
(
finalHeight
,
100.0
);
});
}
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