Unverified Commit 580c844c authored by Hans Muller's avatar Hans Muller Committed by GitHub

Added GalleryApp testMode (#17640)

parent 0cbda7d6
...@@ -25,6 +25,7 @@ class GalleryApp extends StatefulWidget { ...@@ -25,6 +25,7 @@ class GalleryApp extends StatefulWidget {
this.enableRasterCacheImagesCheckerboard: true, this.enableRasterCacheImagesCheckerboard: true,
this.enableOffscreenLayersCheckerboard: true, this.enableOffscreenLayersCheckerboard: true,
this.onSendFeedback, this.onSendFeedback,
this.testMode: false,
}) : super(key: key); }) : super(key: key);
final UpdateUrlFetcher updateUrlFetcher; final UpdateUrlFetcher updateUrlFetcher;
...@@ -32,6 +33,7 @@ class GalleryApp extends StatefulWidget { ...@@ -32,6 +33,7 @@ class GalleryApp extends StatefulWidget {
final bool enableRasterCacheImagesCheckerboard; final bool enableRasterCacheImagesCheckerboard;
final bool enableOffscreenLayersCheckerboard; final bool enableOffscreenLayersCheckerboard;
final VoidCallback onSendFeedback; final VoidCallback onSendFeedback;
final bool testMode;
@override @override
_GalleryAppState createState() => new _GalleryAppState(); _GalleryAppState createState() => new _GalleryAppState();
...@@ -107,6 +109,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -107,6 +109,7 @@ class _GalleryAppState extends State<GalleryApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget home = new GalleryHome( Widget home = new GalleryHome(
testMode: widget.testMode,
optionsPage: new GalleryOptionsPage( optionsPage: new GalleryOptionsPage(
options: _options, options: _options,
onOptionsChanged: _handleOptionsChanged, onOptionsChanged: _handleOptionsChanged,
......
...@@ -263,66 +263,72 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -263,66 +263,72 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0), end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0),
).animate(_controller); ).animate(_controller);
return new Stack( final List<Widget> layers = <Widget>[
key: _backdropKey, // Back layer
children: <Widget>[ new Column(
new Column( crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[
children: <Widget>[ new _BackAppBar(
// Back layer leading: widget.frontAction,
new _BackAppBar( title: new _CrossFadeTransition(
leading: widget.frontAction, progress: _controller,
title: new _CrossFadeTransition( alignment: AlignmentDirectional.centerStart,
progress: _controller, child0: new Semantics(namesRoute: true, child: widget.frontTitle),
alignment: AlignmentDirectional.centerStart, child1: new Semantics(namesRoute: true, child: widget.backTitle),
child0: new Semantics(namesRoute: true, child: widget.frontTitle),
child1: new Semantics(namesRoute: true, child: widget.backTitle),
),
trailing: new IconButton(
onPressed: _toggleFrontLayer,
tooltip: 'Toggle options page',
icon: new AnimatedIcon(
icon: AnimatedIcons.close_menu,
progress: _controller,
),
),
), ),
new Expanded( trailing: new IconButton(
child: new _TappableWhileStatusIs( onPressed: _toggleFrontLayer,
AnimationStatus.dismissed, tooltip: 'Toggle options page',
controller: _controller, icon: new AnimatedIcon(
child: widget.backLayer, icon: AnimatedIcons.close_menu,
progress: _controller,
), ),
), ),
], ),
), new Expanded(
// Front layer
new PositionedTransition(
rect: frontRelativeRect,
child: new AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, Widget child) {
return new PhysicalShape(
elevation: 12.0,
color: Theme.of(context).canvasColor,
clipper: new ShapeBorderClipper(
shape: new BeveledRectangleBorder(
borderRadius: _kFrontHeadingBevelRadius.lerp(_controller.value),
),
),
child: child,
);
},
child: new _TappableWhileStatusIs( child: new _TappableWhileStatusIs(
AnimationStatus.completed, AnimationStatus.dismissed,
controller: _controller, controller: _controller,
child: new FadeTransition( child: widget.backLayer,
opacity: _frontOpacity, ),
child: widget.frontLayer, ),
],
),
// Front layer
new PositionedTransition(
rect: frontRelativeRect,
child: new AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, Widget child) {
return new PhysicalShape(
elevation: 12.0,
color: Theme.of(context).canvasColor,
clipper: new ShapeBorderClipper(
shape: new BeveledRectangleBorder(
borderRadius: _kFrontHeadingBevelRadius.lerp(_controller.value),
),
), ),
child: child,
);
},
child: new _TappableWhileStatusIs(
AnimationStatus.completed,
controller: _controller,
child: new FadeTransition(
opacity: _frontOpacity,
child: widget.frontLayer,
), ),
), ),
), ),
),
];
// 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( new PositionedTransition(
rect: frontRelativeRect, rect: frontRelativeRect,
child: new ExcludeSemantics( child: new ExcludeSemantics(
...@@ -338,7 +344,12 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -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 { ...@@ -270,10 +270,12 @@ class GalleryHome extends StatefulWidget {
const GalleryHome({ const GalleryHome({
Key key, Key key,
this.testMode: false,
this.optionsPage, this.optionsPage,
}) : super(key: key); }) : super(key: key);
final Widget optionsPage; final Widget optionsPage;
final bool testMode;
@override @override
_GalleryHomeState createState() => new _GalleryHomeState(); _GalleryHomeState createState() => new _GalleryHomeState();
...@@ -345,13 +347,13 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat ...@@ -345,13 +347,13 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
onPressed: () => setState(() => _category = null), onPressed: () => setState(() => _category = null),
), ),
), ),
frontTitle: new AnimatedSwitcher( frontTitle: new AnimatedSwitcher(
duration: _kFrontLayerSwitchDuration, duration: _kFrontLayerSwitchDuration,
child: _category == null child: _category == null
? const Text('Flutter gallery') ? const Text('Flutter gallery')
: new Text(_category.name), : new Text(_category.name),
), ),
frontHeading: new Container(height: 24.0), frontHeading: widget.testMode ? null: new Container(height: 24.0),
frontLayer: new AnimatedSwitcher( frontLayer: new AnimatedSwitcher(
duration: _kFrontLayerSwitchDuration, duration: _kFrontLayerSwitchDuration,
switchOutCurve: switchOutCurve, switchOutCurve: switchOutCurve,
......
...@@ -17,6 +17,7 @@ void main() { ...@@ -17,6 +17,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new GalleryApp( new GalleryApp(
testMode: true,
onSendFeedback: () { onSendFeedback: () {
hasFeedback = true; hasFeedback = true;
}, },
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
testWidgets('Flutter gallery button example code displays', (WidgetTester tester) async { testWidgets('Flutter gallery button example code displays', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/6147 // 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(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame await tester.pump(); // triggers a frame
......
...@@ -43,7 +43,7 @@ Future<Null> main() async { ...@@ -43,7 +43,7 @@ Future<Null> main() async {
if (!new Set<String>.from(allDemoTitles).containsAll(_kSkippedDemoTitles)) if (!new Set<String>.from(allDemoTitles).containsAll(_kSkippedDemoTitles))
fail('Unrecognized demo names in _kSkippedDemoTitles: $_kSkippedDemoTitles'); fail('Unrecognized demo names in _kSkippedDemoTitles: $_kSkippedDemoTitles');
runApp(const GalleryApp()); runApp(const GalleryApp(testMode: true));
final _LiveWidgetController controller = new _LiveWidgetController(); final _LiveWidgetController controller = new _LiveWidgetController();
for (GalleryDemoCategory category in kAllGalleryDemoCategories) { for (GalleryDemoCategory category in kAllGalleryDemoCategories) {
await controller.tap(find.text(category.name)); await controller.tap(find.text(category.name));
......
...@@ -19,7 +19,7 @@ void main() { ...@@ -19,7 +19,7 @@ void main() {
child: const SizedBox( child: const SizedBox(
width: 450.0, width: 450.0,
height: 800.0, height: 800.0,
child: const GalleryApp() child: const GalleryApp(testMode: true)
) )
) )
); );
...@@ -43,7 +43,7 @@ void main() { ...@@ -43,7 +43,7 @@ void main() {
}); });
testWidgets('Pesto can be scrolled all the way down', (WidgetTester tester) async { 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(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame await tester.pump(); // triggers a frame
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.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() { void main() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
...@@ -12,7 +12,9 @@ void main() { ...@@ -12,7 +12,9 @@ void main() {
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
testWidgets('Flutter Gallery app simple smoke test', (WidgetTester tester) async { 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(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame await tester.pump(); // triggers a frame
......
...@@ -139,6 +139,7 @@ Future<Null> smokeGallery(WidgetTester tester) async { ...@@ -139,6 +139,7 @@ Future<Null> smokeGallery(WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new GalleryApp( new GalleryApp(
testMode: true,
onSendFeedback: () { onSendFeedback: () {
sendFeedbackButtonPressed = true; // see smokeOptionsPage() sendFeedbackButtonPressed = true; // see smokeOptionsPage()
}, },
......
...@@ -17,7 +17,12 @@ void main() { ...@@ -17,7 +17,12 @@ void main() {
// Regression test for https://github.com/flutter/flutter/pull/5168 // Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets('update dialog', (WidgetTester tester) async { 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(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame await tester.pump(); // triggers a frame
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_driver/driver_extension.dart'; 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() { void main() {
enableFlutterDriverExtension(); 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 @@ ...@@ -3,9 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_driver/driver_extension.dart'; 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() { void main() {
enableFlutterDriverExtension(); 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; ...@@ -7,7 +7,8 @@ import 'dart:convert' show JsonEncoder;
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_gallery/gallery/demos.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 { Future<String> _handleMessages(String message) async {
assert(message == 'demoNames'); assert(message == 'demoNames');
...@@ -18,5 +19,8 @@ Future<String> _handleMessages(String message) async { ...@@ -18,5 +19,8 @@ Future<String> _handleMessages(String message) async {
void main() { void main() {
enableFlutterDriverExtension(handler: _handleMessages); 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));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment