semantics_8_test.dart 1.92 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
    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 24 25 26 27 28 29 30 31
            child: new Stack(
              children: <Widget>[
                new Semantics(
                  checked: true
                ),
                new Semantics(
                  label: 'label'
                )
              ]
32 33 34
            )
          )
        )
35 36
      )
    );
37 38 39 40 41 42 43 44

    expect(semantics, hasSemantics(
      new TestSemantics(
        id: 0,
        flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
        label: 'label',
      )
    ));
45

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

    expect(semantics, hasSemantics(
      new TestSemantics(
        id: 0,
        flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
        label: 'label',
      )
    ));

    semantics.dispose();
77 78
  });
}