semantics_8_test.dart 2.9 KB
Newer Older
1 2 3 4 5 6 7 8
// 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.

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

9
import '../rendering/test_semantics_client.dart';
10 11

void main() {
12
  testWidgets('Semantics 8 - Merging with reset', (WidgetTester tester) async {
13
    TestSemanticsClient client = new TestSemanticsClient(tester.binding.pipelineOwner);
14

15
    await tester.pumpWidget(
16 17 18
      new MergeSemantics(
        child: new Semantics(
          container: true,
19 20
          child: new Semantics(
            container: true,
21 22 23 24 25 26 27 28 29
            child: new Stack(
              children: <Widget>[
                new Semantics(
                  checked: true
                ),
                new Semantics(
                  label: 'label'
                )
              ]
30 31 32
            )
          )
        )
33 34
      )
    );
35
    expect(client.updates.length, equals(1));
36
    expect(client.updates[0].id, equals(0));
37
    expect(client.updates[0].actions, isEmpty);
38 39 40 41 42 43 44 45 46 47
    expect(client.updates[0].flags.hasCheckedState, isTrue);
    expect(client.updates[0].flags.isChecked, isTrue);
    expect(client.updates[0].strings.label, equals('label'));
    expect(client.updates[0].geometry.transform, isNull);
    expect(client.updates[0].geometry.left, equals(0.0));
    expect(client.updates[0].geometry.top, equals(0.0));
    expect(client.updates[0].geometry.width, equals(800.0));
    expect(client.updates[0].geometry.height, equals(600.0));
    expect(client.updates[0].children.length, equals(0));
    client.updates.clear();
48

49
    // switch the order of the inner Semantics node to trigger a reset
50
    await tester.pumpWidget(
51 52 53
      new MergeSemantics(
        child: new Semantics(
          container: true,
54 55
          child: new Semantics(
            container: true,
56 57 58 59 60 61 62 63 64
            child: new Stack(
              children: <Widget>[
                new Semantics(
                  label: 'label'
                ),
                new Semantics(
                  checked: true
                )
              ]
65 66 67
            )
          )
        )
68 69
      )
    );
70
    expect(client.updates.length, equals(1));
71
    expect(client.updates[0].id, equals(0));
72
    expect(client.updates[0].actions, isEmpty);
73 74 75 76 77 78 79 80 81 82
    expect(client.updates[0].flags.hasCheckedState, isTrue);
    expect(client.updates[0].flags.isChecked, isTrue);
    expect(client.updates[0].strings.label, equals('label'));
    expect(client.updates[0].geometry.transform, isNull);
    expect(client.updates[0].geometry.left, equals(0.0));
    expect(client.updates[0].geometry.top, equals(0.0));
    expect(client.updates[0].geometry.width, equals(800.0));
    expect(client.updates[0].geometry.height, equals(600.0));
    expect(client.updates[0].children.length, equals(0));
    client.updates.clear();
83
    client.dispose();
84 85
  });
}