mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Added GalleryApp testMode (#17640)
This commit is contained in:
parent
0cbda7d68d
commit
580c844c2f
|
@ -25,6 +25,7 @@ class GalleryApp extends StatefulWidget {
|
|||
this.enableRasterCacheImagesCheckerboard: true,
|
||||
this.enableOffscreenLayersCheckerboard: true,
|
||||
this.onSendFeedback,
|
||||
this.testMode: false,
|
||||
}) : super(key: key);
|
||||
|
||||
final UpdateUrlFetcher updateUrlFetcher;
|
||||
|
@ -32,6 +33,7 @@ class GalleryApp extends StatefulWidget {
|
|||
final bool enableRasterCacheImagesCheckerboard;
|
||||
final bool enableOffscreenLayersCheckerboard;
|
||||
final VoidCallback onSendFeedback;
|
||||
final bool testMode;
|
||||
|
||||
@override
|
||||
_GalleryAppState createState() => new _GalleryAppState();
|
||||
|
@ -107,6 +109,7 @@ class _GalleryAppState extends State<GalleryApp> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget home = new GalleryHome(
|
||||
testMode: widget.testMode,
|
||||
optionsPage: new GalleryOptionsPage(
|
||||
options: _options,
|
||||
onOptionsChanged: _handleOptionsChanged,
|
||||
|
|
|
@ -263,13 +263,11 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
|||
end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0),
|
||||
).animate(_controller);
|
||||
|
||||
return new Stack(
|
||||
key: _backdropKey,
|
||||
children: <Widget>[
|
||||
final List<Widget> layers = <Widget>[
|
||||
// Back layer
|
||||
new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
// Back layer
|
||||
new _BackAppBar(
|
||||
leading: widget.frontAction,
|
||||
title: new _CrossFadeTransition(
|
||||
|
@ -323,6 +321,14 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
|||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
// The front "heading" is a (typically transparent) widget that's stacked on
|
||||
// top of, and at the top of, the front layer. It adds support for dragging
|
||||
// the front layer up and down and for opening and closing the front layer
|
||||
// with a tap. It may obscure part of the front layer's topmost child.
|
||||
if (widget.frontHeading != null) {
|
||||
layers.add(
|
||||
new PositionedTransition(
|
||||
rect: frontRelativeRect,
|
||||
child: new ExcludeSemantics(
|
||||
|
@ -338,7 +344,12 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
|||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return new Stack(
|
||||
key: _backdropKey,
|
||||
children: layers,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,10 +270,12 @@ class GalleryHome extends StatefulWidget {
|
|||
|
||||
const GalleryHome({
|
||||
Key key,
|
||||
this.testMode: false,
|
||||
this.optionsPage,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget optionsPage;
|
||||
final bool testMode;
|
||||
|
||||
@override
|
||||
_GalleryHomeState createState() => new _GalleryHomeState();
|
||||
|
@ -351,7 +353,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
|||
? const Text('Flutter gallery')
|
||||
: new Text(_category.name),
|
||||
),
|
||||
frontHeading: new Container(height: 24.0),
|
||||
frontHeading: widget.testMode ? null: new Container(height: 24.0),
|
||||
frontLayer: new AnimatedSwitcher(
|
||||
duration: _kFrontLayerSwitchDuration,
|
||||
switchOutCurve: switchOutCurve,
|
||||
|
|
|
@ -17,6 +17,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(
|
||||
new GalleryApp(
|
||||
testMode: true,
|
||||
onSendFeedback: () {
|
||||
hasFeedback = true;
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@ void main() {
|
|||
testWidgets('Flutter gallery button example code displays', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/6147
|
||||
|
||||
await tester.pumpWidget(const GalleryApp());
|
||||
await tester.pumpWidget(const GalleryApp(testMode: true));
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ Future<Null> main() async {
|
|||
if (!new Set<String>.from(allDemoTitles).containsAll(_kSkippedDemoTitles))
|
||||
fail('Unrecognized demo names in _kSkippedDemoTitles: $_kSkippedDemoTitles');
|
||||
|
||||
runApp(const GalleryApp());
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
final _LiveWidgetController controller = new _LiveWidgetController();
|
||||
for (GalleryDemoCategory category in kAllGalleryDemoCategories) {
|
||||
await controller.tap(find.text(category.name));
|
||||
|
|
|
@ -19,7 +19,7 @@ void main() {
|
|||
child: const SizedBox(
|
||||
width: 450.0,
|
||||
height: 800.0,
|
||||
child: const GalleryApp()
|
||||
child: const GalleryApp(testMode: true)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -43,7 +43,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Pesto can be scrolled all the way down', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const GalleryApp());
|
||||
await tester.pumpWidget(const GalleryApp(testMode: true));
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/main.dart' as flutter_gallery_main;
|
||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
@ -12,7 +12,9 @@ void main() {
|
|||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
testWidgets('Flutter Gallery app simple smoke test', (WidgetTester tester) async {
|
||||
flutter_gallery_main.main(); // builds the app and schedules a frame but doesn't trigger one
|
||||
await tester.pumpWidget(
|
||||
const GalleryApp(testMode: true) // builds the app and schedules a frame but doesn't trigger one
|
||||
);
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ Future<Null> smokeGallery(WidgetTester tester) async {
|
|||
|
||||
await tester.pumpWidget(
|
||||
new GalleryApp(
|
||||
testMode: true,
|
||||
onSendFeedback: () {
|
||||
sendFeedbackButtonPressed = true; // see smokeOptionsPage()
|
||||
},
|
||||
|
|
|
@ -17,7 +17,12 @@ void main() {
|
|||
|
||||
// Regression test for https://github.com/flutter/flutter/pull/5168
|
||||
testWidgets('update dialog', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const GalleryApp(updateUrlFetcher: mockUpdateUrlFetcher));
|
||||
await tester.pumpWidget(
|
||||
const GalleryApp(
|
||||
testMode: true,
|
||||
updateUrlFetcher: mockUpdateUrlFetcher
|
||||
)
|
||||
);
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_gallery/main.dart' as app;
|
||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
// As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736
|
||||
// for better visual effect at the cost of performance.
|
||||
MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
}
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_gallery/main.dart' as app;
|
||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
// As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736
|
||||
// for better visual effect at the cost of performance.
|
||||
MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import 'dart:convert' show JsonEncoder;
|
|||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:flutter_gallery/gallery/demos.dart';
|
||||
import 'package:flutter_gallery/main.dart' as app;
|
||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<String> _handleMessages(String message) async {
|
||||
assert(message == 'demoNames');
|
||||
|
@ -18,5 +19,8 @@ Future<String> _handleMessages(String message) async {
|
|||
|
||||
void main() {
|
||||
enableFlutterDriverExtension(handler: _handleMessages);
|
||||
app.main();
|
||||
// As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736
|
||||
// for better visual effect at the cost of performance.
|
||||
MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use
|
||||
runApp(const GalleryApp(testMode: true));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue