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
d709f18c
Commit
d709f18c
authored
Mar 30, 2017
by
Ian Hickson
Committed by
GitHub
Mar 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not swallow exceptions in guarded functions. (#9064)
parent
a94e995f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
14 deletions
+23
-14
refresh_indicator_test.dart
packages/flutter/test/material/refresh_indicator_test.dart
+1
-1
controller.dart
packages/flutter_test/lib/src/controller.dart
+1
-0
test_async_utils.dart
packages/flutter_test/lib/src/test_async_utils.dart
+5
-2
test_pointer.dart
packages/flutter_test/lib/src/test_pointer.dart
+5
-5
test_async_utils_test.dart
packages/flutter_test/test/test_async_utils_test.dart
+11
-6
No files found.
packages/flutter/test/material/refresh_indicator_test.dart
View file @
d709f18c
...
...
@@ -88,7 +88,7 @@ void main() {
),
);
await
tester
.
fling
(
find
.
text
(
'X'
),
const
Offset
(
0.0
,
-
300.0
),
1000.0
);
await
tester
.
fling
(
find
.
text
(
'X'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
...
...
packages/flutter_test/lib/src/controller.dart
View file @
d709f18c
...
...
@@ -380,6 +380,7 @@ class WidgetController {
Future
<
Null
>
dragFrom
(
Point
startLocation
,
Offset
offset
,
{
int
pointer
})
{
return
TestAsyncUtils
.
guard
(()
async
{
final
TestGesture
gesture
=
await
startGesture
(
startLocation
,
pointer:
pointer
);
assert
(
gesture
!=
null
);
await
gesture
.
moveBy
(
offset
);
await
gesture
.
up
();
return
null
;
...
...
packages/flutter_test/lib/src/test_async_utils.dart
View file @
d709f18c
...
...
@@ -67,7 +67,7 @@ class TestAsyncUtils {
final
_AsyncScope
scope
=
new
_AsyncScope
(
StackTrace
.
current
,
zone
);
_scopeStack
.
add
(
scope
);
final
Future
<
Null
>
result
=
scope
.
zone
.
run
(
body
);
void
completionHandler
(
dynamic
error
,
StackTrace
stack
)
{
Future
<
Null
>
completionHandler
(
dynamic
error
,
StackTrace
stack
)
{
assert
(
_scopeStack
.
isNotEmpty
);
assert
(
_scopeStack
.
contains
(
scope
));
bool
leaked
=
false
;
...
...
@@ -101,10 +101,13 @@ class TestAsyncUtils {
}
throw
new
FlutterError
(
message
.
toString
().
trimRight
());
}
if
(
error
!=
null
)
return
new
Future
<
Null
>.
error
(
error
,
stack
);
return
new
Future
<
Null
>.
value
(
null
);
}
return
result
.
then
<
Null
>(
(
Null
value
)
{
completionHandler
(
null
,
null
);
return
completionHandler
(
null
,
null
);
},
onError:
completionHandler
);
...
...
packages/flutter_test/lib/src/test_pointer.dart
View file @
d709f18c
...
...
@@ -140,9 +140,8 @@ class TestGesture {
})
async
{
assert
(
hitTester
!=
null
);
assert
(
dispatcher
!=
null
);
final
Completer
<
TestGesture
>
completer
=
new
Completer
<
TestGesture
>();
TestGesture
result
;
TestAsyncUtils
.
guard
(()
async
{
return
TestAsyncUtils
.
guard
(()
async
{
// dispatch down event
final
HitTestResult
hitTestResult
=
hitTester
(
downLocation
);
final
TestPointer
testPointer
=
new
TestPointer
(
pointer
);
...
...
@@ -151,10 +150,11 @@ class TestGesture {
// create a TestGesture
result
=
new
TestGesture
.
_
(
dispatcher
,
hitTestResult
,
testPointer
);
return
null
;
}).
whenComplete
(()
{
completer
.
complete
(
result
);
}).
then
<
TestGesture
>((
Null
value
)
{
return
result
;
},
onError:
(
dynamic
error
,
StackTrace
stack
)
{
return
new
Future
<
TestGesture
>.
error
(
error
,
stack
);
});
return
completer
.
future
;
}
final
EventDispatcher
_dispatcher
;
...
...
packages/flutter_test/test/test_async_utils_test.dart
View file @
d709f18c
...
...
@@ -27,13 +27,9 @@ class TestAPISubclass extends TestAPI {
}
}
Future
<
Null
>
helperFunction
(
WidgetTester
tester
)
async
{
await
tester
.
pump
();
}
Future
<
Null
>
guardedHelper
(
WidgetTester
tester
)
{
Future
<
Null
>
_guardedThrower
()
{
return
TestAsyncUtils
.
guard
(()
async
{
await
tester
.
pumpWidget
(
new
Text
(
'Hello'
))
;
throw
'Hello'
;
});
}
...
...
@@ -174,5 +170,14 @@ void main() {
await
f1
;
});
testWidgets
(
'TestAsyncUtils - guard body can throw'
,
(
WidgetTester
tester
)
async
{
try
{
await
_guardedThrower
();
expect
(
false
,
true
);
// _guardedThrower should throw and we shouldn't reach here
}
on
String
catch
(
s
)
{
expect
(
s
,
'Hello'
);
}
});
// see also dev/manual_tests/test_data which contains tests run by the flutter_tools tests for 'flutter test'
}
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