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
0b6b39b3
Unverified
Commit
0b6b39b3
authored
Mar 06, 2019
by
xster
Committed by
GitHub
Mar 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move material iOS back swipe test to material (#28855)
parent
11678da3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
12 deletions
+94
-12
README.md
packages/flutter/test/cupertino/README.md
+7
-0
route_test.dart
packages/flutter/test/cupertino/route_test.dart
+11
-12
page_test.dart
packages/flutter/test/material/page_test.dart
+76
-0
No files found.
packages/flutter/test/cupertino/README.md
0 → 100644
View file @
0b6b39b3
# Tests for the Cupertino package
Avoid importing the Material 'package:flutter/material.dart' in these tests as
we're trying to test the Cupertino package in standalone scenarios.
Some tests may be replicated in the Material tests when Material reuses
Cupertino components on iOS such as page transitions and text editing.
packages/flutter/test/cupertino/route_test.dart
View file @
0b6b39b3
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -256,20 +255,20 @@ void main() {
});
testWidgets
(
'Back swipe dismiss interrupted by route push'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/28728
final
GlobalKey
scaffoldKey
=
GlobalKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Scaffold
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
key:
scaffoldKey
,
body
:
Center
(
child:
Raised
Button
(
child
:
Center
(
child:
Cupertino
Button
(
onPressed:
()
{
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
Material
PageRoute
<
void
>(
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
Cupertino
PageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Scaffold
(
body
:
Center
(
child:
Text
(
'route'
)),
return
const
CupertinoPage
Scaffold
(
child
:
Center
(
child:
Text
(
'route'
)),
);
},
));
...
...
@@ -294,17 +293,17 @@ void main() {
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
// The 'route' route has been dragged to the right, halfway across the screen
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'route'
),
matching:
find
.
byType
(
Scaffold
))),
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'route'
),
matching:
find
.
byType
(
CupertinoPage
Scaffold
))),
const
Offset
(
400
,
0
),
);
expect
(
// The 'push' route is sliding in from the left.
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
Scaffold
))).
dx
,
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
CupertinoPage
Scaffold
))).
dx
,
lessThan
(
0
),
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'push'
),
findsOneWidget
);
expect
(
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
Scaffold
))),
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
CupertinoPage
Scaffold
))),
Offset
.
zero
,
);
expect
(
find
.
text
(
'route'
),
findsNothing
);
...
...
packages/flutter/test/material/page_test.dart
View file @
0b6b39b3
...
...
@@ -540,4 +540,80 @@ void main() {
expect
(
find
.
text
(
'Page 1'
),
isOnstage
);
expect
(
find
.
text
(
'Page 2'
),
findsNothing
);
});
testWidgets
(
'Back swipe dismiss interrupted by route push'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/28728
final
GlobalKey
scaffoldKey
=
GlobalKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Scaffold
(
key:
scaffoldKey
,
body:
Center
(
child:
RaisedButton
(
onPressed:
()
{
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Scaffold
(
body:
Center
(
child:
Text
(
'route'
)),
);
},
));
},
child:
const
Text
(
'push'
),
),
),
),
),
);
// Check the basic iOS back-swipe dismiss transition. Dragging the pushed
// route halfway across the screen will trigger the iOS dismiss animation
await
tester
.
tap
(
find
.
text
(
'push'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
findsNothing
);
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
300
));
await
gesture
.
moveBy
(
const
Offset
(
400
,
0
));
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
// The 'route' route has been dragged to the right, halfway across the screen
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'route'
),
matching:
find
.
byType
(
Scaffold
))),
const
Offset
(
400
,
0
),
);
expect
(
// The 'push' route is sliding in from the left.
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
Scaffold
))).
dx
,
lessThan
(
0
),
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'push'
),
findsOneWidget
);
expect
(
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'push'
),
matching:
find
.
byType
(
Scaffold
))),
Offset
.
zero
,
);
expect
(
find
.
text
(
'route'
),
findsNothing
);
// Run the dismiss animation 75%, which exposes the route "push" button,
// and then press the button. MaterialPageTransition duration is 300ms,
// 275 = 300 * 0.75.
await
tester
.
tap
(
find
.
text
(
'push'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
findsNothing
);
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
300
));
await
gesture
.
moveBy
(
const
Offset
(
400
,
0
));
// drag halfway
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
275
));
// partially dismiss "route"
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
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