mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-18 19:53:45 +02:00
Added UI tests and attempt at service test
This commit is contained in:
parent
4953dbe853
commit
4ede413ee4
7 changed files with 113 additions and 150 deletions
|
@ -1 +1 @@
|
|||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.5+6\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+2\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]}],"date_created":"2022-09-01 12:25:01.884569","version":"3.0.5"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.5+6\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+2\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]}],"date_created":"2022-09-02 13:54:18.406312","version":"3.0.5"}
|
|
@ -1,27 +1,6 @@
|
|||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "46.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.6.0"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -36,27 +15,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.1"
|
||||
built_value:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -78,13 +36,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_builder
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.2.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -92,13 +43,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -106,13 +50,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.3+1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -120,13 +57,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -134,20 +64,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -184,13 +100,6 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -254,13 +163,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -282,20 +184,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
mockito:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mockito
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.3.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -310,25 +198,11 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_gen:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_gen
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.2"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -385,20 +259,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
sdks:
|
||||
dart: ">=2.17.6 <3.0.0"
|
||||
flutter: ">=2.8.0"
|
||||
|
|
|
@ -38,8 +38,6 @@ dependencies:
|
|||
flutter_image_picker:
|
||||
path: ../
|
||||
|
||||
mockito: ^5.3.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
@ -11,12 +11,12 @@ dependencies:
|
|||
flutter:
|
||||
sdk: flutter
|
||||
image_picker: ^0.8.5+3
|
||||
mockito: ^5.3.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^2.0.0
|
||||
mocktail: ^0.3.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
4
test/mocks/image_picker_mock.dart
Normal file
4
test/mocks/image_picker_mock.dart
Normal file
|
@ -0,0 +1,4 @@
|
|||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class ImagePickerMock extends Mock implements ImagePicker {}
|
|
@ -1,3 +1,45 @@
|
|||
main() {
|
||||
// import 'dart:typed_data';
|
||||
|
||||
}
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_image_picker/src/services/image_picker_service.dart';
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
// import 'package:image_picker/image_picker.dart';
|
||||
// import 'package:mocktail/mocktail.dart';
|
||||
|
||||
// import '../../mocks/image_picker_mock.dart';
|
||||
|
||||
// void main() {
|
||||
// WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// late ImagePickerMock imagePickerMock;
|
||||
// late ImagePickerService sut;
|
||||
|
||||
// setUp(() {
|
||||
// imagePickerMock = ImagePickerMock();
|
||||
// sut = ImagePickerService();
|
||||
// });
|
||||
|
||||
// group("Image Picker Test with camera option", () {
|
||||
// setUp(() {
|
||||
// imagePickerMock = ImagePickerMock();
|
||||
// sut = ImagePickerService();
|
||||
// });
|
||||
// test("When function called with Camera parameter returns correct picture",
|
||||
// () async {
|
||||
// // Setup the neccesary variables to test
|
||||
// XFile? xFile = XFile("Test", bytes: Uint8List(50));
|
||||
|
||||
// // //Mock the pickImage function of the image picker to return an image
|
||||
// when(() => imagePickerMock.pickImage(source: ImageSource.gallery))
|
||||
// .thenAnswer((_) => Future.value(xFile));
|
||||
|
||||
// // Execute test
|
||||
// var image = await sut.pickImage(ImageSource.gallery);
|
||||
|
||||
// // //Assert test
|
||||
// expect(image, Uint8List(50));
|
||||
// });
|
||||
// });
|
||||
|
||||
// group("Image Picker Widget with gallery option", () {});
|
||||
// }
|
||||
|
|
|
@ -1,3 +1,62 @@
|
|||
main() {
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_image_picker/image_picker.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Image Picker Shows With Normal Theme', (tester) async {
|
||||
await tester.pumpWidget(MaterialApp(home: Material(child: ImagePicker())));
|
||||
|
||||
final titleFinder = find.text(const ImagePickerTheme().title);
|
||||
final makePhotoIconFinder =
|
||||
find.byIcon(const ImagePickerTheme().makePhotoIcon);
|
||||
final makePhotoTextFinder =
|
||||
find.text(const ImagePickerTheme().makePhotoText);
|
||||
final selectImageIconFinder =
|
||||
find.byIcon(const ImagePickerTheme().selectImageIcon);
|
||||
final selectImageTextFinder =
|
||||
find.text(const ImagePickerTheme().selectImageText);
|
||||
final closebuttonTextFinder =
|
||||
find.text(const ImagePickerTheme().closeButtonText);
|
||||
|
||||
expect(titleFinder, findsOneWidget);
|
||||
expect(makePhotoIconFinder, findsOneWidget);
|
||||
expect(makePhotoTextFinder, findsOneWidget);
|
||||
expect(selectImageIconFinder, findsOneWidget);
|
||||
expect(selectImageTextFinder, findsOneWidget);
|
||||
expect(closebuttonTextFinder, findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
|
||||
String title = "title";
|
||||
IconData makePhotoIcon = Icons.motorcycle;
|
||||
String makePhotoText = "taaaake image";
|
||||
IconData selectImageIcon = Icons.chevron_left;
|
||||
String selectImageText = "seleeeeect image";
|
||||
String closeButtonText = "Close Dialog!";
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(
|
||||
child: ImagePicker(
|
||||
imagePickerTheme: ImagePickerTheme(
|
||||
title: title,
|
||||
makePhotoIcon: makePhotoIcon,
|
||||
makePhotoText: makePhotoText,
|
||||
selectImageIcon: selectImageIcon,
|
||||
selectImageText: selectImageText,
|
||||
closeButtonText: closeButtonText)))));
|
||||
|
||||
final titleFinder = find.text(title);
|
||||
final makePhotoIconFinder = find.byIcon(makePhotoIcon);
|
||||
final makePhotoTextFinder = find.text(makePhotoText);
|
||||
final selectImageIconFinder = find.byIcon(selectImageIcon);
|
||||
final selectImageTextFinder = find.text(selectImageText);
|
||||
final closebuttonTextFinder = find.text(closeButtonText);
|
||||
|
||||
expect(titleFinder, findsOneWidget);
|
||||
expect(makePhotoIconFinder, findsOneWidget);
|
||||
expect(makePhotoTextFinder, findsOneWidget);
|
||||
expect(selectImageIconFinder, findsOneWidget);
|
||||
expect(selectImageTextFinder, findsOneWidget);
|
||||
expect(closebuttonTextFinder, findsOneWidget);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue