Commit 622e4396 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add tests for nested contexts (#7197)

This tests against the failure that was fixed in #7189
parent 1155f966
......@@ -94,7 +94,7 @@ Future<Null> main(List<String> args) async {
AppContext _executableContext = new AppContext();
// Make the context current.
_executableContext.runInZone(() {
await _executableContext.runInZone(() {
// Initialize the context with some defaults.
// NOTE: Similar lists also exist in `bin/fuchsia_builder.dart` and
// `test/src/context.dart`. If you update this list of defaults, look
......
......@@ -59,7 +59,7 @@ class AppContext {
: parentContext;
}
dynamic runInZone(dynamic method(), {
Future<dynamic> runInZone(dynamic method(), {
ZoneBinaryCallback<dynamic, dynamic, StackTrace> onError
}) {
return runZoned(
......@@ -69,7 +69,7 @@ class AppContext {
);
}
dynamic _run(dynamic method()) async {
Future<dynamic> _run(dynamic method()) async {
Zone previousZone = _zone;
try {
_zone = Zone.current;
......
......@@ -8,7 +8,7 @@ import 'package:flutter_tools/src/globals.dart';
import 'package:test/test.dart';
void main() {
group('DeviceManager', () {
group('AppContext', () {
test('error', () async {
AppContext context = new AppContext();
BufferLogger mockLogger = new BufferLogger();
......@@ -50,5 +50,31 @@ void main() {
expect(mockLogger.statusText, '');
expect(mockLogger.traceText, 'foo bar\n');
});
test('awaitNestedZones', () async {
AppContext outerContext = new AppContext();
await outerContext.runInZone(() async {
AppContext middleContext = new AppContext();
await middleContext.runInZone(() async {
AppContext innerContext = new AppContext();
await innerContext.runInZone(() async {
expect(innerContext.getVariable(String), isNull);
});
});
});
});
test('fireAndForgetNestedZones', () async {
AppContext outerContext = new AppContext();
outerContext.runInZone(() async {
AppContext middleContext = new AppContext();
middleContext.runInZone(() async {
AppContext innerContext = new AppContext();
innerContext.runInZone(() async {
expect(innerContext.getVariable(String), isNull);
});
});
});
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment