custom_semantics_action_test.dart 1.12 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'package:flutter/semantics.dart';
6
import 'package:flutter_test/flutter_test.dart';
7

8 9 10 11
void main() {
  group(CustomSemanticsAction, () {

    test('is provided a canonical id based on the label', () {
12 13 14
      final CustomSemanticsAction action1 = CustomSemanticsAction(label: _nonconst('test'));
      final CustomSemanticsAction action2 = CustomSemanticsAction(label: _nonconst('test'));
      final CustomSemanticsAction action3 = CustomSemanticsAction(label: _nonconst('not test'));
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
      final int id1 = CustomSemanticsAction.getIdentifier(action1);
      final int id2 = CustomSemanticsAction.getIdentifier(action2);
      final int id3 = CustomSemanticsAction.getIdentifier(action3);

      expect(id1, id2);
      expect(id2, isNot(id3));
      expect(CustomSemanticsAction.getAction(id1), action1);
      expect(CustomSemanticsAction.getAction(id2), action1);
      expect(CustomSemanticsAction.getAction(id3), action3);
    });

  });
}

T _nonconst<T>(T value) => value;