run_app_test.dart 828 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8 9 10 11 12
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async {
    await tester.pumpWidget(
13
      Directionality(
14
        textDirection: TextDirection.ltr,
15
        child: Material(
16
          child: ElevatedButton(
17 18 19
            onPressed: () {
              runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr,)));
            },
20 21 22
            child: const Text('GO'),
          ),
        ),
23
      ),
24 25 26 27 28
    );
    await tester.tap(find.text('GO'));
    expect(find.text('Done'), findsOneWidget);
  });
}