cleanup and added unit tests

This commit is contained in:
verboomp
2026-01-27 14:09:12 +01:00
parent 3d456128b1
commit e4b2dd0462
42 changed files with 1467 additions and 977 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/mockito.dart';
import '../testing/test_http_client_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
var jwtTokenStorage = MockJwtTokenStorage();
when(jwtTokenStorage.getAccessToken()).thenAnswer((_) async => null);
DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage);
LoginController controller = LoginControllerImpl();
group('LoginController', () {
test('authenticate returns JwtTokenPairDto on successful login', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(jwtTokenStorage.saveTokens(any, any)).thenAnswer((_) async => {});
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response(_jwtTokenPairJson, 200));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNotNull);
expect(reply.jwtTokenPairDto?.accessToken, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.access");
expect(reply.jwtTokenPairDto?.refreshToken, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.refresh");
verify(jwtTokenStorage.saveTokens(any, any)).called(1);
});
test('authenticate returns null on authentication failure (401)', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response('Unauthorized', 401));
var reply = await controller.authenticate("wronguser", "wrongpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
test('authenticate returns null on server error (500)', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response('Internal Server Error', 500));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
test('authenticate returns null on exception', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenThrow(Exception('Network error'));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
});
}
String _jwtTokenPairJson = '''{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.access",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.refresh"
}''';

View File

@@ -0,0 +1,41 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/mockito.dart';
import '../testing/test_http_client_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
DiContainer.instance.initState();
var jwtTokenStorage = MockJwtTokenStorage();
when(jwtTokenStorage.getAccessToken()).thenAnswer((_) async => null);
DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage);
PictureController controller = PictureControllerImpl();
group('PictureControllerTest', () {
test('returns true if delete success', () async {
_testDelete(controller, 200, true);
});
test('returns false if delete failed', () async {
_testDelete(controller, 404, false);
});
});
}
void _testDelete(PictureController controller, int response, bool expected) async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.delete(Uri.parse('http://localhost:8080/api/picture/4'), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response("", response));
var dto = await controller.delete(PictureDto(id: 4, image: "", pictureDate: DateTime.now(), category: "", comment: "", username: ""));
expect(dto, expected);
}

View File

@@ -0,0 +1,146 @@
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/main.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:fotodocumentation/utils/main_utils.dart';
import 'testing/test_utils.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('FotoDocumentationApp', () {
testWidgets('renders MaterialApp with router', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Verify MaterialApp.router is used
expect(find.byType(MaterialApp), findsOneWidget);
});
testWidgets('has correct app title', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify its title
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.title, equals('Hartmann Foto App'));
});
testWidgets('uses custom scroll behavior', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify its scrollBehavior type
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.scrollBehavior, isA<MyCustomScrollBehavior>());
});
testWidgets('supports German locale', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify German is in supported locales
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.supportedLocales, contains(const Locale('de')));
});
testWidgets('has localization delegates configured', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify localization delegates are set
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.localizationsDelegates, isNotNull);
expect(materialApp.localizationsDelegates!.length, equals(4));
});
testWidgets('applies provided theme', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final customTheme = ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.light,
);
await tester.pumpWidget(
FotoDocumentationApp(theme: customTheme),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify the theme is applied
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme, equals(customTheme));
});
testWidgets('applies dark theme when provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final darkTheme = ThemeData.dark();
await tester.pumpWidget(
FotoDocumentationApp(theme: darkTheme),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify the dark theme is applied
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme, equals(darkTheme));
});
testWidgets('uses router config', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify routerConfig is set
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.routerConfig, isNotNull);
});
});
group('MyCustomScrollBehavior', () {
test('includes touch pointer device', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior.dragDevices, contains(PointerDeviceKind.touch));
});
test('includes mouse pointer device', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior.dragDevices, contains(PointerDeviceKind.mouse));
});
test('extends MaterialScrollBehavior', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior, isA<MaterialScrollBehavior>());
});
});
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:mockito/mockito.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/dto/customer_dto.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import '../testing/test_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('Customer List Test', () {
testWidgets('Customer list screen search test', (WidgetTester tester) async {
await _searchtest(tester);
});
});
}
List<CustomerListDto> _list = [CustomerListDto(id: 1, customerNumber: "CODE1", name: "Customer 1"), CustomerListDto(id: 2, customerNumber: "CODE2", name: "Customer 2")];
Future<void> _searchtest(WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
String searchText = 'Henk';
var controller = MockCustomerController();
DiContainer.instance.put(CustomerController, controller);
when(controller.getAll("", "")).thenAnswer((_) async => _list);
when(controller.getAll(searchText, "")).thenAnswer((_) async => [_list.first]);
await pumpAppConfig(tester, GlobalRouter.pathHome);
verify(controller.getAll(argThat(equals("")), argThat(equals("")))).called(1);
await tester.enterText(find.byKey(Key("Search_text_field")), searchText);
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
verify(controller.getAll(searchText, "")).called(1);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,200 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/dto/jwt_token_pair_dto.dart';
import 'package:fotodocumentation/pages/login/login_widget.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:mockito/mockito.dart';
import '../testing/test_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
late MockLoginController mockLoginController;
late MockLoginCredentials mockLoginCredentials;
setUp(() {
mockLoginController = MockLoginController();
mockLoginCredentials = MockLoginCredentials();
when(mockLoginCredentials.isLoggedIn).thenReturn(false);
DiContainer.instance.put(LoginController, mockLoginController);
DiContainer.instance.put(LoginCredentials, mockLoginCredentials);
});
group('LoginWidget', () {
testWidgets('displays login title', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify the login title is displayed (German localization)
expect(find.text('BILDERUPLOAD'), findsOneWidget);
});
testWidgets('displays username and password fields', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify username field exists
expect(find.byKey(const Key("username")), findsOneWidget);
// Verify password field exists
expect(find.byKey(const Key("password")), findsOneWidget);
});
testWidgets('displays login button', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify login button exists
expect(find.byKey(const Key("SubmitWidgetButton")), findsOneWidget);
});
testWidgets('can enter username and password', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Enter username
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.pumpAndSettle();
// Enter password
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Verify text was entered
expect(find.text('testuser'), findsOneWidget);
});
testWidgets('calls authenticate on login button tap', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final jwtTokenPairDto = JwtTokenPairDto(
accessToken: 'test_access_token',
refreshToken: 'test_refresh_token',
);
when(mockLoginController.authenticate('testuser', 'testpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: jwtTokenPairDto));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify authenticate was called with correct credentials
verify(mockLoginController.authenticate('testuser', 'testpassword')).called(1);
});
testWidgets('sets logged in on successful authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final jwtTokenPairDto = JwtTokenPairDto(
accessToken: 'test_access_token',
refreshToken: 'test_refresh_token',
);
when(mockLoginController.authenticate('testuser', 'testpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: jwtTokenPairDto));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify setLoggedIn was called
verify(mockLoginCredentials.setLoggedIn(true)).called(1);
});
testWidgets('displays error message on failed authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
when(mockLoginController.authenticate('testuser', 'wrongpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: null));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'wrongpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify error message is displayed (German localization)
expect(find.text('Falscher Benutzername oder Passwort'), findsOneWidget);
});
testWidgets('does not call setLoggedIn on failed authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
when(mockLoginController.authenticate('testuser', 'wrongpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: null));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'wrongpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify setLoggedIn was NOT called
verifyNever(mockLoginCredentials.setLoggedIn(any));
});
testWidgets('password field obscures text', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Find the EditableText descendant of the password field
// TextFormField wraps TextField which contains EditableText
final passwordFieldFinder = find.byKey(const Key("password"));
final editableTextFinder = find.descendant(
of: passwordFieldFinder,
matching: find.byType(EditableText),
);
final editableText = tester.widget<EditableText>(editableTextFinder);
// Verify obscureText is true
expect(editableText.obscureText, isTrue);
});
});
}

View File

@@ -0,0 +1,258 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto;
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/customer/picture_widget.dart';
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import '../testing/test_utils.dart';
// Minimal valid base64 encoded 1x1 pixel PNG image
const String _testImage =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
late CustomerDto customerDto;
late PictureDto pictureDto1;
late PictureDto pictureDto2;
late PictureDto pictureDto3;
setUp(() {
pictureDto1 = PictureDto(
id: 1,
comment: 'First picture comment',
category: 'category1',
image: _testImage,
pictureDate: DateTime(2024, 1, 15),
username: 'user1',
);
pictureDto2 = PictureDto(
id: 2,
comment: 'Second picture comment',
category: 'category2',
image: _testImage,
pictureDate: DateTime(2024, 2, 20),
username: 'user2',
);
pictureDto3 = PictureDto(
id: 3,
comment: null,
category: 'category3',
image: _testImage,
pictureDate: DateTime(2024, 3, 25),
username: 'user3',
);
customerDto = CustomerDto(
id: 1,
name: 'Test Apotheke',
customerNumber: 'CUST001',
pictures: [pictureDto1, pictureDto2, pictureDto3],
);
});
group('PictureWidget', () {
testWidgets('displays customer information correctly', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify that the header is displayed
expect(find.text('INFORMATIONEN'), findsOneWidget);
// Verify customer name is displayed
expect(find.text('Test Apotheke'), findsOneWidget);
// Verify customer number is displayed
expect(find.text('CUST001'), findsOneWidget);
// Verify labels are displayed
expect(find.text('APOTHEKE'), findsOneWidget);
expect(find.text('KUNDENNUMMER'), findsOneWidget);
expect(find.text('DATUM'), findsOneWidget);
expect(find.text('KOMMENTAR'), findsOneWidget);
});
testWidgets('displays picture comment', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify the comment is displayed
expect(find.text('First picture comment'), findsOneWidget);
});
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
await tester.pumpAndSettle();
// The comment field should be empty but the label should exist
expect(find.text('KOMMENTAR'), findsOneWidget);
});
testWidgets('shows close button', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify close button icon exists
expect(find.byIcon(Icons.close), findsOneWidget);
});
testWidgets('shows right navigation button when there are more pictures', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// First picture should have right navigation (chevron_right), no left navigation
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
expect(find.byIcon(Icons.chevron_left), findsNothing);
});
testWidgets('shows left navigation button when not on first picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
await tester.pumpAndSettle();
// Middle picture should have both navigation buttons
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
});
testWidgets('shows only left navigation on last picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
await tester.pumpAndSettle();
// Last picture should have left navigation, no right navigation
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify first picture comment is shown
expect(find.text('First picture comment'), findsOneWidget);
// Tap right navigation button
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
// Verify second picture comment is now shown
expect(find.text('Second picture comment'), findsOneWidget);
expect(find.text('First picture comment'), findsNothing);
});
testWidgets('navigates to previous picture when left button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
await tester.pumpAndSettle();
// Verify second picture comment is shown
expect(find.text('Second picture comment'), findsOneWidget);
// Tap left navigation button
await tester.tap(find.byIcon(Icons.chevron_left));
await tester.pumpAndSettle();
// Verify first picture comment is now shown
expect(find.text('First picture comment'), findsOneWidget);
expect(find.text('Second picture comment'), findsNothing);
});
testWidgets('shows no navigation buttons when only one picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final singlePictureCustomer = CustomerDto(
id: 1,
name: 'Test Apotheke',
customerNumber: 'CUST001',
pictures: [pictureDto1],
);
await pumpApp(
tester,
PictureWidget(customerDto: singlePictureCustomer, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// No navigation buttons should be shown
expect(find.byIcon(Icons.chevron_left), findsNothing);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
setScreenSize(tester, 2048, 2048);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Find the GestureDetector with the image key
final imageFinder = find.byKey(const Key("image"));
expect(imageFinder, findsOneWidget);
// Ensure the widget is visible first
await tester.ensureVisible(imageFinder);
await tester.pumpAndSettle();
// Tap the image - use warnIfMissed: false since the Image.memory may have
// rendering issues in test environment but the GestureDetector should still work
await tester.tap(imageFinder, warnIfMissed: false);
await tester.pumpAndSettle();
// Verify fullscreen dialog is shown
expect(find.byType(PictureFullscreenDialog), findsOneWidget);
});
});
}

View File

@@ -0,0 +1,211 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/base_controller.dart';
import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import '../../testing/test_utils.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('GeneralErrorWidget', () {
testWidgets('displays error icon', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify error icon is displayed
expect(find.byIcon(Icons.error_outline), findsOneWidget);
});
testWidgets('displays error message with error text', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Something went wrong'),
);
await tester.pumpAndSettle();
// Verify error message is displayed (German localization: "Fehler: {name}")
expect(find.text('Fehler: Something went wrong'), findsOneWidget);
});
testWidgets('displays status code message when statusCode is provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: '', statusCode: 404),
);
await tester.pumpAndSettle();
// Verify status code message is displayed (German localization: "Statuscode {statusCode}")
expect(find.text('Statuscode 404'), findsOneWidget);
});
testWidgets('displays status code message for 500 error', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: '', statusCode: 500),
);
await tester.pumpAndSettle();
// Verify status code message is displayed
expect(find.text('Statuscode 500'), findsOneWidget);
});
testWidgets('does not display retry button when reload is null', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify retry button is not displayed
expect(find.byType(ElevatedButton), findsNothing);
expect(find.text('Wiederholen'), findsNothing);
});
testWidgets('displays retry button when reload is provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
GeneralErrorWidget(error: 'Test error', reload: () {}),
);
await tester.pumpAndSettle();
// Verify retry button is displayed (German localization: "Wiederholen")
expect(find.byType(ElevatedButton), findsOneWidget);
expect(find.text('Wiederholen'), findsOneWidget);
});
testWidgets('calls reload callback when retry button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
bool reloadCalled = false;
await pumpApp(
tester,
GeneralErrorWidget(
error: 'Test error',
reload: () {
reloadCalled = true;
},
),
);
await tester.pumpAndSettle();
// Tap retry button
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
// Verify reload was called
expect(reloadCalled, isTrue);
});
testWidgets('fromServerError factory creates widget with status code', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final serverError = ServerError(403);
await pumpApp(
tester,
GeneralErrorWidget.fromServerError(serverError),
);
await tester.pumpAndSettle();
// Verify status code message is displayed
expect(find.text('Statuscode 403'), findsOneWidget);
});
testWidgets('fromServerError factory with reload callback', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
bool reloadCalled = false;
final serverError = ServerError(401);
await pumpApp(
tester,
GeneralErrorWidget.fromServerError(
serverError,
reload: () {
reloadCalled = true;
},
),
);
await tester.pumpAndSettle();
// Verify status code is displayed
expect(find.text('Statuscode 401'), findsOneWidget);
// Verify retry button is displayed and functional
expect(find.text('Wiederholen'), findsOneWidget);
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
expect(reloadCalled, isTrue);
});
testWidgets('widget renders correctly', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify GeneralErrorWidget is rendered
expect(find.byType(GeneralErrorWidget), findsOneWidget);
// Verify it contains a Column for layout
final columnFinder = find.descendant(
of: find.byType(GeneralErrorWidget),
matching: find.byType(Column),
);
expect(columnFinder, findsOneWidget);
});
testWidgets('error icon has correct color', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Find the Icon widget and verify its color
final icon = tester.widget<Icon>(find.byIcon(Icons.error_outline));
expect(icon.color, equals(Colors.red[300]));
});
testWidgets('error icon has correct size', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Find the Icon widget and verify its size
final icon = tester.widget<Icon>(find.byIcon(Icons.error_outline));
expect(icon.size, equals(60));
});
});
}

View File

@@ -1,14 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/l10n/app_localizations.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'test_utils.mocks.dart';
@@ -20,6 +23,7 @@ void setScreenSize(WidgetTester tester, int width, int height) {
MockLoginCredentials getDefaultLoginCredentials() {
var mockLoginCredentials = MockLoginCredentials();
when(mockLoginCredentials.isLoggedIn).thenReturn(true);
return mockLoginCredentials;
}
@@ -58,9 +62,9 @@ Future<void> pumpAppConfig(WidgetTester tester, String initialLocation) async {
// dart run build_runner build
@GenerateMocks([
LoginCredentials,
LoginController,
CustomerController,
HeaderUtils,
SnackbarUtils,
PictureController,
JwtTokenStorage,
http.Client,
])

View File

@@ -3,20 +3,22 @@
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i11;
import 'dart:convert' as _i12;
import 'dart:typed_data' as _i13;
import 'dart:ui' as _i6;
import 'dart:async' as _i7;
import 'dart:convert' as _i14;
import 'dart:typed_data' as _i15;
import 'dart:ui' as _i5;
import 'package:flutter/material.dart' as _i2;
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart'
as _i9;
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart' as _i7;
import 'package:fotodocumentation/utils/jwt_token_storage.dart' as _i10;
import 'package:fotodocumentation/utils/login_credentials.dart' as _i4;
import 'package:http/http.dart' as _i3;
import 'package:fotodocumentation/controller/customer_controller.dart' as _i9;
import 'package:fotodocumentation/controller/login_controller.dart' as _i6;
import 'package:fotodocumentation/controller/picture_controller.dart' as _i11;
import 'package:fotodocumentation/dto/customer_dto.dart' as _i10;
import 'package:fotodocumentation/dto/jwt_token_pair_dto.dart' as _i8;
import 'package:fotodocumentation/dto/picture_dto.dart' as _i12;
import 'package:fotodocumentation/utils/jwt_token_storage.dart' as _i13;
import 'package:fotodocumentation/utils/login_credentials.dart' as _i3;
import 'package:http/http.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i5;
import 'package:mockito/src/dummies.dart' as _i4;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@@ -33,22 +35,8 @@ import 'package:mockito/src/dummies.dart' as _i5;
// ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member
class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget {
_FakeWidget_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
@override
String toString({_i2.DiagnosticLevel? minLevel = _i2.DiagnosticLevel.info}) =>
super.toString();
}
class _FakeResponse_1 extends _i1.SmartFake implements _i3.Response {
_FakeResponse_1(
class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
_FakeResponse_0(
Object parent,
Invocation parentInvocation,
) : super(
@@ -57,9 +45,9 @@ class _FakeResponse_1 extends _i1.SmartFake implements _i3.Response {
);
}
class _FakeStreamedResponse_2 extends _i1.SmartFake
implements _i3.StreamedResponse {
_FakeStreamedResponse_2(
class _FakeStreamedResponse_1 extends _i1.SmartFake
implements _i2.StreamedResponse {
_FakeStreamedResponse_1(
Object parent,
Invocation parentInvocation,
) : super(
@@ -71,7 +59,7 @@ class _FakeStreamedResponse_2 extends _i1.SmartFake
/// A class which mocks [LoginCredentials].
///
/// See the documentation for Mockito's code generation for more information.
class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
class MockLoginCredentials extends _i1.Mock implements _i3.LoginCredentials {
MockLoginCredentials() {
_i1.throwOnMissingStub(this);
}
@@ -79,18 +67,33 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
@override
String get fullname => (super.noSuchMethod(
Invocation.getter(#fullname),
returnValue: _i5.dummyValue<String>(
returnValue: _i4.dummyValue<String>(
this,
Invocation.getter(#fullname),
),
) as String);
@override
bool get isLoggedIn => (super.noSuchMethod(
Invocation.getter(#isLoggedIn),
returnValue: false,
) as bool);
@override
bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners),
returnValue: false,
) as bool);
@override
void setLoggedIn(bool? loggedIn) => super.noSuchMethod(
Invocation.method(
#setLoggedIn,
[loggedIn],
),
returnValueForMissingStub: null,
);
@override
void logout() => super.noSuchMethod(
Invocation.method(
@@ -101,7 +104,7 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
);
@override
void addListener(_i6.VoidCallback? listener) => super.noSuchMethod(
void addListener(_i5.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#addListener,
[listener],
@@ -110,7 +113,7 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
);
@override
void removeListener(_i6.VoidCallback? listener) => super.noSuchMethod(
void removeListener(_i5.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
#removeListener,
[listener],
@@ -137,85 +140,115 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
);
}
/// A class which mocks [HeaderUtils].
/// A class which mocks [LoginController].
///
/// See the documentation for Mockito's code generation for more information.
class MockHeaderUtils extends _i1.Mock implements _i7.HeaderUtils {
MockHeaderUtils() {
class MockLoginController extends _i1.Mock implements _i6.LoginController {
MockLoginController() {
_i1.throwOnMissingStub(this);
}
@override
_i2.Widget titleWidget(String? text) => (super.noSuchMethod(
_i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})> authenticate(
String? username,
String? password,
) =>
(super.noSuchMethod(
Invocation.method(
#titleWidget,
[text],
#authenticate,
[
username,
password,
],
),
returnValue: _FakeWidget_0(
this,
Invocation.method(
#titleWidget,
[text],
),
returnValue: _i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})>.value(
(jwtTokenPairDto: null)),
) as _i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})>);
@override
_i7.Future<bool> refreshAccessToken() => (super.noSuchMethod(
Invocation.method(
#refreshAccessToken,
[],
),
) as _i2.Widget);
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<bool> isUsingJwtAuth() => (super.noSuchMethod(
Invocation.method(
#isUsingJwtAuth,
[],
),
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
}
/// A class which mocks [SnackbarUtils].
/// A class which mocks [CustomerController].
///
/// See the documentation for Mockito's code generation for more information.
class MockSnackbarUtils extends _i1.Mock implements _i9.SnackbarUtils {
MockSnackbarUtils() {
class MockCustomerController extends _i1.Mock
implements _i9.CustomerController {
MockCustomerController() {
_i1.throwOnMissingStub(this);
}
@override
void showSnackbar(
_i2.BuildContext? context,
String? msg,
bool? warning,
_i7.Future<List<_i10.CustomerListDto>> getAll(
String? query,
String? startsWith,
) =>
super.noSuchMethod(
(super.noSuchMethod(
Invocation.method(
#showSnackbar,
#getAll,
[
context,
msg,
warning,
query,
startsWith,
],
),
returnValueForMissingStub: null,
);
returnValue: _i7.Future<List<_i10.CustomerListDto>>.value(
<_i10.CustomerListDto>[]),
) as _i7.Future<List<_i10.CustomerListDto>>);
@override
void showSnackbarPopup(
_i2.BuildContext? context,
String? msg,
bool? warning,
) =>
super.noSuchMethod(
_i7.Future<_i10.CustomerDto?> get({required int? id}) => (super.noSuchMethod(
Invocation.method(
#showSnackbarPopup,
[
context,
msg,
warning,
],
#get,
[],
{#id: id},
),
returnValueForMissingStub: null,
);
returnValue: _i7.Future<_i10.CustomerDto?>.value(),
) as _i7.Future<_i10.CustomerDto?>);
}
/// A class which mocks [PictureController].
///
/// See the documentation for Mockito's code generation for more information.
class MockPictureController extends _i1.Mock implements _i11.PictureController {
MockPictureController() {
_i1.throwOnMissingStub(this);
}
@override
_i7.Future<bool> delete(_i12.PictureDto? dto) => (super.noSuchMethod(
Invocation.method(
#delete,
[dto],
),
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
}
/// A class which mocks [JwtTokenStorage].
///
/// See the documentation for Mockito's code generation for more information.
class MockJwtTokenStorage extends _i1.Mock implements _i10.JwtTokenStorage {
class MockJwtTokenStorage extends _i1.Mock implements _i13.JwtTokenStorage {
MockJwtTokenStorage() {
_i1.throwOnMissingStub(this);
}
@override
_i11.Future<void> saveTokens(
_i7.Future<void> saveTokens(
String? accessToken,
String? refreshToken,
) =>
@@ -227,69 +260,69 @@ class MockJwtTokenStorage extends _i1.Mock implements _i10.JwtTokenStorage {
refreshToken,
],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);
@override
_i11.Future<String?> getAccessToken() => (super.noSuchMethod(
_i7.Future<String?> getAccessToken() => (super.noSuchMethod(
Invocation.method(
#getAccessToken,
[],
),
returnValue: _i11.Future<String?>.value(),
) as _i11.Future<String?>);
returnValue: _i7.Future<String?>.value(),
) as _i7.Future<String?>);
@override
_i11.Future<String?> getRefreshToken() => (super.noSuchMethod(
_i7.Future<String?> getRefreshToken() => (super.noSuchMethod(
Invocation.method(
#getRefreshToken,
[],
),
returnValue: _i11.Future<String?>.value(),
) as _i11.Future<String?>);
returnValue: _i7.Future<String?>.value(),
) as _i7.Future<String?>);
@override
_i11.Future<void> clearTokens() => (super.noSuchMethod(
_i7.Future<void> clearTokens() => (super.noSuchMethod(
Invocation.method(
#clearTokens,
[],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);
@override
_i11.Future<bool> hasTokens() => (super.noSuchMethod(
_i7.Future<bool> hasTokens() => (super.noSuchMethod(
Invocation.method(
#hasTokens,
[],
),
returnValue: _i11.Future<bool>.value(false),
) as _i11.Future<bool>);
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i11.Future<void> updateAccessToken(String? accessToken) =>
_i7.Future<void> updateAccessToken(String? accessToken) =>
(super.noSuchMethod(
Invocation.method(
#updateAccessToken,
[accessToken],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),
) as _i7.Future<void>);
}
/// A class which mocks [Client].
///
/// See the documentation for Mockito's code generation for more information.
class MockClient extends _i1.Mock implements _i3.Client {
class MockClient extends _i1.Mock implements _i2.Client {
MockClient() {
_i1.throwOnMissingStub(this);
}
@override
_i11.Future<_i3.Response> head(
_i7.Future<_i2.Response> head(
Uri? url, {
Map<String, String>? headers,
}) =>
@@ -299,7 +332,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#head,
@@ -307,10 +340,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<_i3.Response> get(
_i7.Future<_i2.Response> get(
Uri? url, {
Map<String, String>? headers,
}) =>
@@ -320,7 +353,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#get,
@@ -328,14 +361,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<_i3.Response> post(
_i7.Future<_i2.Response> post(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
_i14.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -347,7 +380,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#post,
@@ -359,14 +392,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<_i3.Response> put(
_i7.Future<_i2.Response> put(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
_i14.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -378,7 +411,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#put,
@@ -390,14 +423,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<_i3.Response> patch(
_i7.Future<_i2.Response> patch(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
_i14.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -409,7 +442,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#patch,
@@ -421,14 +454,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<_i3.Response> delete(
_i7.Future<_i2.Response> delete(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i12.Encoding? encoding,
_i14.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(
@@ -440,7 +473,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding,
},
),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1(
returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#delete,
@@ -452,10 +485,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
},
),
)),
) as _i11.Future<_i3.Response>);
) as _i7.Future<_i2.Response>);
@override
_i11.Future<String> read(
_i7.Future<String> read(
Uri? url, {
Map<String, String>? headers,
}) =>
@@ -465,7 +498,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url],
{#headers: headers},
),
returnValue: _i11.Future<String>.value(_i5.dummyValue<String>(
returnValue: _i7.Future<String>.value(_i4.dummyValue<String>(
this,
Invocation.method(
#read,
@@ -473,10 +506,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers},
),
)),
) as _i11.Future<String>);
) as _i7.Future<String>);
@override
_i11.Future<_i13.Uint8List> readBytes(
_i7.Future<_i15.Uint8List> readBytes(
Uri? url, {
Map<String, String>? headers,
}) =>
@@ -486,25 +519,25 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url],
{#headers: headers},
),
returnValue: _i11.Future<_i13.Uint8List>.value(_i13.Uint8List(0)),
) as _i11.Future<_i13.Uint8List>);
returnValue: _i7.Future<_i15.Uint8List>.value(_i15.Uint8List(0)),
) as _i7.Future<_i15.Uint8List>);
@override
_i11.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) =>
_i7.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
(super.noSuchMethod(
Invocation.method(
#send,
[request],
),
returnValue:
_i11.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_2(
_i7.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
this,
Invocation.method(
#send,
[request],
),
)),
) as _i11.Future<_i3.StreamedResponse>);
) as _i7.Future<_i2.StreamedResponse>);
@override
void close() => super.noSuchMethod(