semantics_5_test.dart 1.46 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
// 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';
8
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
Hixie's avatar
Hixie committed
9

10
import 'semantics_tester.dart';
Hixie's avatar
Hixie committed
11 12

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

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

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

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