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
ed037a8a
Commit
ed037a8a
authored
Feb 18, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test and travis tool
parent
abb58ad6
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
491 additions
and
0 deletions
+491
-0
.travis.yml
.travis.yml
+21
-0
pubspec.yaml
pubspec.yaml
+5
-0
test/lib/boost_unit_test.dart
test/lib/boost_unit_test.dart
+26
-0
test/lib/boost_widget_test.dart
test/lib/boost_widget_test.dart
+0
-0
test/lib/unit/boost_channel_test.dart
test/lib/unit/boost_channel_test.dart
+108
-0
test/lib/unit/boost_container_test.dart
test/lib/unit/boost_container_test.dart
+224
-0
test/lib/unit/boost_page_route_test.dart
test/lib/unit/boost_page_route_test.dart
+12
-0
test/lib/unit/container_coordinator_test.dart
test/lib/unit/container_coordinator_test.dart
+11
-0
test/lib/unit/container_manager_test.dart
test/lib/unit/container_manager_test.dart
+11
-0
test/lib/unit/flutter_boost_test.dart
test/lib/unit/flutter_boost_test.dart
+12
-0
test/pubspec.yaml
test/pubspec.yaml
+61
-0
No files found.
.travis.yml
0 → 100644
View file @
ed037a8a
os
:
-
linux
sudo
:
false
addons
:
apt
:
sources
:
-
ubuntu-toolchain-r-test
packages
:
-
libstdc++6
# - fonts-droid
before_script
:
-
git clone https://github.com/flutter/flutter.git -b v1.9.1-hotfixes --depth
1
-
./flutter/bin/flutter doctor
script
:
-
./flutter/bin/flutter test --coverage --coverage-path=lcov.info
after_success
:
-
bash <(curl -s https://codecov.io/bash)
cache
:
directories
:
-
$HOME/.pub-cache
pubspec.yaml
View file @
ed037a8a
...
...
@@ -12,6 +12,11 @@ dependencies:
sdk
:
flutter
dev_dependencies
:
flutter_test
:
sdk
:
flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
...
...
test/lib/boost_unit_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_test/flutter_test.dart'
;
import
'package:boost_test/unit/boost_channel_test.dart'
as
boost_channel
;
import
'package:boost_test/unit/boost_container_test.dart'
as
boost_container
;
import
'package:boost_test/unit/boost_page_route_test.dart'
as
boost_page_route
;
import
'package:boost_test/unit/container_coordinator_test.dart'
as
container_coordinator
;
import
'package:boost_test/unit/container_manager_test.dart'
as
container_manager
;
import
'package:boost_test/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/boost_widget_test.dart
0 → 100644
View file @
ed037a8a
test/lib/unit/boost_channel_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_boost/channel/boost_channel.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
const
MethodChannel
channel
=
MethodChannel
(
'flutter_boost'
);
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
dynamic
response
;
channel
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
print
(
methodCall
);
log
.
add
(
methodCall
);
return
response
;
});
tearDown
(()
{
log
.
clear
();
});
group
(
'boost_channel'
,
()
{
response
=
null
;
test
(
'sendEvent successfully'
,
()
async
{
Map
msg1
=
Map
();
BoostChannel
().
sendEvent
(
"name"
,
msg1
);
Map
msg
=
Map
();
msg
[
"name"
]
=
"name"
;
msg
[
"arguments"
]
=
msg1
;
expect
(
log
,
<
Matcher
>[
isMethodCall
(
'__event__'
,
arguments:
msg
)],
);
});
test
(
'invokeMethod successfully'
,
()
async
{
Map
msg
=
{};
msg
[
"test"
]
=
"test"
;
BoostChannel
().
invokeMethod
(
"__event__1"
,
msg
);
// expect(e, isException);
expect
(
log
,
<
Matcher
>[
isMethodCall
(
'__event__1'
,
arguments:
msg
)],
);
});
test
(
'invokeListMethod successfully'
,
()
async
{
Map
msg
=
{};
msg
[
"test"
]
=
"test"
;
var
bb
=
await
BoostChannel
().
invokeListMethod
(
"__event__1"
,
msg
);
expect
(
log
,
<
Matcher
>[
isMethodCall
(
'__event__1'
,
arguments:
msg
)],
);
});
test
(
'invokeMapMethod successfully'
,
()
async
{
Map
msg
=
{};
msg
[
"test"
]
=
"test"
;
BoostChannel
().
invokeMapMethod
(
"__event__1"
,
msg
);
expect
(
log
,
<
Matcher
>[
isMethodCall
(
'__event__1'
,
arguments:
msg
)],
);
});
test
(
'invokeMapMethod successfully'
,
()
async
{
Map
msg
=
{};
msg
[
"test"
]
=
"test"
;
BoostChannel
().
invokeMapMethod
(
"__event__1"
,
msg
);
expect
(
log
,
<
Matcher
>[
isMethodCall
(
'__event__1'
,
arguments:
msg
)],
);
});
test
(
'addEventListener successfully'
,
()
async
{
Function
test
=
BoostChannel
().
addEventListener
(
"addEventListener"
,
(
String
name
,
Map
arguments
)
async
=>
"test"
);
print
(
"xxx"
+
test
.
toString
());
expect
(
test
.
toString
(),
"Closure: () => Null"
,
);
});
test
(
'addMethodHandler successfully'
,
()
async
{
Function
test
=
BoostChannel
().
addMethodHandler
((
MethodCall
call
)
async
=>
"test"
);
expect
(
test
.
toString
(),
"Closure: () => Null"
,
);
});
});
}
test/lib/unit/boost_container_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_boost/container/boost_container.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
FirstWidget
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
{
Navigator
.
pushNamed
(
context
,
'/second'
);
},
child:
Container
(
color:
const
Color
(
0xFFFFFF00
),
child:
const
Text
(
'X'
),
),
);
}
}
class
SecondWidget
extends
StatefulWidget
{
@override
SecondWidgetState
createState
()
=>
SecondWidgetState
();
}
class
SecondWidgetState
extends
State
<
SecondWidget
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
onTap:
()
=>
Navigator
.
pop
(
context
),
child:
Container
(
color:
const
Color
(
0xFFFF00FF
),
child:
const
Text
(
'Y'
),
),
);
}
}
typedef
ExceptionCallback
=
void
Function
(
dynamic
exception
);
class
ThirdWidget
extends
StatelessWidget
{
const
ThirdWidget
({
this
.
targetKey
,
this
.
onException
});
final
Key
targetKey
;
final
ExceptionCallback
onException
;
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
key:
targetKey
,
onTap:
()
{
try
{
Navigator
.
of
(
context
);
}
catch
(
e
)
{
onException
(
e
);
}
},
behavior:
HitTestBehavior
.
opaque
,
);
}
}
class
OnTapPage
extends
StatelessWidget
{
const
OnTapPage
({
Key
key
,
this
.
id
,
this
.
onTap
})
:
super
(
key:
key
);
final
String
id
;
final
VoidCallback
onTap
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Page
$id
'
)),
body:
GestureDetector
(
onTap:
onTap
,
behavior:
HitTestBehavior
.
opaque
,
child:
Container
(
child:
Center
(
child:
Text
(
id
,
style:
Theme
.
of
(
context
).
textTheme
.
display2
),
),
),
),
);
}
}
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
testWidgets
(
'Can navigator navigate to and from a stateful widget'
,
(
WidgetTester
tester
)
async
{
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
FirstWidget
(),
// X
'/second'
:
(
BuildContext
context
)
=>
SecondWidget
(),
// Y
};
await
tester
.
pumpWidget
(
MaterialApp
(
routes:
routes
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
,
skipOffstage:
false
),
findsNothing
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pump
();
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
,
skipOffstage:
false
),
isOffstage
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'X'
),
findsNothing
);
expect
(
find
.
text
(
'X'
,
skipOffstage:
false
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Y'
));
expect
(
find
.
text
(
'X'
),
findsNothing
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
),
findsOneWidget
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'X'
),
findsOneWidget
);
expect
(
find
.
text
(
'Y'
,
skipOffstage:
false
),
findsNothing
);
});
//
testWidgets
(
'Navigator.of fails gracefully when not found in context'
,
(
WidgetTester
tester
)
async
{
const
Key
targetKey
=
Key
(
'foo'
);
dynamic
exception
;
final
Widget
widget
=
ThirdWidget
(
targetKey:
targetKey
,
onException:
(
dynamic
e
)
{
exception
=
e
;
},
);
await
tester
.
pumpWidget
(
widget
);
await
tester
.
tap
(
find
.
byKey
(
targetKey
));
expect
(
exception
,
isInstanceOf
<
FlutterError
>());
expect
(
'
$exception
'
,
startsWith
(
'Navigator operation requested with a context'
));
});
//
testWidgets
(
'Navigator.of rootNavigator finds root Navigator'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Column
(
children:
<
Widget
>[
const
SizedBox
(
height:
300.0
,
child:
Text
(
'Root page'
),
),
SizedBox
(
height:
300.0
,
child:
BoostContainer
(
onGenerateRoute:
(
RouteSettings
settings
)
{
if
(
settings
.
isInitialRoute
)
{
return
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
child:
const
Text
(
'Next'
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
RaisedButton
(
child:
const
Text
(
'Inner page'
),
onPressed:
()
{
Navigator
.
of
(
context
,
rootNavigator:
true
).
push
(
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Text
(
'Dialog'
);
}
),
);
},
);
}
),
);
},
);
},
);
}
return
null
;
},
),
),
],
),
),
));
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
);
});
}
\ No newline at end of file
test/lib/unit/boost_page_route_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_boost/container/boost_page_route.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'boost_page_route'
,
()
{
});
}
\ No newline at end of file
test/lib/unit/container_coordinator_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'container_coordinator'
,
()
{
});
}
\ No newline at end of file
test/lib/unit/container_manager_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_boost/container/container_manager.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'container_manager'
,
()
{
});
}
\ No newline at end of file
test/lib/unit/flutter_boost_test.dart
0 → 100644
View file @
ed037a8a
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
group
(
'boost_container'
,
()
{
});
}
\ No newline at end of file
test/pubspec.yaml
0 → 100644
View file @
ed037a8a
name
:
boost_test
description
:
A new Flutter package.
version
:
0.0.1
author
:
homepage
:
environment
:
sdk
:
'
>=2.2.0
<3.0.0'
dependencies
:
flutter
:
sdk
:
flutter
test
:
^1.5.1
dev_dependencies
:
flutter_test
:
sdk
:
flutter
flutter_driver
:
sdk
:
flutter
e2e
:
^0.2.1
mockito
:
4.1.1
flutter_boost
:
path
:
../
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter
:
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.io/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.io/custom-fonts/#from-packages
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