date_picker_test.dart 1.16 KB
Newer Older
Hixie's avatar
Hixie committed
1 2 3 4
// Copyright 2015 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.

Adam Barth's avatar
Adam Barth committed
5
import 'package:flutter_test/flutter_test.dart';
6
import 'package:flutter/material.dart';
7 8

void main() {
9
  testWidgets('Can select a day', (WidgetTester tester) async {
10
    DateTime currentValue;
11

12
    final Widget widget = new Material(
13
      child: new ListView(
14
        children: <Widget>[
15
          new MonthPicker(
16 17 18 19 20 21 22 23 24 25
            selectedDate: new DateTime.utc(2015, 6, 9, 7, 12),
            firstDate: new DateTime.utc(2013),
            lastDate: new DateTime.utc(2018),
            onChanged: (DateTime dateTime) {
              currentValue = dateTime;
            }
          )
        ]
      )
    );
26

27
    await tester.pumpWidget(widget);
28

29
    expect(currentValue, isNull);
30 31 32 33
    await tester.tap(find.text('2015'));
    await tester.pumpWidget(widget);
    await tester.tap(find.text('2014'));
    await tester.pumpWidget(widget);
34
    expect(currentValue, equals(new DateTime(2014, 6, 9)));
35
    await tester.tap(find.text('30'));
36
    expect(currentValue, equals(new DateTime(2013, 1, 30)));
37
  }, skip: true);
38
}