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
7d7ac629
Commit
7d7ac629
authored
Feb 20, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test case
parent
47c27577
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
490 additions
and
38 deletions
+490
-38
test/lib/unit/flutter_boost_test.dart
test/lib/unit/flutter_boost_test.dart
+83
-38
test/lib/unit/page_widgets.dart
test/lib/unit/page_widgets.dart
+407
-0
No files found.
test/lib/unit/flutter_boost_test.dart
View file @
7d7ac629
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'page_widgets.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
void
main
(
)
{
class
MyApp
extends
StatefulWidget
{
const
MethodChannel
channel
=
MethodChannel
(
'flutter_boost'
);
@override
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
_MyAppState
createState
()
=>
_MyAppState
();
dynamic
response
;
}
channel
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
print
(
methodCall
);
log
.
add
(
methodCall
);
return
response
;
});
tearDown
(()
{
class
_MyAppState
extends
State
<
MyApp
>
{
log
.
clear
();
@override
});
void
initState
()
{
super
.
initState
();
FlutterBoost
.
singleton
.
registerPageBuilders
({
'embeded'
:
(
pageName
,
params
,
_
)
=>
EmbededFirstRouteWidget
(),
'first'
:
(
pageName
,
params
,
_
)
=>
FirstRouteWidget
(),
'second'
:
(
pageName
,
params
,
_
)
=>
SecondRouteWidget
(),
'tab'
:
(
pageName
,
params
,
_
)
=>
TabRouteWidget
(),
'flutterFragment'
:
(
pageName
,
params
,
_
)
=>
FragmentRouteWidget
(
params
),
'flutterPage'
:
(
pageName
,
params
,
_
)
{
print
(
"flutterPage params:
$params
"
);
return
FlutterRouteWidget
(
params:
params
);
},
});
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Flutter Boost example'
,
builder:
FlutterBoost
.
init
(
postPush:
_onRoutePushed
),
home:
Container
());
}
void
_onRoutePushed
(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{}
}
class
TestBoostNavigatorObserver
extends
NavigatorObserver
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didPush"
);
}
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didPop"
);
}
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didRemove"
);
}
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
print
(
"flutterboost#didReplace"
);
}
}
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
TestWidgetsFlutterBinding
.
ensureInitialized
();
group
(
'flutter_boost'
,
()
{
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
response
=
null
;
(
WidgetTester
tester
)
async
{
//push app
await
tester
.
pumpWidget
(
MyApp
(),
);
test
(
'init successfully'
,
()
async
{
//open firt page
Function
builder
=
FlutterBoost
.
init
();
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"first"
,
{},
"1000000"
);
expect
(
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
builder
.
runtimeType
,
TransitionBuilder
,
);
});
test
(
'open successfully'
,
()
async
{
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
Future
<
Map
<
dynamic
,
dynamic
>>
result
=
FlutterBoost
.
singleton
.
open
(
"url"
);
expect
(
//open second page
result
,
ContainerCoordinator
.
singleton
isInstanceOf
<
Future
<
Map
<
dynamic
,
dynamic
>>>(),
.
nativeContainerDidShow
(
"second"
,
{},
"2000000"
);
);
});
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
//close sencod page
FlutterBoost
.
containerManager
?.
remove
(
"2000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// test('close successfully', () async {
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
// Future<bool> result = FlutterBoost.singleton.close("id");
//
// expect(
// result,
// isInstanceOf<bool>(),
// );
// });
});
});
...
...
test/lib/unit/page_widgets.dart
0 → 100755
View file @
7d7ac629
This diff is collapsed.
Click to expand it.
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