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
11869d5e
Commit
11869d5e
authored
Feb 20, 2020
by
Vadaski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add boost_page_route test
- boost_page_route_test.dart test `of` and `tryOf` method
parent
d0dae876
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
test/lib/unit/boost_page_route_test.dart
test/lib/unit/boost_page_route_test.dart
+127
-0
No files found.
test/lib/unit/boost_page_route_test.dart
View file @
11869d5e
...
...
@@ -44,4 +44,131 @@ void main() {
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
});
group
(
'Try to get the BoostPageRoute in the ancestor node'
,
()
{
testWidgets
(
'obtain BoostPageRoute through the `BoostPageRoute.of(context)` method'
,
(
WidgetTester
tester
)
async
{
var
boostPageRoute
;
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
boostPageRoute
=
BoostPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
of
(
context
);
},
);
},
),
);
return
boostPageRoute
;
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
// The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect
(
boostPageRoute
,
boostPageRouteFindByOfMethod
);
});
testWidgets
(
'try to find BoostPageRoute through the `BoostPageRoute.of(context)` method, '
'but it doesn
\'
t exist, the method should throw an Exception'
,
(
WidgetTester
tester
)
async
{
var
contextCache
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
(
settings:
settings
,
builder:
(
context
)
=>
Builder
(
builder:
(
context
)
=>
FloatingActionButton
(
onPressed:
()
{
contextCache
=
context
;
},
),
),
);
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
expect
(()
=>
BoostPageRoute
.
of
(
contextCache
),
throwsException
);
});
testWidgets
(
'obtain BoostPageRoute through the `BoostPageRoute.tryOf(context)` method'
,
(
WidgetTester
tester
)
async
{
var
boostPageRoute
;
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
boostPageRoute
=
BoostPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
tryOf
(
context
);
},
);
},
),
);
return
boostPageRoute
;
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
// The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect
(
boostPageRoute
,
boostPageRouteFindByOfMethod
);
});
});
testWidgets
(
'try to find BoostPageRoute through the `BoostPageRoute.tryOf(context)` method, '
'but it doesn
\'
t exist, the method should return null'
,
(
WidgetTester
tester
)
async
{
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
tryOf
(
context
);
},
);
},
),
);
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
expect
(
boostPageRouteFindByOfMethod
,
null
);
});
}
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