Add test for AppContext (#7465)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/context.dart' hide context;
|
||||
import 'package:flutter_tools/src/base/context.dart' as pkg;
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/globals.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -76,5 +77,26 @@ void main() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('overriddenValuesInNestedZones', () async {
|
||||
expect(pkg.context, isNull);
|
||||
AppContext outerContext = new AppContext();
|
||||
outerContext.setVariable(String, 'outer');
|
||||
outerContext.runInZone(() async {
|
||||
expect(pkg.context[String], 'outer');
|
||||
AppContext middleContext = new AppContext();
|
||||
middleContext.setVariable(String, 'middle');
|
||||
middleContext.runInZone(() async {
|
||||
expect(pkg.context[String], 'middle');
|
||||
AppContext innerContext = new AppContext();
|
||||
innerContext.setVariable(String, 'inner');
|
||||
innerContext.runInZone(() async {
|
||||
expect(pkg.context[String], 'inner');
|
||||
});
|
||||
expect(pkg.context[String], 'middle');
|
||||
});
|
||||
expect(pkg.context[String], 'outer');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user