date_picker_test.dart 26.2 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1 2 3 4
// 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.

5 6
import 'dart:ui';

7
import 'package:flutter/rendering.dart';
Ian Hickson's avatar
Ian Hickson committed
8
import 'package:flutter/material.dart';
9
import 'package:flutter/widgets.dart';
Ian Hickson's avatar
Ian Hickson committed
10 11
import 'package:flutter_test/flutter_test.dart';

12
import '../widgets/semantics_tester.dart';
13 14
import 'feedback_tester.dart';

Ian Hickson's avatar
Ian Hickson committed
15
void main() {
16 17 18 19 20 21
  group('showDatePicker', () {
    _tests();
  });
}

void _tests() {
22 23 24
  DateTime firstDate;
  DateTime lastDate;
  DateTime initialDate;
25
  SelectableDayPredicate selectableDayPredicate;
26
  DatePickerMode initialDatePickerMode;
27 28
  final Finder nextMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Next month') ?? false));
  final Finder previousMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Previous month') ?? false));
29 30

  setUp(() {
31 32 33
    firstDate = new DateTime(2001, DateTime.january, 1);
    lastDate = new DateTime(2031, DateTime.december, 31);
    initialDate = new DateTime(2016, DateTime.january, 15);
34 35
    selectableDayPredicate = null;
    initialDatePickerMode = null;
36 37
  });

38
  testWidgets('tap-select a day', (WidgetTester tester) async {
39
    final Key _datePickerKey = new UniqueKey();
40
    DateTime _selectedDate = new DateTime(2016, DateTime.july, 26);
Ian Hickson's avatar
Ian Hickson committed
41 42

    await tester.pumpWidget(
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
      new MaterialApp(
        home: new StatefulBuilder(
          builder: (BuildContext context, StateSetter setState) {
            return new Container(
              width: 400.0,
              child: new SingleChildScrollView(
                child: new Material(
                  child: new MonthPicker(
                    firstDate: new DateTime(0),
                    lastDate: new DateTime(9999),
                    key: _datePickerKey,
                    selectedDate: _selectedDate,
                    onChanged: (DateTime value) {
                      setState(() {
                        _selectedDate = value;
                      });
                    },
60
                  ),
61 62 63 64 65 66
                ),
              ),
            );
          },
        ),
      )
Ian Hickson's avatar
Ian Hickson committed
67
    );
68

69
    expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 26)));
Ian Hickson's avatar
Ian Hickson committed
70

71
    await tester.tapAt(const Offset(50.0, 100.0));
72
    await tester.pumpAndSettle();
Ian Hickson's avatar
Ian Hickson committed
73 74
    await tester.pump(const Duration(seconds: 2));

75 76
    await tester.tap(find.text('1'));
    await tester.pumpAndSettle();
77
    expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 1)));
Ian Hickson's avatar
Ian Hickson committed
78

79
    await tester.tap(nextMonthIcon);
80
    await tester.pumpAndSettle();
81
    expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 1)));
Ian Hickson's avatar
Ian Hickson committed
82

83 84
    await tester.tap(find.text('5'));
    await tester.pumpAndSettle();
85
    expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 5)));
Ian Hickson's avatar
Ian Hickson committed
86

87 88
    await tester.drag(find.byKey(_datePickerKey), const Offset(-400.0, 0.0));
    await tester.pumpAndSettle();
89
    expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 5)));
Ian Hickson's avatar
Ian Hickson committed
90

91 92
    await tester.tap(find.text('25'));
    await tester.pumpAndSettle();
93
    expect(_selectedDate, equals(new DateTime(2016, DateTime.september, 25)));
Ian Hickson's avatar
Ian Hickson committed
94

95 96
    await tester.drag(find.byKey(_datePickerKey), const Offset(800.0, 0.0));
    await tester.pumpAndSettle();
97
    expect(_selectedDate, equals(new DateTime(2016, DateTime.september, 25)));
Ian Hickson's avatar
Ian Hickson committed
98

99 100
    await tester.tap(find.text('17'));
    await tester.pumpAndSettle();
101
    expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 17)));
Ian Hickson's avatar
Ian Hickson committed
102 103 104 105
  });

  testWidgets('render picker with intrinsic dimensions', (WidgetTester tester) async {
    await tester.pumpWidget(
106 107 108 109 110 111 112 113 114 115 116
      new MaterialApp(
        home: new StatefulBuilder(
          builder: (BuildContext context, StateSetter setState) {
            return new IntrinsicWidth(
              child: new IntrinsicHeight(
                child: new Material(
                  child: new SingleChildScrollView(
                    child: new MonthPicker(
                      firstDate: new DateTime(0),
                      lastDate: new DateTime(9999),
                      onChanged: (DateTime value) { },
117
                      selectedDate: new DateTime(2000, DateTime.january, 1),
118 119
                    ),
                  ),
120 121 122 123 124
                ),
              ),
            );
          },
        ),
125
      ),
Ian Hickson's avatar
Ian Hickson committed
126 127 128 129
    );
    await tester.pump(const Duration(seconds: 5));
  });

130 131 132 133 134 135 136 137 138 139
  Future<Null> preparePicker(WidgetTester tester, Future<Null> callback(Future<DateTime> date)) async {
    BuildContext buttonContext;
    await tester.pumpWidget(new MaterialApp(
      home: new Material(
        child: new Builder(
          builder: (BuildContext context) {
            return new RaisedButton(
              onPressed: () {
                buttonContext = context;
              },
140
              child: const Text('Go'),
141 142 143 144 145 146 147 148 149
            );
          },
        ),
      ),
    ));

    await tester.tap(find.text('Go'));
    expect(buttonContext, isNotNull);

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
    final Future<DateTime> date = initialDatePickerMode == null
        // Exercise the argument default for initialDatePickerMode.
        ?
            showDatePicker(
              context: buttonContext,
              initialDate: initialDate,
              firstDate: firstDate,
              lastDate: lastDate,
              selectableDayPredicate: selectableDayPredicate,
            )
        :
            showDatePicker(
              context: buttonContext,
              initialDate: initialDate,
              firstDate: firstDate,
              lastDate: lastDate,
              selectableDayPredicate: selectableDayPredicate,
              initialDatePickerMode: initialDatePickerMode,
            );
169

170
    await tester.pumpAndSettle(const Duration(seconds: 1));
171 172 173 174 175 176
    await callback(date);
  }

  testWidgets('Initial date is the default', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('OK'));
177
      expect(await date, equals(new DateTime(2016, DateTime.january, 15)));
178 179 180 181 182 183 184 185 186 187 188 189 190 191
    });
  });

  testWidgets('Can cancel', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('CANCEL'));
      expect(await date, isNull);
    });
  });

  testWidgets('Can select a day', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('12'));
      await tester.tap(find.text('OK'));
192
      expect(await date, equals(new DateTime(2016, DateTime.january, 12)));
193 194 195 196 197
    });
  });

  testWidgets('Can select a month', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
198
      await tester.tap(previousMonthIcon);
199
      await tester.pumpAndSettle(const Duration(seconds: 1));
200 201
      await tester.tap(find.text('25'));
      await tester.tap(find.text('OK'));
202
      expect(await date, equals(new DateTime(2015, DateTime.december, 25)));
203 204 205 206 207 208 209
    });
  });

  testWidgets('Can select a year', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('2016'));
      await tester.pump();
210
      await tester.tap(find.text('2018'));
211
      await tester.tap(find.text('OK'));
212
      expect(await date, equals(new DateTime(2018, DateTime.january, 15)));
213 214 215 216 217 218 219
    });
  });

  testWidgets('Can select a year and then a day', (WidgetTester tester) async {
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('2016'));
      await tester.pump();
220
      await tester.tap(find.text('2017'));
221
      await tester.pump();
Yegor's avatar
Yegor committed
222 223 224
      final MaterialLocalizations localizations = MaterialLocalizations.of(
        tester.element(find.byType(DayPicker))
      );
225
      final String dayLabel = localizations.formatMediumDate(new DateTime(2017, DateTime.january, 15));
226 227 228 229
      await tester.tap(find.text(dayLabel));
      await tester.pump();
      await tester.tap(find.text('19'));
      await tester.tap(find.text('OK'));
230
      expect(await date, equals(new DateTime(2017, DateTime.january, 19)));
231 232 233 234 235 236 237 238 239 240 241
    });
  });

  testWidgets('Current year is initially visible in year picker', (WidgetTester tester) async {
    initialDate = new DateTime(2000);
    firstDate = new DateTime(1900);
    lastDate = new DateTime(2100);
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('2000'));
      await tester.pump();
      expect(find.text('2000'), findsNWidgets(2));
242 243
    });
  });
244 245

  testWidgets('Cannot select a day outside bounds', (WidgetTester tester) async {
246
    initialDate = new DateTime(2017, DateTime.january, 15);
247 248 249 250 251 252
    firstDate = initialDate;
    lastDate = initialDate;
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('10')); // Earlier than firstDate. Should be ignored.
      await tester.tap(find.text('20')); // Later than lastDate. Should be ignored.
      await tester.tap(find.text('OK'));
253
      // We should still be on the initial date.
254 255 256 257 258
      expect(await date, equals(initialDate));
    });
  });

  testWidgets('Cannot select a month past last date', (WidgetTester tester) async {
259
    initialDate = new DateTime(2017, DateTime.january, 15);
260
    firstDate = initialDate;
261
    lastDate = new DateTime(2017, DateTime.february, 20);
262
    await preparePicker(tester, (Future<DateTime> date) async {
263
      await tester.tap(nextMonthIcon);
264
      await tester.pumpAndSettle(const Duration(seconds: 1));
265
      // Shouldn't be possible to keep going into March.
266
      expect(nextMonthIcon, findsNothing);
267 268 269 270
    });
  });

  testWidgets('Cannot select a month before first date', (WidgetTester tester) async {
271 272
    initialDate = new DateTime(2017, DateTime.january, 15);
    firstDate = new DateTime(2016, DateTime.december, 10);
273 274
    lastDate = initialDate;
    await preparePicker(tester, (Future<DateTime> date) async {
275
      await tester.tap(previousMonthIcon);
276
      await tester.pumpAndSettle(const Duration(seconds: 1));
277
      // Shouldn't be possible to keep going into November.
278
      expect(previousMonthIcon, findsNothing);
279 280
    });
  });
281 282

  testWidgets('Only predicate days are selectable', (WidgetTester tester) async {
283 284 285
    initialDate = new DateTime(2017, DateTime.january, 16);
    firstDate = new DateTime(2017, DateTime.january, 10);
    lastDate = new DateTime(2017, DateTime.january, 20);
286 287 288 289 290 291
    selectableDayPredicate = (DateTime day) => day.day.isEven;
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.tap(find.text('10')); // Even, works.
      await tester.tap(find.text('13')); // Odd, doesn't work.
      await tester.tap(find.text('17')); // Odd, doesn't work.
      await tester.tap(find.text('OK'));
292
      expect(await date, equals(new DateTime(2017, DateTime.january, 10)));
293 294
    });
  });
295

296
  testWidgets('Can select initial date picker mode', (WidgetTester tester) async {
297
    initialDate = new DateTime(2014, DateTime.january, 15);
298 299 300 301 302 303 304
    initialDatePickerMode = DatePickerMode.year;
    await preparePicker(tester, (Future<DateTime> date) async {
      await tester.pump();
      // 2018 wouldn't be available if the year picker wasn't showing.
      // The initial current year is 2014.
      await tester.tap(find.text('2018'));
      await tester.tap(find.text('OK'));
305
      expect(await date, equals(new DateTime(2018, DateTime.january, 15)));
306 307 308
    });
  });

309 310
  group('haptic feedback', () {
    const Duration kHapticFeedbackInterval = const Duration(milliseconds: 10);
311
    FeedbackTester feedback;
312 313

    setUp(() {
314
      feedback = new FeedbackTester();
315 316 317
      initialDate = new DateTime(2017, DateTime.january, 16);
      firstDate = new DateTime(2017, DateTime.january, 10);
      lastDate = new DateTime(2018, DateTime.january, 20);
318 319 320
      selectableDayPredicate = (DateTime date) => date.day.isEven;
    });

321 322 323 324
    tearDown(() {
      feedback?.dispose();
    });

325 326 327 328
    testWidgets('tap-select date vibrates', (WidgetTester tester) async {
      await preparePicker(tester, (Future<DateTime> date) async {
        await tester.tap(find.text('10'));
        await tester.pump(kHapticFeedbackInterval);
329
        expect(feedback.hapticCount, 1);
330 331
        await tester.tap(find.text('12'));
        await tester.pump(kHapticFeedbackInterval);
332
        expect(feedback.hapticCount, 2);
333 334
        await tester.tap(find.text('14'));
        await tester.pump(kHapticFeedbackInterval);
335
        expect(feedback.hapticCount, 3);
336 337 338 339 340 341 342
      });
    });

    testWidgets('tap-select unselectable date does not vibrate', (WidgetTester tester) async {
      await preparePicker(tester, (Future<DateTime> date) async {
        await tester.tap(find.text('11'));
        await tester.pump(kHapticFeedbackInterval);
343
        expect(feedback.hapticCount, 0);
344 345
        await tester.tap(find.text('13'));
        await tester.pump(kHapticFeedbackInterval);
346
        expect(feedback.hapticCount, 0);
347 348
        await tester.tap(find.text('15'));
        await tester.pump(kHapticFeedbackInterval);
349
        expect(feedback.hapticCount, 0);
350 351 352 353 354 355 356
      });
    });

    testWidgets('mode, year change vibrates', (WidgetTester tester) async {
      await preparePicker(tester, (Future<DateTime> date) async {
        await tester.tap(find.text('2017'));
        await tester.pump(kHapticFeedbackInterval);
357
        expect(feedback.hapticCount, 1);
358 359
        await tester.tap(find.text('2018'));
        await tester.pump(kHapticFeedbackInterval);
360
        expect(feedback.hapticCount, 2);
361 362
      });
    });
363

364
  });
365 366 367 368 369 370 371 372 373

  test('days in month', () {
    expect(DayPicker.getDaysInMonth(2017, 10), 31);
    expect(DayPicker.getDaysInMonth(2017, 6), 30);
    expect(DayPicker.getDaysInMonth(2017, 2), 28);
    expect(DayPicker.getDaysInMonth(2016, 2), 29);
    expect(DayPicker.getDaysInMonth(2000, 2), 29);
    expect(DayPicker.getDaysInMonth(1900, 2), 28);
  });
374 375 376 377 378 379 380 381 382 383 384 385 386

  testWidgets('month header tap', (WidgetTester tester) async {
    selectableDayPredicate = null;
    await preparePicker(tester, (Future<DateTime> date) async {
      // Switch into the year selector.
      await tester.tap(find.text('January 2016'));
      await tester.pump();
      expect(find.text('2020'), isNotNull);

      await tester.tap(find.text('CANCEL'));
      expect(await date, isNull);
    });
  });
387 388 389 390 391

  testWidgets('exports semantics', (WidgetTester tester) async {
    final SemanticsTester semantics = new SemanticsTester(tester);
    await preparePicker(tester, (Future<DateTime> date) async {
      final TestSemantics expected = new TestSemantics(
392 393 394
        flags: <SemanticsFlag>[
          SemanticsFlag.scopesRoute,
        ],
395 396 397
        children: <TestSemantics>[
          new TestSemantics(
            actions: <SemanticsAction>[SemanticsAction.tap],
398
            label: '2016',
399 400 401
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
402
            flags: <SemanticsFlag>[SemanticsFlag.isSelected],
403
            actions: <SemanticsAction>[SemanticsAction.tap],
404
            label: 'Fri, Jan 15',
405 406 407 408 409 410 411
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
            children: <TestSemantics>[
              new TestSemantics(
                children: <TestSemantics>[
                  new TestSemantics(
412
                    actions: <SemanticsAction>[SemanticsAction.scrollLeft, SemanticsAction.scrollRight],
413 414 415 416
                    children: <TestSemantics>[
                      new TestSemantics(
                        children: <TestSemantics>[
                          new TestSemantics(
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
                            children: <TestSemantics>[
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '1, Friday, January 1, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '2, Saturday, January 2, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '3, Sunday, January 3, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '4, Monday, January 4, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '5, Tuesday, January 5, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '6, Wednesday, January 6, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '7, Thursday, January 7, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '8, Friday, January 8, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '9, Saturday, January 9, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '10, Sunday, January 10, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '11, Monday, January 11, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '12, Tuesday, January 12, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '13, Wednesday, January 13, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '14, Thursday, January 14, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                flags: <SemanticsFlag>[SemanticsFlag.isSelected],
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '15, Friday, January 15, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '16, Saturday, January 16, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '17, Sunday, January 17, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '18, Monday, January 18, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '19, Tuesday, January 19, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '20, Wednesday, January 20, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '21, Thursday, January 21, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '22, Friday, January 22, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '23, Saturday, January 23, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '24, Sunday, January 24, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '25, Monday, January 25, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '26, Tuesday, January 26, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '27, Wednesday, January 27, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '28, Thursday, January 28, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '29, Friday, January 29, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '30, Saturday, January 30, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                              new TestSemantics(
                                actions: <SemanticsAction>[SemanticsAction.tap],
                                label: '31, Sunday, January 31, 2016',
                                textDirection: TextDirection.ltr,
                              ),
                            ],
575 576 577 578 579 580 581 582 583 584
                          ),
                        ],
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
          new TestSemantics(
585
            flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
586
            actions: <SemanticsAction>[SemanticsAction.tap],
587
            label: 'Previous month December 2015',
588 589 590
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
591
            flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
592
            actions: <SemanticsAction>[SemanticsAction.tap],
593
            label: 'Next month February 2016',
594 595 596
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
597
            flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
598
            actions: <SemanticsAction>[SemanticsAction.tap],
599
            label: 'CANCEL',
600 601 602
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
603
            flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
604
            actions: <SemanticsAction>[SemanticsAction.tap],
605
            label: 'OK',
606 607 608 609 610 611
            textDirection: TextDirection.ltr,
          ),
        ],
      );

      expect(semantics, hasSemantics(
612 613 614 615 616
        new TestSemantics.root(children: <TestSemantics>[
          new TestSemantics(
            children: <TestSemantics>[expected],
          ),
        ]),
617 618 619 620 621
        ignoreId: true,
        ignoreTransform: true,
        ignoreRect: true,
      ));
    });
622 623

    semantics.dispose();
624
  });
Ian Hickson's avatar
Ian Hickson committed
625
}