config_test_utils.dart 866 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter_test/flutter_test.dart';

void testConfig(
  String description,
11
  String? expectedStringValue, {
12
  Map<Type, dynamic> otherExpectedValues = const <Type, dynamic>{int: isNull},
13
}) {
14
  final String? actualStringValue = Zone.current[String] as String?;
15 16
  final Map<Type, dynamic> otherActualValues = otherExpectedValues.map<Type, dynamic>(
    (Type key, dynamic value) {
17
      return MapEntry<Type, dynamic>(key, Zone.current[key]);
18 19 20 21 22
    },
  );

  test(description, () {
    expect(actualStringValue, expectedStringValue);
23
    for (final Type key in otherExpectedValues.keys) {
24 25 26 27
      expect(otherActualValues[key], otherExpectedValues[key]);
    }
  });
}