run_app_test.dart 908 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// 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
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
8 9

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