semantics_5_test.dart 1.37 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
Hixie's avatar
Hixie committed
2 3 4 5 6 7 8
// 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 'semantics_tester.dart';
Hixie's avatar
Hixie committed
10 11

void main() {
12
  testWidgets('Semantics 5', (WidgetTester tester) async {
13
    final SemanticsTester semantics = SemanticsTester(tester);
Hixie's avatar
Hixie committed
14

15
    await tester.pumpWidget(
16
      Stack(
17
        textDirection: TextDirection.ltr,
18
        fit: StackFit.expand,
19
        children: <Widget>[
20
          Semantics(
21 22
            // this tests that empty nodes disappear
          ),
23
          Semantics(
24
            // this tests whether you can have a container with no other semantics
25
            container: true,
26
          ),
27
          Semantics(
28
            label: 'label', // (force a fork)
Ian Hickson's avatar
Ian Hickson committed
29
            textDirection: TextDirection.ltr,
30
          ),
31
        ],
32
      ),
33
    );
34 35

    expect(semantics, hasSemantics(
36
      TestSemantics.root(
37
        children: <TestSemantics>[
38
          TestSemantics.rootChild(
39
            id: 1,
40
            rect: TestSemantics.fullScreen,
41
          ),
42
          TestSemantics.rootChild(
43 44
            id: 2,
            label: 'label',
45
            rect: TestSemantics.fullScreen,
46
          ),
47 48
        ],
      ),
49 50 51
    ));

    semantics.dispose();
Hixie's avatar
Hixie committed
52 53
  });
}