2019-11-27 15:04:02 -08:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2016-10-03 12:00:01 -07:00
|
|
|
// 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_gallery/gallery/app.dart';
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
2019-12-05 21:33:07 +01:00
|
|
|
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
2016-10-03 12:00:01 -07:00
|
|
|
if (binding is LiveTestWidgetsFlutterBinding)
|
2017-04-12 13:33:02 -07:00
|
|
|
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
2016-10-03 12:00:01 -07:00
|
|
|
|
|
|
|
|
testWidgets('Flutter gallery button example code displays', (WidgetTester tester) async {
|
|
|
|
|
// Regression test for https://github.com/flutter/flutter/issues/6147
|
|
|
|
|
|
2018-05-16 11:42:39 -07:00
|
|
|
await tester.pumpWidget(const GalleryApp(testMode: true));
|
2016-10-03 12:00:01 -07:00
|
|
|
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
|
|
|
|
await tester.pump(); // triggers a frame
|
|
|
|
|
|
2018-04-30 08:23:11 -07:00
|
|
|
await Scrollable.ensureVisible(tester.element(find.text('Material')), alignment: 0.5);
|
2018-04-27 08:11:20 -07:00
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
await tester.tap(find.text('Material'));
|
|
|
|
|
await tester.pumpAndSettle();
|
2016-10-03 12:00:01 -07:00
|
|
|
|
|
|
|
|
// Launch the buttons demo and then prove that showing the example
|
|
|
|
|
// code dialog does not crash.
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Buttons'));
|
2018-04-27 08:11:20 -07:00
|
|
|
await tester.pumpAndSettle();
|
2016-10-03 12:00:01 -07:00
|
|
|
|
2016-10-03 12:52:06 -07:00
|
|
|
await tester.tap(find.byTooltip('Show example code'));
|
2016-10-03 12:00:01 -07:00
|
|
|
await tester.pump(); // start animation
|
|
|
|
|
await tester.pump(const Duration(seconds: 1)); // end animation
|
|
|
|
|
|
|
|
|
|
expect(find.text('Example code'), findsOneWidget);
|
|
|
|
|
});
|
|
|
|
|
}
|