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
0
Merge Requests
0
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
eb1d61ce
Commit
eb1d61ce
authored
Feb 24, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test case
parent
26e82a00
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
3 deletions
+110
-3
pubspec.yaml
pubspec.yaml
+1
-0
test/lib/unit/container_coordinator_test.dart
test/lib/unit/container_coordinator_test.dart
+109
-3
No files found.
pubspec.yaml
View file @
eb1d61ce
...
...
@@ -16,6 +16,7 @@ dev_dependencies:
flutter_test
:
sdk
:
flutter
mockito
:
4.1.1
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
...
...
test/lib/unit/container_coordinator_test.dart
View file @
eb1d61ce
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'dart:ui'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:flutter_boost/channel/boost_channel.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'dart:typed_data'
;
class
MockBoostChannel
extends
BoostChannel
implements
Mock
{
MethodHandler
get
testHandler
=>
_testHandler
;
EventListener
get
testEventListener
=>
_testEventListener
;
MethodHandler
_testHandler
;
EventListener
_testEventListener
;
VoidCallback
addEventListener
(
String
name
,
EventListener
listener
)
{
_testEventListener
=
listener
;
super
.
addEventListener
(
name
,
listener
);
}
VoidCallback
addMethodHandler
(
MethodHandler
handler
)
{
_testHandler
=
handler
;
super
.
addMethodHandler
(
handler
);
}
}
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
const
MessageCodec
<
dynamic
>
jsonMessage
=
JSONMessageCodec
();
test
(
'test onMethodCall'
,
()
async
{
// Initialize all bindings because defaultBinaryMessenger.send() needs a window.
TestWidgetsFlutterBinding
.
ensureInitialized
();
MockBoostChannel
boostChannel
=
MockBoostChannel
();
ContainerCoordinator
(
boostChannel
);
final
Map
arguments
=
{};
arguments
[
"pageName"
]
=
"pageName"
;
arguments
[
"params"
]
=
{};
arguments
[
"uniqueId"
]
=
"xxxxx"
;
MethodCall
call
=
MethodCall
(
'didInitPageContainer'
,
arguments
);
try
{
boostChannel
.
testHandler
(
call
);
}
catch
(
e
)
{
expect
(
e
,
isAssertionError
);
}
MethodCall
call2
=
MethodCall
(
'willShowPageContainer'
,
arguments
);
try
{
boostChannel
.
testHandler
(
call2
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
MethodCall
call3
=
MethodCall
(
'didShowPageContainer'
,
arguments
);
try
{
boostChannel
.
testHandler
(
call3
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
MethodCall
call4
=
MethodCall
(
'willDisappearPageContainer'
,
arguments
);
try
{
boostChannel
.
testHandler
(
call4
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
MethodCall
call5
=
MethodCall
(
'onNativePageResult'
,
arguments
);
try
{
boostChannel
.
testHandler
(
call5
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
Map
arg
=
{
'type'
:
'backPressedCallback'
};
try
{
boostChannel
.
testEventListener
(
"lifecycle"
,
arg
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
Map
arg2
=
{
'type'
:
'foreground'
};
try
{
boostChannel
.
testEventListener
(
"lifecycle"
,
arg2
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
group
(
'container_coordinator'
,
()
{
Map
arg3
=
{
'type'
:
'background'
};
try
{
boostChannel
.
testEventListener
(
"lifecycle"
,
arg3
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
Map
arg4
=
{
'type'
:
'scheduleFrame'
};
try
{
boostChannel
.
testEventListener
(
"lifecycle"
,
arg4
);
}
catch
(
e
)
{
expect
(
e
,
isNoSuchMethodError
);
}
});
}
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