Commit 741a17ec authored by Brian Egan's avatar Brian Egan

Apply integration tests to vanila sample

parent b613648a
......@@ -4,7 +4,7 @@ import 'package:flutter_architecture_samples/flutter_architecture_samples.dart';
import 'package:todos_repository/todos_repository.dart';
import 'package:vanilla/models.dart';
import 'package:vanilla/screens/add_edit_screen.dart';
import 'package:vanilla/screens/tabs_screen.dart';
import 'package:vanilla/screens/home_screen.dart';
import 'package:vanilla/localization.dart';
class VanillaApp extends StatefulWidget {
......@@ -49,7 +49,7 @@ class VanillaAppState extends State<VanillaApp> {
],
routes: {
ArchSampleRoutes.home: (context) {
return new TabsScreen(
return new HomeScreen(
appState: appState,
updateTodo: updateTodo,
addTodo: addTodo,
......@@ -60,6 +60,7 @@ class VanillaAppState extends State<VanillaApp> {
},
ArchSampleRoutes.addTodo: (context) {
return new AddEditScreen(
key: ArchSampleKeys.addTodoScreen,
addTodo: addTodo,
updateTodo: updateTodo,
);
......
......@@ -90,6 +90,7 @@ class DetailScreen extends StatelessWidget {
new MaterialPageRoute(
builder: (context) {
return new AddEditScreen(
key: ArchSampleKeys.editTodoScreen,
updateTodo: updateTodo,
addTodo: addTodo,
todo: todo,
......
......@@ -9,7 +9,7 @@ import 'package:vanilla/widgets/stats_counter.dart';
import 'package:vanilla/widgets/todo_list.dart';
import 'package:vanilla/widgets/typedefs.dart';
class TabsScreen extends StatefulWidget {
class HomeScreen extends StatefulWidget {
final AppState appState;
final TodoAdder addTodo;
final TodoRemover removeTodo;
......@@ -17,7 +17,7 @@ class TabsScreen extends StatefulWidget {
final Function toggleAll;
final Function clearCompleted;
TabsScreen({
HomeScreen({
@required this.appState,
@required this.addTodo,
@required this.removeTodo,
......@@ -26,15 +26,15 @@ class TabsScreen extends StatefulWidget {
@required this.clearCompleted,
Key key,
})
: super(key: key);
: super(key: ArchSampleKeys.homeScreen);
@override
State<StatefulWidget> createState() {
return new TabsScreenState();
return new HomeScreenState();
}
}
class TabsScreenState extends State<TabsScreen> {
class HomeScreenState extends State<HomeScreen> {
VisibilityFilter activeFilter = VisibilityFilter.all;
AppTab activeTab = AppTab.todos;
......@@ -102,7 +102,12 @@ class TabsScreenState extends State<TabsScreen> {
},
items: AppTab.values.map((tab) {
return new BottomNavigationBarItem(
icon: new Icon(tab == AppTab.todos ? Icons.list : Icons.show_chart),
icon: new Icon(
tab == AppTab.todos ? Icons.list : Icons.show_chart,
key: tab == AppTab.stats
? ArchSampleKeys.statsTab
: ArchSampleKeys.todoTab,
),
title: new Text(tab == AppTab.stats
? ArchSampleLocalizations.of(context).stats
: ArchSampleLocalizations.of(context).todos),
......
......@@ -18,15 +18,18 @@ class ExtraActionsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new PopupMenuButton<ExtraAction>(
key: ArchSampleKeys.extraActionsButton,
onSelected: onSelected,
itemBuilder: (BuildContext context) => <PopupMenuItem<ExtraAction>>[
new PopupMenuItem<ExtraAction>(
key: ArchSampleKeys.toggleAll,
value: ExtraAction.toggleAllComplete,
child: new Text(allComplete
? ArchSampleLocalizations.of(context).markAllIncomplete
: ArchSampleLocalizations.of(context).markAllComplete),
),
new PopupMenuItem<ExtraAction>(
key: ArchSampleKeys.clearCompleted,
value: ExtraAction.clearCompleted,
child:
new Text(ArchSampleLocalizations.of(context).clearCompleted),
......
......@@ -23,11 +23,13 @@ class FilterButton extends StatelessWidget {
opacity: isActive ? 1.0 : 0.0,
duration: new Duration(milliseconds: 150),
child: new PopupMenuButton<VisibilityFilter>(
key: ArchSampleKeys.filterButton,
tooltip: ArchSampleLocalizations.of(context).filterTodos,
onSelected: onSelected,
itemBuilder: (BuildContext context) =>
<PopupMenuItem<VisibilityFilter>>[
new PopupMenuItem<VisibilityFilter>(
key: ArchSampleKeys.allFilter,
value: VisibilityFilter.all,
child: new Text(
ArchSampleLocalizations.of(context).showAll,
......@@ -37,6 +39,7 @@ class FilterButton extends StatelessWidget {
),
),
new PopupMenuItem<VisibilityFilter>(
key: ArchSampleKeys.activeFilter,
value: VisibilityFilter.active,
child: new Text(
ArchSampleLocalizations.of(context).showActive,
......@@ -46,6 +49,7 @@ class FilterButton extends StatelessWidget {
),
),
new PopupMenuItem<VisibilityFilter>(
key: ArchSampleKeys.completedFilter,
value: VisibilityFilter.completed,
child: new Text(
ArchSampleLocalizations.of(context).showCompleted,
......
......@@ -7,7 +7,7 @@ class StatsCounter extends StatelessWidget {
final int numActive;
final int numCompleted;
StatsCounter({@required this.numActive, @required this.numCompleted});
StatsCounter({@required this.numActive, @required this.numCompleted}) : super(key: ArchSampleKeys.statsCounter);
@override
Widget build(BuildContext context) {
......@@ -26,6 +26,7 @@ class StatsCounter extends StatelessWidget {
padding: new EdgeInsets.only(bottom: 24.0),
child: new Text(
'$numCompleted',
key: ArchSampleKeys.statsNumCompleted,
style: Theme.of(context).textTheme.subhead,
),
),
......@@ -40,6 +41,7 @@ class StatsCounter extends StatelessWidget {
padding: new EdgeInsets.only(bottom: 24.0),
child: new Text(
"$numActive",
key: ArchSampleKeys.statsNumActive,
style: Theme.of(context).textTheme.subhead,
),
)
......
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_architecture_samples/flutter_architecture_samples.dart';
import 'package:vanilla/models.dart';
class TodoItem extends StatelessWidget {
......@@ -9,29 +10,33 @@ class TodoItem extends StatelessWidget {
final Todo todo;
TodoItem({
Key key,
@required this.onDismissed,
@required this.onTap,
@required this.onCheckboxChanged,
@required this.todo,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
return new Dismissible(
key: new Key(todo.id),
key: ArchSampleKeys.todoItem(todo.id),
onDismissed: onDismissed,
child: new ListTile(
onTap: onTap,
leading: new Checkbox(
key: ArchSampleKeys.todoItemCheckbox(todo.id),
value: todo.complete,
onChanged: onCheckboxChanged,
),
title: new Text(
todo.task,
key: ArchSampleKeys.todoItemTask(todo.id),
style: Theme.of(context).textTheme.title,
),
subtitle: new Text(
todo.note,
key: ArchSampleKeys.todoItemNote(todo.id),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.subhead,
......
......@@ -69,6 +69,7 @@ class TodoList extends StatelessWidget {
Scaffold.of(context).showSnackBar(
new SnackBar(
key: ArchSampleKeys.snackbar,
duration: new Duration(seconds: 2),
backgroundColor: Theme.of(context).backgroundColor,
content: new Text(
......
......@@ -14,6 +14,8 @@ dev_dependencies:
sdk: flutter
flutter_driver:
sdk: flutter
integration_tests:
path: ../integration_tests
todos_repository:
path: ../todos_repository
......
// This line imports the extension
import 'package:flutter_driver/driver_extension.dart';
import 'package:vanilla/main.dart' as app;
void main() {
enableFlutterDriverExtension();
app.main();
}
import 'package:integration_tests/integration_tests.dart' as integrationTests;
main() {
integrationTests.main();
}
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