Skip to content

Commit

Permalink
add golden tests for CupertinoDatePicker (flutter#30828)
Browse files Browse the repository at this point in the history
Add golden tests for CupertinoDatePicker
  • Loading branch information
LongCatIsLooong authored Apr 11, 2019
1 parent 8ca7c4c commit b8a1870
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/internal/goldens.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
894e9634cda6eb940d1ad4efb20b63a174bb7797
cb8264b1953000a603ecc2659ece3483859438a1
33 changes: 33 additions & 0 deletions packages/flutter/test/cupertino/date_picker_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2017 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.

import 'dart:io' show Platform;
import 'dart:ui';

import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -811,6 +813,37 @@ void main() {
expect(lastSelectedItem, 1);
handle.dispose();
});

testWidgets('DatePicker golden tests', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: SizedBox(
width: 200,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: DateTime(2019, 1, 1, 4),
onDateTimeChanged: (_) {},
)
)
)
);

await expectLater(
find.byType(CupertinoDatePicker),
matchesGoldenFile('date_picker_test.datetime.initial.png'),
skip: !Platform.isLinux
);

// Slightly drag the hour component to make the current hour off-center.
await tester.drag(find.text('4'), Offset(0, _kRowOffset.dy / 2));
await tester.pump();

await expectLater(
find.byType(CupertinoDatePicker),
matchesGoldenFile('date_picker_test.datetime.drag.png'),
skip: !Platform.isLinux
);
});
}

Widget _buildPicker({ FixedExtentScrollController controller, ValueChanged<int> onSelectedItemChanged }) {
Expand Down

0 comments on commit b8a1870

Please sign in to comment.