semantics_5_test.dart 1.7 KB
Newer Older
Hixie's avatar
Hixie committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 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';
import 'package:test/test.dart';

import 'test_semantics.dart';

void main() {
  test('Semantics 5', () {
    testWidgets((WidgetTester tester) {
15
      TestSemanticsListener client = new TestSemanticsListener();
Hixie's avatar
Hixie committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

      tester.pumpWidget(
        new Stack(
          children: <Widget>[
            new Semantics(
              // this tests that empty nodes disappear
            ),
            new Semantics(
              // this tests whether you can have a container with no other semantics
              container: true
            ),
            new Semantics(
              label: 'label' // (force a fork)
            ),
          ]
        )
      );
      expect(client.updates.length, equals(2));
      expect(client.updates[0].id, equals(0));
      expect(client.updates[0].flags.hasCheckedState, isFalse);
      expect(client.updates[0].strings.label, equals(''));
      expect(client.updates[0].children.length, equals(2));
      expect(client.updates[0].children[0].id, equals(1));
      expect(client.updates[0].children[0].flags.hasCheckedState, isFalse);
      expect(client.updates[0].children[0].strings.label, equals(''));
      expect(client.updates[0].children[1].id, equals(2));
      expect(client.updates[0].children[1].flags.hasCheckedState, isFalse);
      expect(client.updates[0].children[1].strings.label, equals('label'));
      expect(client.updates[1], isNull);
      client.updates.clear();

    });
  });
}