From 719712b74c2f254ee2ef321c32413e1822fa191e Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Thu, 12 Jan 2017 09:31:27 -0800 Subject: [PATCH] Add test for AppContext (#7465) --- packages/flutter_tools/test/context_test.dart | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/flutter_tools/test/context_test.dart b/packages/flutter_tools/test/context_test.dart index a589528036..d6601233b0 100644 --- a/packages/flutter_tools/test/context_test.dart +++ b/packages/flutter_tools/test/context_test.dart @@ -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'); + }); + }); }); }