flutter_date_time_picker/test/flutter_date_time_picker_test.dart

67 lines
1.8 KiB
Dart
Raw Permalink Normal View History

2022-11-01 09:43:38 +01:00
// SPDX-FileCopyrightText: 2022 Iconica
//
// SPDX-License-Identifier: BSD-3-Clause
2022-09-01 16:09:20 +02:00
import 'package:flutter/material.dart';
2022-08-26 09:56:44 +02:00
import 'package:flutter_date_time_picker/flutter_date_time_picker.dart';
2022-09-02 14:58:14 +02:00
import 'package:flutter_test/flutter_test.dart';
2022-08-26 09:56:44 +02:00
void main() {
2022-09-02 14:58:14 +02:00
testWidgets('Render App with DateTimePicker Widget', (tester) async {
// Render App
await tester.pumpWidget(MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: DragDownDateTimePicker(
controller: DateTimePickerController(
initialDate: DateTime.now(),
),
configuration: DateTimePickerConfiguration(
theme: const DateTimePickerTheme(),
highlightToday: true,
pickTime: false,
),
2022-09-02 14:58:14 +02:00
child: Container(),
),
),
));
await tester.pump();
});
testWidgets('Test if DateTimePicker Widget swipes', (tester) async {
// Render App
await tester.pumpWidget(MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: DragDownDateTimePicker(
controller: DateTimePickerController(
initialDate: DateTime.now(),
),
configuration: DateTimePickerConfiguration(
theme: const DateTimePickerTheme(),
highlightToday: true,
pickTime: false,
),
2022-09-02 14:58:14 +02:00
child: Container(),
),
2022-09-01 16:09:20 +02:00
),
));
2022-09-02 14:58:14 +02:00
await tester.pump();
// Forward
await tester.drag(
find.byType(SingleChildScrollView), const Offset(500.0, 0.0));
await tester.pumpAndSettle();
// Return
await tester.drag(
find.byType(SingleChildScrollView), const Offset(-500.0, 0.0));
await tester.pumpAndSettle();
// Backward
await tester.drag(
find.byType(SingleChildScrollView), const Offset(-500.0, 0.0));
await tester.pumpAndSettle();
2022-08-26 09:56:44 +02:00
});
}