desktop_text_selection_toolbar_test.dart 991 Bytes
Newer Older
1 2 3 4 5 6
// Copyright 2014 The Flutter 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_test/flutter_test.dart';
7

8 9 10
void main() {
  TestWidgetsFlutterBinding.ensureInitialized();

11
  testWidgets('positions itself at the anchor', (WidgetTester tester) async {
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    // An arbitrary point on the screen to position at.
    const Offset anchor = Offset(30.0, 40.0);

    await tester.pumpWidget(
      MaterialApp(
        home: Center(
          child: DesktopTextSelectionToolbar(
            anchor: anchor,
            children: <Widget>[
              DesktopTextSelectionToolbarButton(
                child: const Text('Tap me'),
                onPressed: () {},
              ),
            ],
          ),
        ),
      ),
    );

    expect(
      tester.getTopLeft(find.byType(DesktopTextSelectionToolbarButton)),
      anchor,
    );
  });
}