Commit 248960a7 authored by Adam Barth's avatar Adam Barth

Add a route table to Material Gallery (#3457)

Use the route table to generate the list of screens to test in the smoke test.
parent 986b0174
......@@ -45,6 +45,8 @@ const String _actionText =
const String _actionCode = 'buttons_action';
class ButtonsDemo extends StatefulWidget {
static const String routeName = '/buttons';
@override
_ButtonsDemoState createState() => new _ButtonsDemoState();
}
......
......@@ -118,6 +118,8 @@ class TravelDestinationItem extends StatelessWidget {
}
class CardsDemo extends StatelessWidget {
static const String routeName = '/cards';
@override
Widget build(BuildContext context) {
return new Scaffold(
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class ChipDemo extends StatefulWidget {
static const String routeName = '/chip';
@override
_ChipDemoState createState() => new _ChipDemoState();
}
......
......@@ -109,6 +109,8 @@ class ColorSwatchTabView extends StatelessWidget {
}
class ColorsDemo extends StatelessWidget {
static const String routeName = '/colors';
@override
Widget build(BuildContext context) {
return new TabBarSelection<ColorSwatch>(
......
......@@ -20,6 +20,8 @@ class Desert {
}
class DataTableDemo extends StatefulWidget {
static const String routeName = '/data-table';
@override
_DataTableDemoState createState() => new _DataTableDemoState();
}
......
......@@ -8,6 +8,8 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class DatePickerDemo extends StatefulWidget {
static const String routeName = '/date-picker';
@override
_DatePickerDemoState createState() => new _DatePickerDemoState();
}
......
......@@ -55,6 +55,8 @@ class DialogDemoItem extends StatelessWidget {
}
class DialogDemo extends StatefulWidget {
static const String routeName = '/dialog';
@override
DialogDemoState createState() => new DialogDemoState();
}
......
......@@ -10,6 +10,8 @@ import 'package:flutter/services.dart';
import 'package:flutter_sprites/flutter_sprites.dart';
class DrawingDemo extends StatefulWidget {
static const String routeName = '/drawing';
@override
_DrawingDemoState createState() => new _DrawingDemoState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class DropDownDemo extends StatefulWidget {
static const String routeName = '/dropdown';
@override
_DropDownDemoState createState() => new _DropDownDemoState();
}
......
......@@ -16,6 +16,8 @@ SpriteSheet _sprites;
class FitnessDemo extends StatelessWidget {
FitnessDemo({ Key key }) : super(key: key);
static const String routeName = '/fitness';
@override
Widget build(BuildContext context) {
return new Scaffold(
......
......@@ -70,6 +70,8 @@ class _ContactItem extends StatelessWidget {
}
class FlexibleSpaceDemo extends StatefulWidget {
static const String routeName = '/flexible-space';
@override
FlexibleSpaceDemoState createState() => new FlexibleSpaceDemoState();
}
......
......@@ -132,6 +132,8 @@ class GridDemoPhotoItem extends StatelessWidget {
class GridListDemo extends StatefulWidget {
GridListDemo({ Key key }) : super(key: key);
static const String routeName = '/grid-list';
@override
GridListDemoState createState() => new GridListDemoState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class IconsDemo extends StatefulWidget {
static const String routeName = '/icons';
@override
IconsDemoState createState() => new IconsDemoState();
}
......
......@@ -31,6 +31,8 @@ class LeaveBehindItem implements Comparable<LeaveBehindItem> {
class LeaveBehindDemo extends StatefulWidget {
LeaveBehindDemo({ Key key }) : super(key: key);
static const String routeName = '/leave-behind';
@override
LeaveBehindDemoState createState() => new LeaveBehindDemoState();
}
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
class ListDemo extends StatefulWidget {
ListDemo({ Key key }) : super(key: key);
static const String routeName = '/list';
@override
ListDemoState createState() => new ListDemoState();
}
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
class MenuDemo extends StatefulWidget {
MenuDemo({ Key key }) : super(key: key);
static const String routeName = '/menu';
@override
MenuDemoState createState() => new MenuDemoState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class ModalBottomSheetDemo extends StatelessWidget {
static const String routeName = '/modal-bottom-sheet';
final TextStyle textStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0,
......
......@@ -11,6 +11,8 @@ enum IndicatorType { overscroll, refresh }
class OverscrollDemo extends StatefulWidget {
OverscrollDemo({ Key key }) : super(key: key);
static const String routeName = '/overscroll';
@override
OverscrollDemoState createState() => new OverscrollDemoState();
}
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
class PageSelectorDemo extends StatelessWidget {
static const String routeName = '/page-selector';
void _handleArrowButtonPress(BuildContext context, int delta) {
final TabBarSelectionState<IconData> selection = TabBarSelection.of/*<IconData>*/(context);
if (!selection.valueIsChanging)
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class PersistentBottomSheetDemo extends StatefulWidget {
static const String routeName = '/persistent-bottom-sheet';
@override
_PersistentBottomSheetDemoState createState() => new _PersistentBottomSheetDemoState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class ProgressIndicatorDemo extends StatefulWidget {
static const String routeName = '/progress-indicator';
@override
_ProgressIndicatorDemoState createState() => new _ProgressIndicatorDemoState();
}
......
......@@ -11,6 +11,8 @@ enum TabsDemoStyle {
}
class ScrollableTabsDemo extends StatefulWidget {
static const String routeName = '/scrollable-tabs';
@override
ScrollableTabsDemoState createState() => new ScrollableTabsDemoState();
}
......
......@@ -29,6 +29,8 @@ const String _switchText =
const String _switchCode = 'selectioncontrols_switch';
class SelectionControlsDemo extends StatefulWidget {
static const String routeName = '/selection-controls';
@override
_SelectionControlsDemoState createState() => new _SelectionControlsDemoState();
}
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class SliderDemo extends StatefulWidget {
static const String routeName = '/slider';
@override
_SliderDemoState createState() => new _SliderDemoState();
}
......
......@@ -20,6 +20,8 @@ const String _text3 =
class SnackBarDemo extends StatefulWidget {
SnackBarDemo({ Key key }) : super(key: key);
static const String routeName = '/snack-bar';
@override
_SnackBarDemoState createState() => new _SnackBarDemoState();
}
......
......@@ -19,6 +19,8 @@ final List<_Page> _pages = <_Page>[
];
class TabsDemo extends StatefulWidget {
static const String routeName = '/tabs';
@override
TabsDemoState createState() => new TabsDemoState();
}
......
......@@ -26,6 +26,8 @@ const String _explanatoryText =
"by its key.";
class TabsFabDemo extends StatefulWidget {
static const String routeName = '/tabs-fab';
@override
_TabsFabDemoState createState() => new _TabsFabDemoState();
}
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
class TextFieldDemo extends StatefulWidget {
TextFieldDemo({ Key key }) : super(key: key);
static const String routeName = '/text-field';
@override
TextFieldDemoState createState() => new TextFieldDemoState();
}
......
......@@ -7,6 +7,8 @@ import 'dart:async';
import 'package:flutter/material.dart';
class TimePickerDemo extends StatefulWidget {
static const String routeName = '/time-picker';
@override
_TimePickerDemoState createState() => new _TimePickerDemoState();
}
......
......@@ -10,6 +10,9 @@ const String _introText =
"apps accessible, like screen readers.";
class TooltipDemo extends StatelessWidget {
static const String routeName = '/tooltip';
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
class TwoLevelListDemo extends StatelessWidget {
static const String routeName = '/two-level-list';
@override
Widget build(BuildContext context) {
return new Scaffold(
......
......@@ -39,6 +39,8 @@ class TextStyleItem extends StatelessWidget {
}
class TypographyDemo extends StatelessWidget {
static const String routeName = '/typography';
@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme;
......
......@@ -20,6 +20,8 @@ enum WeatherType {
class WeatherDemo extends StatefulWidget {
WeatherDemo({ Key key }) : super(key: key);
static const String routeName = '/weather';
@override
_WeatherDemoState createState() => new _WeatherDemoState();
}
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
export 'demo/buttons_demo.dart';
export 'demo/cards_demo.dart';
export 'demo/colors_demo.dart';
export 'demo/chip_demo.dart';
export 'demo/data_table_demo.dart';
export 'demo/date_picker_demo.dart';
export 'demo/dialog_demo.dart';
export 'demo/drop_down_demo.dart';
export 'demo/drawing_demo.dart';
export 'demo/fitness_demo.dart';
export 'demo/flexible_space_demo.dart';
export 'demo/grid_list_demo.dart';
export 'demo/icons_demo.dart';
export 'demo/leave_behind_demo.dart';
export 'demo/list_demo.dart';
export 'demo/modal_bottom_sheet_demo.dart';
export 'demo/menu_demo.dart';
export 'demo/overscroll_demo.dart';
export 'demo/page_selector_demo.dart';
export 'demo/persistent_bottom_sheet_demo.dart';
export 'demo/progress_indicator_demo.dart';
export 'demo/selection_controls_demo.dart';
export 'demo/slider_demo.dart';
export 'demo/snack_bar_demo.dart';
export 'demo/scrollable_tabs_demo.dart';
export 'demo/tabs_demo.dart';
export 'demo/tabs_fab_demo.dart';
export 'demo/text_field_demo.dart';
export 'demo/time_picker_demo.dart';
export 'demo/tooltip_demo.dart';
export 'demo/two_level_list_demo.dart';
export 'demo/typography_demo.dart';
export 'demo/weather_demo.dart';
......@@ -5,8 +5,45 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import '../demos.dart';
import 'home.dart';
final Map<String, WidgetBuilder> kRoutes = <String, WidgetBuilder>{
WeatherDemo.routeName: (BuildContext context) => new WeatherDemo(),
FitnessDemo.routeName: (BuildContext context) => new FitnessDemo(),
DrawingDemo.routeName: (BuildContext context) => new DrawingDemo(),
FlexibleSpaceDemo.routeName: (BuildContext context) => new FlexibleSpaceDemo(),
TabsFabDemo.routeName: (BuildContext context) => new TabsFabDemo(),
ButtonsDemo.routeName: (BuildContext context) => new ButtonsDemo(),
CardsDemo.routeName: (BuildContext context) => new CardsDemo(),
ChipDemo.routeName: (BuildContext context) => new ChipDemo(),
DatePickerDemo.routeName: (BuildContext context) => new DatePickerDemo(),
DataTableDemo.routeName: (BuildContext context) => new DataTableDemo(),
DialogDemo.routeName: (BuildContext context) => new DialogDemo(),
DropDownDemo.routeName: (BuildContext context) => new DropDownDemo(),
TwoLevelListDemo.routeName: (BuildContext context) => new TwoLevelListDemo(),
GridListDemo.routeName: (BuildContext context) => new GridListDemo(),
IconsDemo.routeName: (BuildContext context) => new IconsDemo(),
LeaveBehindDemo.routeName: (BuildContext context) => new LeaveBehindDemo(),
ListDemo.routeName: (BuildContext context) => new ListDemo(),
MenuDemo.routeName: (BuildContext context) => new MenuDemo(),
ModalBottomSheetDemo.routeName: (BuildContext context) => new ModalBottomSheetDemo(),
OverscrollDemo.routeName: (BuildContext context) => new OverscrollDemo(),
PageSelectorDemo.routeName: (BuildContext context) => new PageSelectorDemo(),
PersistentBottomSheetDemo.routeName: (BuildContext context) => new PersistentBottomSheetDemo(),
ProgressIndicatorDemo.routeName: (BuildContext context) => new ProgressIndicatorDemo(),
ScrollableTabsDemo.routeName: (BuildContext context) => new ScrollableTabsDemo(),
SelectionControlsDemo.routeName: (BuildContext context) => new SelectionControlsDemo(),
SliderDemo.routeName: (BuildContext context) => new SliderDemo(),
SnackBarDemo.routeName: (BuildContext context) => new SnackBarDemo(),
TabsDemo.routeName: (BuildContext context) => new TabsDemo(),
TextFieldDemo.routeName: (BuildContext context) => new TextFieldDemo(),
TimePickerDemo.routeName: (BuildContext context) => new TimePickerDemo(),
TooltipDemo.routeName: (BuildContext context) => new TooltipDemo(),
ColorsDemo.routeName: (BuildContext context) => new ColorsDemo(),
TypographyDemo.routeName: (BuildContext context) => new TypographyDemo(),
};
class GalleryApp extends StatefulWidget {
GalleryApp({ Key key }) : super(key: key);
......@@ -24,6 +61,7 @@ class GalleryAppState extends State<GalleryApp> {
title: 'Flutter Material Gallery',
theme: _useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme,
showPerformanceOverlay: _showPerformanceOverlay,
routes: kRoutes,
home: new GalleryHome(
useLightTheme: _useLightTheme,
onThemeChanged: (bool value) { setState(() { _useLightTheme = value; }); },
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/material.dart';
......
......@@ -5,44 +5,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import '../demos.dart';
import 'drawer.dart';
import 'header.dart';
import 'item.dart';
import '../demo/buttons_demo.dart';
import '../demo/cards_demo.dart';
import '../demo/colors_demo.dart';
import '../demo/chip_demo.dart';
import '../demo/data_table_demo.dart';
import '../demo/date_picker_demo.dart';
import '../demo/dialog_demo.dart';
import '../demo/drop_down_demo.dart';
import '../demo/drawing_demo.dart';
import '../demo/fitness_demo.dart';
import '../demo/flexible_space_demo.dart';
import '../demo/grid_list_demo.dart';
import '../demo/icons_demo.dart';
import '../demo/leave_behind_demo.dart';
import '../demo/list_demo.dart';
import '../demo/modal_bottom_sheet_demo.dart';
import '../demo/menu_demo.dart';
import '../demo/overscroll_demo.dart';
import '../demo/page_selector_demo.dart';
import '../demo/persistent_bottom_sheet_demo.dart';
import '../demo/progress_indicator_demo.dart';
import '../demo/selection_controls_demo.dart';
import '../demo/slider_demo.dart';
import '../demo/snack_bar_demo.dart';
import '../demo/scrollable_tabs_demo.dart';
import '../demo/tabs_demo.dart';
import '../demo/tabs_fab_demo.dart';
import '../demo/text_field_demo.dart';
import '../demo/time_picker_demo.dart';
import '../demo/tooltip_demo.dart';
import '../demo/two_level_list_demo.dart';
import '../demo/typography_demo.dart';
import '../demo/weather_demo.dart';
const double _kFlexibleSpaceMaxHeight = 256.0;
class GalleryHome extends StatefulWidget {
......@@ -106,51 +73,51 @@ class GalleryHomeState extends State<GalleryHome> {
leading: new Icon(icon: Icons.star),
title: new Text('Demos'),
children: <Widget>[
new GalleryItem(title: 'Weather', builder: () => new WeatherDemo()),
new GalleryItem(title: 'Fitness', builder: () => new FitnessDemo()),
new GalleryItem(title: 'Fancy lines', builder: () => new DrawingDemo()),
new GalleryItem(title: 'Flexible space toolbar', builder: () => new FlexibleSpaceDemo()),
new GalleryItem(title: 'Floating action button', builder: () => new TabsFabDemo()),
new GalleryItem(title: 'Weather', routeName: WeatherDemo.routeName),
new GalleryItem(title: 'Fitness', routeName: FitnessDemo.routeName),
new GalleryItem(title: 'Fancy lines', routeName: DrawingDemo.routeName),
new GalleryItem(title: 'Flexible space toolbar', routeName: FlexibleSpaceDemo.routeName),
new GalleryItem(title: 'Floating action button', routeName: TabsFabDemo.routeName),
]
),
new TwoLevelSublist(
leading: new Icon(icon: Icons.extension),
title: new Text('Components'),
children: <Widget>[
new GalleryItem(title: 'Buttons', builder: () => new ButtonsDemo()),
new GalleryItem(title: 'Cards', builder: () => new CardsDemo()),
new GalleryItem(title: 'Chips', builder: () => new ChipDemo()),
new GalleryItem(title: 'Date picker', builder: () => new DatePickerDemo()),
new GalleryItem(title: 'Data tables', builder: () => new DataTableDemo()),
new GalleryItem(title: 'Dialog', builder: () => new DialogDemo()),
new GalleryItem(title: 'Drop-down button', builder: () => new DropDownDemo()),
new GalleryItem(title: 'Expand/collapse list control', builder: () => new TwoLevelListDemo()),
new GalleryItem(title: 'Grid', builder: () => new GridListDemo()),
new GalleryItem(title: 'Icons', builder: () => new IconsDemo()),
new GalleryItem(title: 'Leave-behind list items', builder: () => new LeaveBehindDemo()),
new GalleryItem(title: 'List', builder: () => new ListDemo()),
new GalleryItem(title: 'Menus', builder: () => new MenuDemo()),
new GalleryItem(title: 'Modal bottom sheet', builder: () => new ModalBottomSheetDemo()),
new GalleryItem(title: 'Over-scroll', builder: () => new OverscrollDemo()),
new GalleryItem(title: 'Page selector', builder: () => new PageSelectorDemo()),
new GalleryItem(title: 'Persistent bottom sheet', builder: () => new PersistentBottomSheetDemo()),
new GalleryItem(title: 'Progress indicators', builder: () => new ProgressIndicatorDemo()),
new GalleryItem(title: 'Scrollable tabs', builder: () => new ScrollableTabsDemo()),
new GalleryItem(title: 'Selection controls', builder: () => new SelectionControlsDemo()),
new GalleryItem(title: 'Sliders', builder: () => new SliderDemo()),
new GalleryItem(title: 'Snackbar', builder: () => new SnackBarDemo()),
new GalleryItem(title: 'Tabs', builder: () => new TabsDemo()),
new GalleryItem(title: 'Text fields', builder: () => new TextFieldDemo()),
new GalleryItem(title: 'Time picker', builder: () => new TimePickerDemo()),
new GalleryItem(title: 'Tooltips', builder: () => new TooltipDemo()),
new GalleryItem(title: 'Buttons', routeName: ButtonsDemo.routeName),
new GalleryItem(title: 'Cards', routeName: CardsDemo.routeName),
new GalleryItem(title: 'Chips', routeName: ChipDemo.routeName),
new GalleryItem(title: 'Date picker', routeName: DatePickerDemo.routeName),
new GalleryItem(title: 'Data tables', routeName: DataTableDemo.routeName),
new GalleryItem(title: 'Dialog', routeName: DialogDemo.routeName),
new GalleryItem(title: 'Drop-down button', routeName: DropDownDemo.routeName),
new GalleryItem(title: 'Expand/collapse list control', routeName: TwoLevelListDemo.routeName),
new GalleryItem(title: 'Grid', routeName: GridListDemo.routeName),
new GalleryItem(title: 'Icons', routeName: IconsDemo.routeName),
new GalleryItem(title: 'Leave-behind list items', routeName: LeaveBehindDemo.routeName),
new GalleryItem(title: 'List', routeName: ListDemo.routeName),
new GalleryItem(title: 'Menus', routeName: MenuDemo.routeName),
new GalleryItem(title: 'Modal bottom sheet', routeName: ModalBottomSheetDemo.routeName),
new GalleryItem(title: 'Over-scroll', routeName: OverscrollDemo.routeName),
new GalleryItem(title: 'Page selector', routeName: PageSelectorDemo.routeName),
new GalleryItem(title: 'Persistent bottom sheet', routeName: PersistentBottomSheetDemo.routeName),
new GalleryItem(title: 'Progress indicators', routeName: ProgressIndicatorDemo.routeName),
new GalleryItem(title: 'Scrollable tabs', routeName: ScrollableTabsDemo.routeName),
new GalleryItem(title: 'Selection controls', routeName: SelectionControlsDemo.routeName),
new GalleryItem(title: 'Sliders', routeName: SliderDemo.routeName),
new GalleryItem(title: 'Snackbar', routeName: SnackBarDemo.routeName),
new GalleryItem(title: 'Tabs', routeName: TabsDemo.routeName),
new GalleryItem(title: 'Text fields', routeName: TextFieldDemo.routeName),
new GalleryItem(title: 'Time picker', routeName: TimePickerDemo.routeName),
new GalleryItem(title: 'Tooltips', routeName: TooltipDemo.routeName),
]
),
new TwoLevelSublist(
leading: new Icon(icon: Icons.color_lens),
title: new Text('Style'),
children: <Widget>[
new GalleryItem(title: 'Colors', builder: () => new ColorsDemo()),
new GalleryItem(title: 'Typography', builder: () => new TypographyDemo()),
new GalleryItem(title: 'Colors', routeName: ColorsDemo.routeName),
new GalleryItem(title: 'Typography', routeName: TypographyDemo.routeName),
]
)
]
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// 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';
typedef Widget GalleryDemoBuilder();
class GalleryItem extends StatelessWidget {
GalleryItem({ this.title, this.icon, this.builder });
GalleryItem({ this.title, this.icon, this.routeName });
final String title;
final IconData icon;
final GalleryDemoBuilder builder;
final String routeName;
@override
Widget build(BuildContext context) {
......@@ -17,11 +21,8 @@ class GalleryItem extends StatelessWidget {
leading: leading,
title: new Text(title),
onTap: () {
if (builder != null) {
Navigator.push(context, new MaterialPageRoute<Null>(
builder: (BuildContext context) => builder()
));
}
if (routeName != null)
Navigator.pushNamed(context, routeName);
}
);
}
......
......@@ -7,51 +7,22 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart';
import '../lib/main.dart' as material_gallery;
import '../lib/gallery/app.dart' as material_gallery;
import '../lib/gallery/item.dart' as material_gallery;
// Warning: the following strings must be kept in sync with GalleryHome.
const List<String> demoCategories = const <String>['Demos', 'Components', 'Style'];
const List<String> demoNames = const <String>[
'Weather',
'Fitness',
'Fancy lines',
'Flexible space toolbar',
'Floating action button',
'Buttons',
'Cards',
'Chips',
'Date picker',
'Data tables',
'Dialog',
'Drop-down button',
'Expand/collapse list control',
'Grid',
'Icons',
'Leave-behind list items',
'List',
'Menus',
'Modal bottom sheet',
'Over-scroll',
'Page selector',
'Persistent bottom sheet',
'Progress indicators',
'Scrollable tabs',
'Selection controls',
'Sliders',
'Snackbar',
'Tabs',
'Text fields',
'Time picker',
'Tooltips',
'Colors',
'Typography'
];
Finder findGalleryItemByRouteName(WidgetTester tester, String routeName) {
return find.byPredicate((Widget widget) {
return widget is material_gallery.GalleryItem
&& widget.routeName == routeName;
});
}
Finder byTooltip(WidgetTester tester, String message) {
return find.byElement((Element element) {
Widget widget = element.widget;
if (widget is Tooltip)
return widget.message == message;
return false;
return find.byPredicate((Widget widget) {
return widget is Tooltip && widget.message == message;
});
}
......@@ -62,12 +33,12 @@ Finder findBackButton(WidgetTester tester) => byTooltip(tester, 'Back');
// Start a gallery demo and then go back. This function assumes that the
// we're starting on home route and that the submenu that contains the demo
// called 'name' is already open.
void smokeDemo(WidgetTester tester, String menuItemText) {
void smokeDemo(WidgetTester tester, String routeName) {
// Ensure that we're (likely to be) on the home page
final Finder navigationMenuButton = findNavigationMenuButton(tester);
expect(tester, hasWidget(navigationMenuButton));
final Finder menuItem = findGalleryItemByRouteName(tester, routeName);
expect(tester, hasWidget(menuItem));
tester.tap(find.text(menuItemText));
tester.tap(menuItem);
tester.pump(); // Launch the demo.
tester.pump(const Duration(seconds: 1)); // Wait until the demo has opened.
......@@ -95,18 +66,18 @@ void main() {
final List<double> scrollDeltas = new List<double>();
double previousY = tester.getTopRight(find.text(demoCategories[0])).y;
for (String name in demoNames) {
final double y = tester.getTopRight(find.text(name)).y;
final List<String> routeNames = material_gallery.kRoutes.keys.toList();
for (String routeName in routeNames) {
final double y = tester.getTopRight(findGalleryItemByRouteName(tester, routeName)).y;
scrollDeltas.add(previousY - y);
previousY = y;
}
// Launch each demo and then scroll that item out of the way.
for (int i = 0; i < demoNames.length; i += 1) {
final String name = demoNames[i];
print("$name");
smokeDemo(tester, name);
tester.scroll(find.text(name), new Offset(0.0, scrollDeltas[i]));
for (int i = 0; i < routeNames.length; i += 1) {
final String routeName = routeNames[i];
smokeDemo(tester, routeName);
tester.scroll(findGalleryItemByRouteName(tester, routeName), new Offset(0.0, scrollDeltas[i]));
tester.pump();
}
......
......@@ -266,6 +266,11 @@ class CommonFinders {
/// Finds widgets equal to [config].
Finder byConfig(Widget config) => new _ConfigFinder(config);
/// Finds widgets using a [predicate].
Finder byPredicate(WidgetPredicate predicate) {
return new _ElementFinder((Element element) => predicate(element.widget));
}
/// Finds widgets using an element [predicate].
Finder byElement(ElementPredicate predicate) => new _ElementFinder(predicate);
}
......@@ -403,6 +408,7 @@ class _ConfigFinder extends Finder {
}
}
typedef bool WidgetPredicate(Widget element);
typedef bool ElementPredicate(Element element);
class _ElementFinder extends Finder {
......
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