added clear message for denied camera or gallery access
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:marianum_mobile/api/api_error.dart';
|
||||
@@ -10,6 +11,7 @@ import 'package:marianum_mobile/api/errors/error_mapper.dart';
|
||||
import 'package:marianum_mobile/api/errors/network_exception.dart';
|
||||
import 'package:marianum_mobile/api/errors/not_found_exception.dart';
|
||||
import 'package:marianum_mobile/api/errors/parse_exception.dart';
|
||||
import 'package:marianum_mobile/api/errors/permission_exception.dart';
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
|
||||
void main() {
|
||||
@@ -142,10 +144,7 @@ void main() {
|
||||
|
||||
test('401 maps to the unauthorized AuthException', () {
|
||||
const ex = DynamiteApiException(401, {}, '');
|
||||
expect(
|
||||
errorToUserMessage(ex),
|
||||
AuthException.unauthorized().userMessage,
|
||||
);
|
||||
expect(errorToUserMessage(ex), AuthException.unauthorized().userMessage);
|
||||
expect(errorAllowsRetry(ex), isFalse);
|
||||
});
|
||||
|
||||
@@ -205,4 +204,29 @@ void main() {
|
||||
expect(errorAllowsRetry(StateError('x')), isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('PermissionException.fromPlatform', () {
|
||||
test('camera_access_denied maps to the camera message', () {
|
||||
final mapped = PermissionException.fromPlatform(
|
||||
PlatformException(code: 'camera_access_denied', message: 'denied'),
|
||||
);
|
||||
expect(mapped?.userMessage, contains('Kamera'));
|
||||
expect(mapped?.technicalDetails, 'denied');
|
||||
expect(errorAllowsRetry(mapped), isFalse);
|
||||
});
|
||||
|
||||
test('photo_access_denied maps to the photos message', () {
|
||||
final mapped = PermissionException.fromPlatform(
|
||||
PlatformException(code: 'photo_access_denied'),
|
||||
);
|
||||
expect(mapped?.userMessage, contains('Fotos'));
|
||||
});
|
||||
|
||||
test('unrelated platform codes are not mapped', () {
|
||||
expect(
|
||||
PermissionException.fromPlatform(PlatformException(code: 'other')),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user