date_picker_test.dart 25.4 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';

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

10
import '../widgets/semantics_tester.dart';
11 12
import 'feedback_tester.dart';

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

void _tests() {
20 21 22
  DateTime firstDate;
  DateTime lastDate;
  DateTime initialDate;
23
  SelectableDayPredicate selectableDayPredicate;
24
  DatePickerMode initialDatePickerMode;
25 26
  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));
27 28

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

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

    await tester.pumpWidget(
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
      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;
                      });
                    },
58
                  ),
59 60 61 62 63 64
                ),
              ),
            );
          },
        ),
      )
Ian Hickson's avatar
Ian Hickson committed
65
    );
66

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

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

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

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

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

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

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

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

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

  testWidgets('render picker with intrinsic dimensions', (WidgetTester tester) async {
    await tester.pumpWidget(
104 105 106 107 108 109 110 111 112 113 114
      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) { },
115
                      selectedDate: new DateTime(2000, DateTime.january, 1),
116 117
                    ),
                  ),
118 119 120 121 122
                ),
              ),
            );
          },
        ),
123
      ),
Ian Hickson's avatar
Ian Hickson committed
124 125 126 127
    );
    await tester.pump(const Duration(seconds: 5));
  });

128 129 130 131 132 133 134 135 136 137
  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;
              },
138
              child: const Text('Go'),
139 140 141 142 143 144 145 146 147
            );
          },
        ),
      ),
    ));

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

148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    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,
            );
167

168
    await tester.pumpAndSettle(const Duration(seconds: 1));
169 170 171 172 173 174
    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'));
175
      expect(await date, equals(new DateTime(2016, DateTime.january, 15)));
176 177 178 179 180 181 182 183 184 185 186 187 188 189
    });
  });

  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'));
190
      expect(await date, equals(new DateTime(2016, DateTime.january, 12)));
191 192 193 194 195
    });
  });

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

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

  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();
218
      await tester.tap(find.text('2017'));
219
      await tester.pump();
Yegor's avatar
Yegor committed
220 221 222
      final MaterialLocalizations localizations = MaterialLocalizations.of(
        tester.element(find.byType(DayPicker))
      );
223
      final String dayLabel = localizations.formatMediumDate(new DateTime(2017, DateTime.january, 15));
224 225 226 227
      await tester.tap(find.text(dayLabel));
      await tester.pump();
      await tester.tap(find.text('19'));
      await tester.tap(find.text('OK'));
228
      expect(await date, equals(new DateTime(2017, DateTime.january, 19)));
229 230 231 232 233 234 235 236 237 238 239
    });
  });

  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));
240 241
    });
  });
242 243

  testWidgets('Cannot select a day outside bounds', (WidgetTester tester) async {
244
    initialDate = new DateTime(2017, DateTime.january, 15);
245 246 247 248 249 250
    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'));
251
      // We should still be on the initial date.
252 253 254 255 256
      expect(await date, equals(initialDate));
    });
  });

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

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

  testWidgets('Only predicate days are selectable', (WidgetTester tester) async {
281 282 283
    initialDate = new DateTime(2017, DateTime.january, 16);
    firstDate = new DateTime(2017, DateTime.january, 10);
    lastDate = new DateTime(2017, DateTime.january, 20);
284 285 286 287 288 289
    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'));
290
      expect(await date, equals(new DateTime(2017, DateTime.january, 10)));
291 292
    });
  });
293

294
  testWidgets('Can select initial date picker mode', (WidgetTester tester) async {
295
    initialDate = new DateTime(2014, DateTime.january, 15);
296 297 298 299 300 301 302
    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'));
303
      expect(await date, equals(new DateTime(2018, DateTime.january, 15)));
304 305 306
    });
  });

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

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

319 320 321 322
    tearDown(() {
      feedback?.dispose();
    });

323 324 325 326
    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);
327
        expect(feedback.hapticCount, 1);
328 329
        await tester.tap(find.text('12'));
        await tester.pump(kHapticFeedbackInterval);
330
        expect(feedback.hapticCount, 2);
331 332
        await tester.tap(find.text('14'));
        await tester.pump(kHapticFeedbackInterval);
333
        expect(feedback.hapticCount, 3);
334 335 336 337 338 339 340
      });
    });

    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);
341
        expect(feedback.hapticCount, 0);
342 343
        await tester.tap(find.text('13'));
        await tester.pump(kHapticFeedbackInterval);
344
        expect(feedback.hapticCount, 0);
345 346
        await tester.tap(find.text('15'));
        await tester.pump(kHapticFeedbackInterval);
347
        expect(feedback.hapticCount, 0);
348 349 350 351 352 353 354
      });
    });

    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);
355
        expect(feedback.hapticCount, 1);
356 357
        await tester.tap(find.text('2018'));
        await tester.pump(kHapticFeedbackInterval);
358
        expect(feedback.hapticCount, 2);
359 360
      });
    });
361

362
  });
363 364 365 366 367 368 369 370 371

  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);
  });
372 373 374 375 376 377 378 379 380 381 382 383 384

  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);
    });
  });
385 386 387 388 389 390 391 392 393 394 395 396

  testWidgets('exports semantics', (WidgetTester tester) async {
    final SemanticsTester semantics = new SemanticsTester(tester);
    await preparePicker(tester, (Future<DateTime> date) async {
      final TestSemantics expected = new TestSemantics(
        children: <TestSemantics>[
          new TestSemantics(
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'2016',
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
397
            flags: <SemanticsFlag>[SemanticsFlag.isSelected],
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 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
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'Fri, Jan 15',
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
            children: <TestSemantics>[
              new TestSemantics(
                actions: <SemanticsAction>[SemanticsAction.scrollLeft, SemanticsAction.scrollRight],
                children: <TestSemantics>[
                  new TestSemantics(
                    children: <TestSemantics>[
                      new TestSemantics(
                        children: <TestSemantics>[
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'1, Friday, January 1, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'2, Saturday, January 2, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'3, Sunday, January 3, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'4, Monday, January 4, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'5, Tuesday, January 5, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'6, Wednesday, January 6, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'7, Thursday, January 7, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'8, Friday, January 8, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'9, Saturday, January 9, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'10, Sunday, January 10, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'11, Monday, January 11, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'12, Tuesday, January 12, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'13, Wednesday, January 13, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'14, Thursday, January 14, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
482
                            flags: <SemanticsFlag>[SemanticsFlag.isSelected],
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 575
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'15, Friday, January 15, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'16, Saturday, January 16, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'17, Sunday, January 17, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'18, Monday, January 18, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'19, Tuesday, January 19, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'20, Wednesday, January 20, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'21, Thursday, January 21, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'22, Friday, January 22, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'23, Saturday, January 23, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'24, Sunday, January 24, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'25, Monday, January 25, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'26, Tuesday, January 26, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'27, Wednesday, January 27, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'28, Thursday, January 28, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'29, Friday, January 29, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'30, Saturday, January 30, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                          new TestSemantics(
                            actions: <SemanticsAction>[SemanticsAction.tap],
                            label: r'31, Sunday, January 31, 2016',
                            textDirection: TextDirection.ltr,
                          ),
                        ],
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
          new TestSemantics(
576 577 578 579 580
            flags: <SemanticsFlag>[
              SemanticsFlag.isButton,
              SemanticsFlag.hasEnabledState,
              SemanticsFlag.isEnabled,
            ],
581 582 583 584 585
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'Previous month December 2015',
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
586 587 588 589 590
            flags: <SemanticsFlag>[
              SemanticsFlag.isButton,
              SemanticsFlag.hasEnabledState,
              SemanticsFlag.isEnabled,
            ],
591 592 593 594 595
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'Next month February 2016',
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
596 597 598 599 600
            flags: <SemanticsFlag>[
              SemanticsFlag.isButton,
              SemanticsFlag.hasEnabledState,
              SemanticsFlag.isEnabled,
            ],
601 602 603 604 605
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'CANCEL',
            textDirection: TextDirection.ltr,
          ),
          new TestSemantics(
606 607 608 609 610
            flags: <SemanticsFlag>[
              SemanticsFlag.isButton,
              SemanticsFlag.hasEnabledState,
              SemanticsFlag.isEnabled,
            ],
611 612 613 614 615 616 617 618 619 620 621 622 623 624
            actions: <SemanticsAction>[SemanticsAction.tap],
            label: r'OK',
            textDirection: TextDirection.ltr,
          ),
        ],
      );

      expect(semantics, hasSemantics(
        expected,
        ignoreId: true,
        ignoreTransform: true,
        ignoreRect: true,
      ));
    });
625 626

    semantics.dispose();
627
  });
Ian Hickson's avatar
Ian Hickson committed
628
}