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
4304a694
Commit
4304a694
authored
Feb 24, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test
parent
1c38e078
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
169 additions
and
153 deletions
+169
-153
test/lib/boost_test.dart
test/lib/boost_test.dart
+0
-25
test/lib/unit/flutter_boost_test.dart
test/lib/unit/flutter_boost_test.dart
+20
-128
test/lib/unit/page_widget_test.dart
test/lib/unit/page_widget_test.dart
+149
-0
No files found.
test/lib/boost_test.dart
deleted
100644 → 0
View file @
1c38e078
import
'package:flutter_test/flutter_test.dart'
;
import
'unit/boost_channel_test.dart'
as
boost_channel
;
//import 'unit/boost_container_test.dart' as boost_container;
import
'unit/boost_page_route_test.dart'
as
boost_page_route
;
import
'unit/container_coordinator_test.dart'
as
container_coordinator
;
import
'unit/container_manager_test.dart'
as
container_manager
;
import
'unit/flutter_boost_test.dart'
as
flutter_boost
;
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
// group('all_test', () {
// boost_channel.main();
//// boost_container.main();
// boost_page_route.main();
// container_coordinator.main();
// container_manager.main();
// flutter_boost.main();
// });
}
test/lib/unit/flutter_boost_test.dart
View file @
4304a694
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_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'page_widgets.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@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
(
)
{
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
TestWidgetsFlutterBinding
.
ensureInitialized
();
...
@@ -67,84 +9,34 @@ void main() {
...
@@ -67,84 +9,34 @@ void main() {
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
//push app
//push app
await
tester
.
pumpWidget
(
});
MyApp
(),
);
//open firt page
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"first"
,
{},
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
//open second page firt(1000000)->second(2000000)
ContainerCoordinator
.
singleton
.
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 firt(1000000)
FlutterBoost
.
containerManager
?.
remove
(
"2000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
// second page ,but pageId is 2000001 firt(1000000)->second(2000001)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"second"
,
{},
"2000001"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
//reopen firt page second(2000001)->firt(1000000)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"first"
,
{},
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
//reopen firt page second(2000001)->firt(1000000)
// reopen second page and pageId is 2000001 firt(1000000)->second(2000001)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"second"
,
{},
"2000001"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
//close firt(1000000) page second(2000001)
FlutterBoost
.
containerManager
?.
remove
(
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
test
(
'test onMethodCall'
,
()
async
{
// open second(2000003)
FlutterBoost
.
singleton
.
registerDefaultPageBuilder
((
pageName
,
params
,
_
)
=>
Container
());
ContainerCoordinator
.
singleton
try
{
.
nativeContainerDidShow
(
"second"
,
{},
"2000003"
);
FlutterBoost
.
singleton
.
open
(
"url"
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
try
{
FlutterBoost
.
singleton
.
close
(
"url"
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
try
{
FlutterBoost
.
singleton
.
close
(
"closeCurrent"
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
await
tester
.
idle
();
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
});
});
}
}
test/lib/unit/page_widget_test.dart
0 → 100644
View file @
4304a694
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'page_widgets.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@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
();
testWidgets
(
'test iOS edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
//push app
await
tester
.
pumpWidget
(
MyApp
(),
);
//open firt page
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"first"
,
{},
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
//open second page firt(1000000)->second(2000000)
ContainerCoordinator
.
singleton
.
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 firt(1000000)
FlutterBoost
.
containerManager
?.
remove
(
"2000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
// second page ,but pageId is 2000001 firt(1000000)->second(2000001)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"second"
,
{},
"2000001"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
//reopen firt page second(2000001)->firt(1000000)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"first"
,
{},
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'First'
),
findsOneWidget
);
//reopen firt page second(2000001)->firt(1000000)
// reopen second page and pageId is 2000001 firt(1000000)->second(2000001)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"second"
,
{},
"2000001"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
//close firt(1000000) page second(2000001)
FlutterBoost
.
containerManager
?.
remove
(
"1000000"
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Second'
),
findsOneWidget
);
// open second(2000003)
ContainerCoordinator
.
singleton
.
nativeContainerDidShow
(
"second"
,
{},
"2000003"
);
await
tester
.
idle
();
expect
(
find
.
text
(
'Second'
),
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