Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_boost_1.22.4
Commits
9e07e9f2
Commit
9e07e9f2
authored
Feb 18, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test
parent
5a70c578
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
164 additions
and
23 deletions
+164
-23
test/lib/unit/boost_container_test.dart
test/lib/unit/boost_container_test.dart
+17
-17
test/lib/unit/boost_page_route_test.dart
test/lib/unit/boost_page_route_test.dart
+39
-4
test/lib/unit/container_coordinator_test.dart
test/lib/unit/container_coordinator_test.dart
+1
-0
test/lib/unit/container_manager_test.dart
test/lib/unit/container_manager_test.dart
+107
-2
No files found.
test/lib/unit/boost_container_test.dart
View file @
9e07e9f2
...
...
@@ -166,7 +166,7 @@ void main() {
// ),
// SizedBox(
// height: 300.0,
// child:
BoostContaine
r(
// child:
Navigato
r(
// onGenerateRoute: (RouteSettings settings) {
// if (settings.isInitialRoute) {
// return MaterialPageRoute<void>(
...
...
@@ -174,13 +174,13 @@ void main() {
// return RaisedButton(
// child: const Text('Next'),
// onPressed: () {
//
Navigato
r.of(context).push(
//
BoostContaine
r.of(context).push(
// MaterialPageRoute<void>(
// builder: (BuildContext context) {
// return RaisedButton(
// child: const Text('Inner page'),
// onPressed: () {
//
Navigator.of(context, rootNavigator: true
)
//
BoostContainer.of(context
)
// .push(
// MaterialPageRoute<void>(
// builder: (BuildContext context) {
...
...
@@ -204,21 +204,21 @@ void main() {
// ),
// ),
// ));
//
// await tester.tap(find.text('Next'));
// await tester.pump();
// await tester.pump(const Duration(milliseconds: 300));
//
//
//
//
await tester.tap(find.text('Next'));
//
//
await tester.pump();
//
//
await tester.pump(const Duration(milliseconds: 300));
//
// // Both elements are on screen.
// expect(
tester.getTopLeft(find.text('Root page')).dy, 0.0
);
// expect(tester.getTopLeft(find.text('Inner page')).dy, greaterThan(300.0));
//
// await tester.tap(find.text('Inner page'));
// await tester.pump();
// await tester.pump(const Duration(milliseconds: 300));
//
// // Dialog is pushed to the whole page and is at the top of the screen, not
// // inside the inner page.
// expect(tester.getTopLeft(find.text('Dialog')).dy, 0.0);
// expect(
find.text('Next'), findsOneWidget
);
//
//
expect(tester.getTopLeft(find.text('Inner page')).dy, greaterThan(300.0));
//
//
//
//
await tester.tap(find.text('Inner page'));
//
//
await tester.pump();
//
//
await tester.pump(const Duration(milliseconds: 300));
//
//
//
//
// Dialog is pushed to the whole page and is at the top of the screen, not
//
//
// inside the inner page.
//
//
expect(tester.getTopLeft(find.text('Dialog')).dy, 0.0);
// });
}
test/lib/unit/boost_page_route_test.dart
View file @
9e07e9f2
import
'package:flutter_boost/container/boost_page_route.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
group
(
'boost_page_route'
,
()
{
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
onGenerateRoute:
(
RouteSettings
settings
)
{
return
BoostPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
{
final
String
pageNumber
=
settings
.
name
==
'/'
?
'1'
:
'2'
;
return
Center
(
child:
Text
(
'Page
$pageNumber
'
));
},
);
},
),
);
});
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pushNamed
(
'/next'
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
}
\ No newline at end of file
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
200
));
await
gesture
.
moveBy
(
const
Offset
(
300
,
0
));
await
tester
.
pump
();
// Bring it exactly back such that there's nothing to animate when releasing.
await
gesture
.
moveBy
(
const
Offset
(-
300
,
0
));
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
});
}
test/lib/unit/container_coordinator_test.dart
View file @
9e07e9f2
...
...
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
group
(
'container_coordinator'
,
()
{
...
...
test/lib/unit/container_manager_test.dart
View file @
9e07e9f2
...
...
@@ -2,10 +2,115 @@ import 'package:flutter_boost/container/container_manager.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
final
GlobalKey
scaffoldKey
=
GlobalKey
();
class
FirstRouteWidget
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'First Route'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
RaisedButton
(
child:
Text
(
'First'
),
onPressed:
()
{
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
)
{
print
(
"call me when page is finished. did recieve second route result
$value
"
);
});
},
),
],
),
),
);
}
}
class
SecondRouteWidget
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Second Route'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
RaisedButton
(
child:
Text
(
'Second'
),
onPressed:
()
{
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
)
{
print
(
"call me when page is finished. did recieve second route result
$value
"
);
});
},
),
],
),
),
);
}
}
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@override
void
initState
()
{
super
.
initState
();
FlutterBoost
.
singleton
.
registerPageBuilders
({
'first'
:
(
pageName
,
params
,
_
)
=>
FirstRouteWidget
(),
'second'
:
(
pageName
,
params
,
_
)
=>
SecondRouteWidget
(),
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Flutter Boost example'
,
key:
scaffoldKey
,
builder:
(
BuildContext
context
,
Widget
child
)
{
assert
(
child
is
Navigator
,
'child must be Navigator, what is wrong?'
);
final
BoostContainerManager
manager
=
BoostContainerManager
(
initNavigator:
child
,
);
return
manager
;
},
home:
Container
());
}
void
_onRoutePushed
(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{}
}
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MyApp
());
group
(
'container_manager'
,
()
{
// Navigator.pushNamed(scaffoldKey.currentContext, "first");
expect
(
find
.
text
(
'First'
),
findsNothing
);
});
}
\ No newline at end of file
}
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