semantics_8_test.dart 2.2 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:ui' show SemanticsFlags;

7 8 9 10
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

11
import 'semantics_tester.dart';
12 13

void main() {
14
  testWidgets('Semantics 8 - Merging with reset', (WidgetTester tester) async {
15
    final SemanticsTester semantics = new SemanticsTester(tester);
16

17
    await tester.pumpWidget(
18 19 20
      new MergeSemantics(
        child: new Semantics(
          container: true,
21 22
          child: new Semantics(
            container: true,
23
            child: new Stack(
24
              textDirection: TextDirection.ltr,
25
              children: <Widget>[
26
                const Semantics(
Ian Hickson's avatar
Ian Hickson committed
27
                  checked: true,
28
                ),
29
                const Semantics(
Ian Hickson's avatar
Ian Hickson committed
30 31
                  label: 'label',
                  textDirection: TextDirection.ltr,
32 33
                )
              ]
34 35 36
            )
          )
        )
37 38
      )
    );
39 40

    expect(semantics, hasSemantics(
41
      new TestSemantics.root(
42 43
        flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
        label: 'label',
Ian Hickson's avatar
Ian Hickson committed
44
        textDirection: TextDirection.ltr,
45 46
      )
    ));
47

48
    // switch the order of the inner Semantics node to trigger a reset
49
    await tester.pumpWidget(
50 51 52
      new MergeSemantics(
        child: new Semantics(
          container: true,
53 54
          child: new Semantics(
            container: true,
55
            child: new Stack(
56
              textDirection: TextDirection.ltr,
57
              children: <Widget>[
58
                const Semantics(
Ian Hickson's avatar
Ian Hickson committed
59 60
                  label: 'label',
                  textDirection: TextDirection.ltr,
61
                ),
62
                const Semantics(
63 64 65
                  checked: true
                )
              ]
66 67 68
            )
          )
        )
69 70
      )
    );
71 72

    expect(semantics, hasSemantics(
73
      new TestSemantics.root(
74 75
        flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
        label: 'label',
Ian Hickson's avatar
Ian Hickson committed
76
        textDirection: TextDirection.ltr,
77 78 79 80
      )
    ));

    semantics.dispose();
81 82
  });
}