Skip to content

Commit

Permalink
handle quick actions being unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 4, 2024
1 parent 026ed61 commit 8f6ea38
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/Backend/favorite_actions_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart' as flTest;
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:quick_actions_platform_interface/quick_actions_platform_interface.dart';
import 'package:tail_app/Backend/Definitions/Action/base_action.dart';
import 'package:tail_app/Backend/LoggingWrappers.dart';
import 'package:tail_app/Backend/favorite_actions.dart';
Expand All @@ -12,6 +15,7 @@ import '../testing_utils/hive_utils.dart';
void main() {
setUp(() async {
flTest.TestWidgetsFlutterBinding.ensureInitialized();
QuickActionsPlatform.instance = MockQuickActionsPlatform();
await setupHive();
});
tearDown(() async {
Expand Down Expand Up @@ -42,3 +46,14 @@ void main() {
expect(HiveProxy.getAll<FavoriteAction>(favoriteActionsBox).length, 0);
});
}

class MockQuickActionsPlatform extends Mock with MockPlatformInterfaceMixin implements QuickActionsPlatform {
@override
Future<void> clearShortcutItems() async => super.noSuchMethod(Invocation.method(#clearShortcutItems, <Object?>[]));

@override
Future<void> initialize(QuickActionHandler? handler) async => super.noSuchMethod(Invocation.method(#initialize, <Object?>[handler]));

@override
Future<void> setShortcutItems(List<ShortcutItem>? items) async => super.noSuchMethod(Invocation.method(#setShortcutItems, <Object?>[items]));
}

0 comments on commit 8f6ea38

Please sign in to comment.