Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
330dc94c
Commit
330dc94c
authored
Apr 15, 2019
by
Dan Field
Committed by
Jonah Williams
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that ErrorWidget.builder is not modified after test (#30898)
parent
28cb589c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
error_widget_builder_test.dart
packages/flutter/test/widgets/error_widget_builder_test.dart
+2
-0
binding.dart
packages/flutter_test/lib/src/binding.dart
+17
-0
No files found.
packages/flutter/test/widgets/error_widget_builder_test.dart
View file @
330dc94c
...
...
@@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';
void
main
(
)
{
testWidgets
(
'ErrorWidget.builder'
,
(
WidgetTester
tester
)
async
{
final
ErrorWidgetBuilder
oldBuilder
=
ErrorWidget
.
builder
;
ErrorWidget
.
builder
=
(
FlutterErrorDetails
details
)
{
return
const
Text
(
'oopsie!'
,
textDirection:
TextDirection
.
ltr
);
};
...
...
@@ -21,5 +22,6 @@ void main() {
);
expect
(
tester
.
takeException
().
toString
(),
'test'
);
expect
(
find
.
text
(
'oopsie!'
),
findsOneWidget
);
ErrorWidget
.
builder
=
oldBuilder
;
});
}
packages/flutter_test/lib/src/binding.dart
View file @
330dc94c
...
...
@@ -584,6 +584,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
final
bool
autoUpdateGoldensBeforeTest
=
autoUpdateGoldenFiles
;
final
TestExceptionReporter
reportTestExceptionBeforeTest
=
reportTestException
;
final
ErrorWidgetBuilder
errorWidgetBuilderBeforeTest
=
ErrorWidget
.
builder
;
// run the test
await
testBody
();
...
...
@@ -598,6 +599,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
invariantTester
();
_verifyAutoUpdateGoldensUnset
(
autoUpdateGoldensBeforeTest
);
_verifyReportTestExceptionUnset
(
reportTestExceptionBeforeTest
);
_verifyErrorWidgetBuilderUnset
(
errorWidgetBuilderBeforeTest
);
_verifyInvariants
();
}
...
...
@@ -667,6 +669,21 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
}());
}
void
_verifyErrorWidgetBuilderUnset
(
ErrorWidgetBuilder
valueBeforeTest
)
{
assert
(()
{
if
(
ErrorWidget
.
builder
!=
valueBeforeTest
)
{
FlutterError
.
reportError
(
FlutterErrorDetails
(
exception:
FlutterError
(
'The value of ErrorWidget.builder was changed by the test.'
,
),
stack:
StackTrace
.
current
,
library
:
'Flutter test framework'
,
));
}
return
true
;
}());
}
/// Called by the [testWidgets] function after a test is executed.
void
postTest
()
{
assert
(
inTest
);
...
...
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