Skip to content

Instantly share code, notes, and snippets.

@albertusdev
Created February 27, 2019 16:41
Show Gist options
  • Save albertusdev/500baba1d153ad8b30a89ab8e4bf1727 to your computer and use it in GitHub Desktop.
Save albertusdev/500baba1d153ad8b30a89ab8e4bf1727 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:frontend/image_picker_bottom_sheet.dart'
as ImagePickerBottomSheet;
void main() {
testWidgets(
'Bottom sheet should appear and show choose from gallery or take a new picture text',
(WidgetTester tester) async {
BuildContext savedContext;
await tester
.pumpWidget(MaterialApp(home: Builder(builder: (BuildContext context) {
savedContext = context;
return Container();
})));
await tester.pump();
expect(
find.text(ImagePickerBottomSheet.kTakeANewPictureText), findsNothing);
expect(
find.text(ImagePickerBottomSheet.kChooseFromGalleryText), findsNothing);
ImagePickerBottomSheet.showImagePickerBottomSheet(savedContext);
await tester.pump(); // Bottom sheet show animation starts
await tester.pump(const Duration(seconds: 2)); // animation done
expect(find.text(ImagePickerBottomSheet.kChooseFromGalleryText),
findsOneWidget);
expect(
find.text(ImagePickerBottomSheet.kTakeANewPictureText), findsOneWidget);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment