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
00c9e326
Commit
00c9e326
authored
Mar 09, 2017
by
Hans Muller
Committed by
GitHub
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Additional Hero tests: destination moves midflight (#8668)
parent
a97eb121
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
0 deletions
+161
-0
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+161
-0
No files found.
packages/flutter/test/widgets/heroes_test.dart
View file @
00c9e326
...
...
@@ -643,4 +643,165 @@ void main() {
expect
(
finalHeight
,
100.0
);
});
testWidgets
(
'Destination hero scrolls mid-flight'
,
(
WidgetTester
tester
)
async
{
final
Key
homeHeroKey
=
const
Key
(
'home hero'
);
final
Key
routeHeroKey
=
const
Key
(
'route hero'
);
final
Key
routeContainerKey
=
const
Key
(
'route hero container'
);
// 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
SizedBox
(
height:
100.0
),
// This container will appear at Y=100
new
Container
(
key:
routeContainerKey
,
child:
new
Hero
(
tag:
'H'
,
child:
new
Container
(
key:
routeHeroKey
,
height:
200.0
,
width:
200.0
))
),
new
FlatButton
(
child:
new
Text
(
'POP'
),
onPressed:
()
{
Navigator
.
pop
(
context
);
}
),
new
SizedBox
(
height:
600.0
),
],
)
);
},
);
// 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
SizedBox
(
height:
200.0
),
// This container will appear at Y=200
new
Container
(
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
);
}
),
new
SizedBox
(
height:
600.0
),
],
);
},
),
),
)
);
// Pushes route
await
tester
.
tap
(
find
.
text
(
'PUSH'
));
await
tester
.
pump
();
await
tester
.
pump
();
final
double
initialY
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
initialY
,
200.0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
final
double
yAt100ms
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
yAt100ms
,
lessThan
(
200.0
));
expect
(
yAt100ms
,
greaterThan
(
100.0
));
// Scroll the target upwards by 25 pixels. The Hero flight's Y coordinate
// will be redirected from 100 to 75.
await
(
tester
.
scroll
(
find
.
byKey
(
routeContainerKey
),
const
Offset
(
0.0
,
-
25.0
)));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
final
double
yAt110ms
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
yAt110ms
,
lessThan
(
yAt100ms
));
expect
(
yAt110ms
,
greaterThan
(
75.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
await
tester
.
pump
();
final
double
finalHeroY
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
finalHeroY
,
75.0
);
// 100 less 25 for the scroll
});
testWidgets
(
'Destination hero scrolls out of view mid-flight'
,
(
WidgetTester
tester
)
async
{
final
Key
homeHeroKey
=
const
Key
(
'home hero'
);
final
Key
routeHeroKey
=
const
Key
(
'route hero'
);
final
Key
routeContainerKey
=
const
Key
(
'route hero container'
);
// 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
SizedBox
(
height:
100.0
),
// This container will appear at Y=100
new
Container
(
key:
routeContainerKey
,
child:
new
Hero
(
tag:
'H'
,
child:
new
Container
(
key:
routeHeroKey
,
height:
200.0
,
width:
200.0
))
),
new
SizedBox
(
height:
800.0
),
],
)
);
},
);
// 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
SizedBox
(
height:
200.0
),
// This container will appear at Y=200
new
Container
(
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
initialY
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
initialY
,
200.0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
final
double
yAt100ms
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
yAt100ms
,
lessThan
(
200.0
));
expect
(
yAt100ms
,
greaterThan
(
100.0
));
await
(
tester
.
scroll
(
find
.
byKey
(
routeContainerKey
),
const
Offset
(
0.0
,
-
400.0
)));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
find
.
byKey
(
routeContainerKey
),
findsNothing
);
// Scrolled off the top
// Flight continues (the hero will fade out) even though the destination
// no longer exists.
final
double
yAt110ms
=
tester
.
getTopLeft
(
find
.
byKey
(
routeHeroKey
)).
y
;
expect
(
yAt110ms
,
lessThan
(
yAt100ms
));
expect
(
yAt110ms
,
greaterThan
(
100.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
await
tester
.
pump
();
expect
(
find
.
byKey
(
routeHeroKey
),
findsNothing
);
});
}
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