update_icons_test.dart 3.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:test/test.dart';

import '../update_icons.dart';

Map<String, String> codepointsA = <String, String>{
  'airplane': '111',
  'boat': '222',
};
Map<String, String> codepointsB = <String, String>{
  'airplane': '333',
};
Map<String, String> codepointsC = <String, String>{
  'airplane': '111',
  'train': '444',
};
20 21 22
Map<String, String> codepointsUnderscore = <String, String>{
  'airplane__123': '111',
};
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

void main() {
  group('safety checks', () {
    test('superset', () {
      expect(testIsSuperset(codepointsA, codepointsA), true);

      expect(testIsSuperset(codepointsA, codepointsB), true);
      expect(testIsSuperset(codepointsB, codepointsA), false);
    });
    test('stability', () {
      expect(testIsStable(codepointsA, codepointsA), true);

      expect(testIsStable(codepointsA, codepointsB), false);
      expect(testIsStable(codepointsB, codepointsA), false);

      expect(testIsStable(codepointsA, codepointsC), true);
      expect(testIsStable(codepointsC, codepointsA), true);
    });
  });
42 43

  test('no double underscores', () {
44
    expect(Icon(codepointsUnderscore.entries.first).usage, 'Icon(Icons.airplane_123),');
45
  });
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

  test('usage string is correct', () {
    expect(
      Icon(const MapEntry<String, String>('abc', '')).usage,
      'Icon(Icons.abc),',
    );
  });

  test('usage string is correct with replacement', () {
    expect(
      Icon(const MapEntry<String, String>('123', '')).usage,
      'Icon(Icons.onetwothree),',
    );
    expect(
      Icon(const MapEntry<String, String>('123_rounded', '')).usage,
      'Icon(Icons.onetwothree_rounded),',
    );
  });
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

  test('certain icons should be mirrored in RTL', () {
    // Exact match
    expect(
      Icon(const MapEntry<String, String>('help', '')).isMirroredInRTL,
      true,
    );
    // Variant
    expect(
      Icon(const MapEntry<String, String>('help_rounded', '')).isMirroredInRTL,
      true,
    );
    // Common suffixes
    expect(
      Icon(const MapEntry<String, String>('help_alt', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_new', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_off', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_on', '')).isMirroredInRTL,
      true,
    );
    // Common suffixes + variant
    expect(
      Icon(const MapEntry<String, String>('help_alt_rounded', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_new_rounded', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_off_rounded', '')).isMirroredInRTL,
      true,
    );
    expect(
      Icon(const MapEntry<String, String>('help_on_rounded', '')).isMirroredInRTL,
      true,
    );
    // No match
    expect(
      Icon(const MapEntry<String, String>('help_center_rounded', '')).isMirroredInRTL,
      false,
    );
    // No match
    expect(
      Icon(const MapEntry<String, String>('arrow', '')).isMirroredInRTL,
      false,
    );
  });
121
}