home_test_screen.dart 1.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
import 'dart:async';

import 'package:flutter_driver/flutter_driver.dart';
import '../elements/extra_actions_element.dart';
import '../elements/filters_element.dart';
import '../elements/stats_element.dart';
import '../elements/todo_list_element.dart';
import '../utils.dart';
import 'test_screen.dart';

class HomeTestScreen extends TestScreen {
  final _filterButtonFinder = find.byValueKey('__filterButton__');
  final _extraActionsButtonFinder = find.byValueKey('__extraActionsButton__');
  final _todosTabFinder = find.byValueKey('__todoTab__');
  final _statsTabFinder = find.byValueKey('__statsTab__');
  final _snackbarFinder = find.byValueKey('__snackbar__');

  HomeTestScreen(FlutterDriver driver) : super(driver);

  @override
  Future<bool> isLoading({Duration timeout}) async =>
      new TodoListElement(driver).isLoading;

  @override
  Future<bool> isReady({Duration timeout}) =>
      new TodoListElement(driver).isReady;

  TodoListElement get todoList {
    return new TodoListElement(driver);
  }

  StatsElement get stats {
    return new StatsElement(driver);
  }

  TodoListElement tapTodosTab() {
    driver.tap(_todosTabFinder);

    return new TodoListElement(driver);
  }

  StatsElement tapStatsTab() {
    driver.tap(_statsTabFinder);

    return new StatsElement(driver);
  }

  FiltersElement tapFilterButton() {
    driver.tap(_filterButtonFinder);

    return new FiltersElement(driver);
  }

  ExtraActionsElement tapExtraActionsButton() {
    driver.tap(_extraActionsButtonFinder);

    return new ExtraActionsElement(driver);
  }

  Future<bool> get snackbarVisible {
    return widgetExists(driver, _snackbarFinder);
  }
}