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
d1f4822e
Commit
d1f4822e
authored
Mar 17, 2017
by
Hans Muller
Committed by
GitHub
Mar 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Verify that stateful hero state persists mid-flight (#8817)
parent
d52c0a8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+94
-0
No files found.
packages/flutter/test/widgets/heroes_test.dart
View file @
d1f4822e
...
...
@@ -76,6 +76,18 @@ class MutatingRoute extends MaterialPageRoute<Null> {
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
MyStatefulWidget
({
Key
key
,
this
.
value
:
'123'
})
:
super
(
key:
key
);
final
String
value
;
@override
MyStatefulWidgetState
createState
()
=>
new
MyStatefulWidgetState
();
}
class
MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
@override
Widget
build
(
BuildContext
context
)
=>
new
Text
(
config
.
value
);
}
void
main
(
)
{
testWidgets
(
'Heroes animate'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -911,4 +923,86 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
heroBCKey
)).
y
,
0.0
);
});
testWidgets
(
'Stateful hero child state survives flight'
,
(
WidgetTester
tester
)
async
{
final
MaterialPageRoute
<
Null
>
route
=
new
MaterialPageRoute
<
Null
>(
builder:
(
BuildContext
context
)
{
return
new
Material
(
child:
new
ListView
(
children:
<
Widget
>[
new
Card
(
child:
new
Hero
(
tag:
'H'
,
child:
new
SizedBox
(
height:
200.0
,
child:
new
MyStatefulWidget
(
value:
'456'
),
),
),
),
new
FlatButton
(
child:
new
Text
(
'POP'
),
onPressed:
()
{
Navigator
.
pop
(
context
);
}
),
],
)
);
},
);
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
SizedBox
(
height:
100.0
,
child:
new
MyStatefulWidget
(
value:
'456'
),
),
),
),
new
FlatButton
(
child:
new
Text
(
'PUSH'
),
onPressed:
()
{
Navigator
.
push
(
context
,
route
);
}
),
],
);
},
),
),
)
);
expect
(
find
.
text
(
'456'
),
findsOneWidget
);
// Push route.
await
tester
.
tap
(
find
.
text
(
'PUSH'
));
await
tester
.
pump
();
await
tester
.
pump
();
// Push flight underway.
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
find
.
text
(
'456'
),
findsOneWidget
);
// Push flight finished.
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
expect
(
find
.
text
(
'456'
),
findsOneWidget
);
// Pop route.
await
tester
.
tap
(
find
.
text
(
'POP'
));
await
tester
.
pump
();
await
tester
.
pump
();
// Pop flight underway.
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
expect
(
find
.
text
(
'456'
),
findsOneWidget
);
// Pop flight finished
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
expect
(
find
.
text
(
'456'
),
findsOneWidget
);
});
}
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