diff --git a/packages/app_center/lib/manage/manage_model.dart b/packages/app_center/lib/manage/manage_model.dart index 5c6a4f15e..7946d4f45 100644 --- a/packages/app_center/lib/manage/manage_model.dart +++ b/packages/app_center/lib/manage/manage_model.dart @@ -12,11 +12,8 @@ class ManageModel extends _$ManageModel { @override Future build() async { final installedSnaps = await _snapd.getSnaps(); - final refreshableSnapNames = ref - .watch( - updatesModelProvider.select((value) => value.refreshableSnapNames), - ) - .toList(growable: false); + final refreshableSnapNames = + (await ref.watch(updatesModelProvider.future)).snapNames; return ManageSnapsData( installedSnaps: installedSnaps, refreshableSnapNames: refreshableSnapNames, diff --git a/packages/app_center/lib/manage/manage_model.g.dart b/packages/app_center/lib/manage/manage_model.g.dart index ef5435bd4..65d352e9f 100644 --- a/packages/app_center/lib/manage/manage_model.g.dart +++ b/packages/app_center/lib/manage/manage_model.g.dart @@ -6,7 +6,7 @@ part of 'manage_model.dart'; // RiverpodGenerator // ************************************************************************** -String _$manageModelHash() => r'c6232c1bbc8a1896700cdde1ed0002cd14e1b8e3'; +String _$manageModelHash() => r'd03360ac71a6afd337499953bf9be67ac001960e'; /// See also [ManageModel]. @ProviderFor(ManageModel) diff --git a/packages/app_center/lib/manage/manage_page.dart b/packages/app_center/lib/manage/manage_page.dart index e68e9f857..772ed6fd1 100644 --- a/packages/app_center/lib/manage/manage_page.dart +++ b/packages/app_center/lib/manage/manage_page.dart @@ -8,6 +8,7 @@ import 'package:app_center/manage/local_snap_providers.dart'; import 'package:app_center/manage/manage_l10n.dart'; import 'package:app_center/manage/manage_model.dart'; import 'package:app_center/manage/manage_snaps_data.dart'; +import 'package:app_center/providers/error_stream_provider.dart'; import 'package:app_center/snapd/snapd.dart'; import 'package:app_center/store/store.dart'; import 'package:app_center/widgets/widgets.dart'; @@ -17,46 +18,32 @@ import 'package:snapd/snapd.dart'; import 'package:ubuntu_widgets/ubuntu_widgets.dart'; import 'package:yaru/yaru.dart'; -class ManagePage extends ConsumerStatefulWidget { +class ManagePage extends ConsumerWidget { const ManagePage({super.key}); static IconData icon(bool selected) => YaruIcons.app_grid; static String label(BuildContext context) => AppLocalizations.of(context).managePageLabel; - @override - ConsumerState createState() => _ManagePageState(); -} - -class _ManagePageState extends ConsumerState { - StreamSubscription? _errorSubscription; - - @override - void initState() { - super.initState(); - - _errorSubscription = - ref.read(updatesModelProvider).errorStream.listen(showError); - } - - @override - void dispose() { - _errorSubscription?.cancel(); - _errorSubscription = null; - super.dispose(); + Future _showError(BuildContext context, SnapdException e) { + return showErrorDialog( + context: context, + title: e.kind ?? 'Unknown Snapd Exception', + message: e.message, + ); } - Future showError(SnapdException e) => showErrorDialog( - context: context, - title: e.kind ?? 'Unknown Snapd Exception', - message: e.message, - ); - @override - Widget build(BuildContext context) { - final manageModel = ref.watch(manageModelProvider); - return manageModel.state.when( - data: (_) => _ManageView(manageModel: manageModel), + Widget build(BuildContext context, WidgetRef ref) { + ref.listen(errorStreamProvider, (_, error) { + if (error.hasValue && error.value is SnapdException) { + _showError(context, error.value as SnapdException); + } + }); + + final manageSnaps = ref.watch(manageModelProvider); + return manageSnaps.when( + data: (data) => _ManageView(manageSnapsData: data), error: (error, stack) => ErrorView(error: error), loading: () => const Center(child: YaruCircularProgressIndicator()), ); @@ -248,7 +235,9 @@ class _ActionButtons extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final l10n = AppLocalizations.of(context); final updatesModel = ref.watch(updatesModelProvider); - final (label, icon) = updatesModel.state.when( + final updateChangeId = ref.watch(updateChangeIdProvider); + + final (label, icon) = updatesModel.when( data: (_) => (l10n.managePageCheckForUpdates, const Icon(YaruIcons.sync)), loading: () => ( l10n.managePageCheckingForUpdates, @@ -262,16 +251,15 @@ class _ActionButtons extends ConsumerWidget { error: (_, __) => ('', const SizedBox.shrink()), ); - final updatesInprogress = updatesModel.refreshableSnapNames.isNotEmpty && - !updatesModel.state.isLoading && - updatesModel.activeChangeId != null; + final updatesInProgress = !updatesModel.isLoading && updateChangeId != null; return Wrap( spacing: 10, runSpacing: 10, children: [ PushButton.outlined( - onPressed: - updatesModel.activeChangeId != null ? null : updatesModel.refresh, + onPressed: updatesInProgress + ? null + : () => ref.refresh(updatesModelProvider), child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -288,16 +276,15 @@ class _ActionButtons extends ConsumerWidget { ), ), PushButton.elevated( - onPressed: updatesModel.refreshableSnapNames.isNotEmpty && - !updatesModel.state.isLoading && - updatesModel.activeChangeId == null - ? ref.read(updatesModelProvider).updateAll - : null, - child: updatesModel.activeChangeId != null + onPressed: + !updatesInProgress && (updatesModel.value?.isNotEmpty ?? false) + ? ref.read(updatesModelProvider.notifier).updateAll + : null, + child: updateChangeId != null ? Consumer( builder: (context, ref, child) { final change = ref.watch( - activeChangeProvider(updatesModel.activeChangeId), + activeChangeProvider(updateChangeId), ); return Row( mainAxisSize: MainAxisSize.min, @@ -336,11 +323,11 @@ class _ActionButtons extends ConsumerWidget { ], ), ), - if (updatesInprogress) + if (updatesInProgress) PushButton.outlined( onPressed: () => ref - .read(updatesModelProvider) - .cancelChange(updatesModel.activeChangeId!), + .read(updatesModelProvider.notifier) + .cancelChange(updateChangeId), child: Text( l10n.snapActionCancelLabel, maxLines: 1, @@ -354,7 +341,7 @@ class _ActionButtons extends ConsumerWidget { enum ManageTilePosition { first, middle, last, single } -class _ManageSnapTile extends ConsumerWidget { +class _ManageSnapTile extends StatelessWidget { const _ManageSnapTile({ required this.snap, this.position = ManageTilePosition.middle, @@ -366,7 +353,7 @@ class _ManageSnapTile extends ConsumerWidget { final bool showUpdateButton; @override - Widget build(BuildContext context, WidgetRef ref) { + Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); final border = BorderSide(color: Theme.of(context).colorScheme.outline); final dateTimeSinceUpdate = snap.installDate != null @@ -528,10 +515,9 @@ class _ButtonBarForUpdate extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final snapLauncher = ref.watch(launchProvider(snap)); final l10n = AppLocalizations.of(context); + final snapLauncher = ref.watch(launchProvider(snap)); final snapModel = ref.watch(snapModelProvider(snap.name)); - final updatesModel = ref.watch(updatesModelProvider); final activeChangeId = snapModel.value?.activeChangeId; final change = activeChangeId != null ? ref.watch(activeChangeProvider(activeChangeId)) @@ -541,7 +527,7 @@ class _ButtonBarForUpdate extends ConsumerWidget { mainAxisSize: MainAxisSize.min, children: [ OutlinedButton( - onPressed: updatesModel.activeChangeId != null || !snapModel.hasValue + onPressed: activeChangeId != null || !snapModel.hasValue ? null : ref.read(snapModelProvider(snap.name).notifier).refresh, child: snapModel.value?.activeChangeId != null diff --git a/packages/app_center/lib/providers/error_stream_provider.dart b/packages/app_center/lib/providers/error_stream_provider.dart index e72f44c56..62a1528ac 100644 --- a/packages/app_center/lib/providers/error_stream_provider.dart +++ b/packages/app_center/lib/providers/error_stream_provider.dart @@ -1,11 +1,18 @@ import 'dart:async'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; +part 'error_stream_provider.g.dart'; + /// Used to listen to incoming errors to show them to the user. final errorStreamProvider = StreamProvider( - (ref) => getService().stream, + (ref) => ref.watch(errorStreamControllerProvider).stream, ); +@Riverpod(keepAlive: true) +ErrorStreamController errorStreamController(ErrorStreamControllerRef ref) { + return getService(); +} + typedef ErrorStreamController = StreamController; diff --git a/packages/app_center/lib/providers/error_stream_provider.g.dart b/packages/app_center/lib/providers/error_stream_provider.g.dart new file mode 100644 index 000000000..9a2d89ea8 --- /dev/null +++ b/packages/app_center/lib/providers/error_stream_provider.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'error_stream_provider.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$errorStreamControllerHash() => + r'76de12539c2769e4c803295c94c6f22a8ea8cfa3'; + +/// See also [errorStreamController]. +@ProviderFor(errorStreamController) +final errorStreamControllerProvider = Provider.internal( + errorStreamController, + name: r'errorStreamControllerProvider', + debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') + ? null + : _$errorStreamControllerHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef ErrorStreamControllerRef = ProviderRef; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/packages/app_center/lib/snapd/snap_data.dart b/packages/app_center/lib/snapd/snap_data.dart index cce9f4b75..dcdacbcfd 100644 --- a/packages/app_center/lib/snapd/snap_data.dart +++ b/packages/app_center/lib/snapd/snap_data.dart @@ -14,6 +14,7 @@ class SnapData with _$SnapData { required Snap? storeSnap, String? selectedChannel, String? activeChangeId, + bool hasUpdate = false, }) { return _SnapData( name: name, @@ -22,6 +23,7 @@ class SnapData with _$SnapData { selectedChannel: selectedChannel ?? defaultSelectedChannel(localSnap, storeSnap), activeChangeId: activeChangeId, + hasUpdate: hasUpdate, ); } @@ -33,6 +35,7 @@ class SnapData with _$SnapData { required Snap? localSnap, required Snap? storeSnap, required String? selectedChannel, + required bool hasUpdate, String? activeChangeId, }) = _SnapData; diff --git a/packages/app_center/lib/snapd/snap_data.freezed.dart b/packages/app_center/lib/snapd/snap_data.freezed.dart index bf2ac41ca..4e5bf7418 100644 --- a/packages/app_center/lib/snapd/snap_data.freezed.dart +++ b/packages/app_center/lib/snapd/snap_data.freezed.dart @@ -20,25 +20,26 @@ mixin _$SnapData { Snap? get localSnap => throw _privateConstructorUsedError; Snap? get storeSnap => throw _privateConstructorUsedError; String? get selectedChannel => throw _privateConstructorUsedError; + bool get hasUpdate => throw _privateConstructorUsedError; String? get activeChangeId => throw _privateConstructorUsedError; @optionalTypeArgs TResult when({ required TResult Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId) + String? selectedChannel, bool hasUpdate, String? activeChangeId) definition, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ TResult? Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId)? + String? selectedChannel, bool hasUpdate, String? activeChangeId)? definition, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ TResult Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId)? + String? selectedChannel, bool hasUpdate, String? activeChangeId)? definition, required TResult orElse(), }) => @@ -75,6 +76,7 @@ abstract class $SnapDataCopyWith<$Res> { Snap? localSnap, Snap? storeSnap, String? selectedChannel, + bool hasUpdate, String? activeChangeId}); $SnapCopyWith<$Res>? get localSnap; @@ -98,6 +100,7 @@ class _$SnapDataCopyWithImpl<$Res, $Val extends SnapData> Object? localSnap = freezed, Object? storeSnap = freezed, Object? selectedChannel = freezed, + Object? hasUpdate = null, Object? activeChangeId = freezed, }) { return _then(_value.copyWith( @@ -117,6 +120,10 @@ class _$SnapDataCopyWithImpl<$Res, $Val extends SnapData> ? _value.selectedChannel : selectedChannel // ignore: cast_nullable_to_non_nullable as String?, + hasUpdate: null == hasUpdate + ? _value.hasUpdate + : hasUpdate // ignore: cast_nullable_to_non_nullable + as bool, activeChangeId: freezed == activeChangeId ? _value.activeChangeId : activeChangeId // ignore: cast_nullable_to_non_nullable @@ -162,6 +169,7 @@ abstract class _$$SnapDataImplCopyWith<$Res> Snap? localSnap, Snap? storeSnap, String? selectedChannel, + bool hasUpdate, String? activeChangeId}); @override @@ -185,6 +193,7 @@ class __$$SnapDataImplCopyWithImpl<$Res> Object? localSnap = freezed, Object? storeSnap = freezed, Object? selectedChannel = freezed, + Object? hasUpdate = null, Object? activeChangeId = freezed, }) { return _then(_$SnapDataImpl( @@ -204,6 +213,10 @@ class __$$SnapDataImplCopyWithImpl<$Res> ? _value.selectedChannel : selectedChannel // ignore: cast_nullable_to_non_nullable as String?, + hasUpdate: null == hasUpdate + ? _value.hasUpdate + : hasUpdate // ignore: cast_nullable_to_non_nullable + as bool, activeChangeId: freezed == activeChangeId ? _value.activeChangeId : activeChangeId // ignore: cast_nullable_to_non_nullable @@ -220,6 +233,7 @@ class _$SnapDataImpl extends _SnapData { required this.localSnap, required this.storeSnap, required this.selectedChannel, + required this.hasUpdate, this.activeChangeId}) : super._(); @@ -232,11 +246,13 @@ class _$SnapDataImpl extends _SnapData { @override final String? selectedChannel; @override + final bool hasUpdate; + @override final String? activeChangeId; @override String toString() { - return 'SnapData.definition(name: $name, localSnap: $localSnap, storeSnap: $storeSnap, selectedChannel: $selectedChannel, activeChangeId: $activeChangeId)'; + return 'SnapData.definition(name: $name, localSnap: $localSnap, storeSnap: $storeSnap, selectedChannel: $selectedChannel, hasUpdate: $hasUpdate, activeChangeId: $activeChangeId)'; } @override @@ -251,13 +267,15 @@ class _$SnapDataImpl extends _SnapData { other.storeSnap == storeSnap) && (identical(other.selectedChannel, selectedChannel) || other.selectedChannel == selectedChannel) && + (identical(other.hasUpdate, hasUpdate) || + other.hasUpdate == hasUpdate) && (identical(other.activeChangeId, activeChangeId) || other.activeChangeId == activeChangeId)); } @override - int get hashCode => Object.hash( - runtimeType, name, localSnap, storeSnap, selectedChannel, activeChangeId); + int get hashCode => Object.hash(runtimeType, name, localSnap, storeSnap, + selectedChannel, hasUpdate, activeChangeId); @JsonKey(ignore: true) @override @@ -269,35 +287,35 @@ class _$SnapDataImpl extends _SnapData { @optionalTypeArgs TResult when({ required TResult Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId) + String? selectedChannel, bool hasUpdate, String? activeChangeId) definition, }) { return definition( - name, localSnap, storeSnap, selectedChannel, activeChangeId); + name, localSnap, storeSnap, selectedChannel, hasUpdate, activeChangeId); } @override @optionalTypeArgs TResult? whenOrNull({ TResult? Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId)? + String? selectedChannel, bool hasUpdate, String? activeChangeId)? definition, }) { return definition?.call( - name, localSnap, storeSnap, selectedChannel, activeChangeId); + name, localSnap, storeSnap, selectedChannel, hasUpdate, activeChangeId); } @override @optionalTypeArgs TResult maybeWhen({ TResult Function(String name, Snap? localSnap, Snap? storeSnap, - String? selectedChannel, String? activeChangeId)? + String? selectedChannel, bool hasUpdate, String? activeChangeId)? definition, required TResult orElse(), }) { if (definition != null) { - return definition( - name, localSnap, storeSnap, selectedChannel, activeChangeId); + return definition(name, localSnap, storeSnap, selectedChannel, hasUpdate, + activeChangeId); } return orElse(); } @@ -337,6 +355,7 @@ abstract class _SnapData extends SnapData { required final Snap? localSnap, required final Snap? storeSnap, required final String? selectedChannel, + required final bool hasUpdate, final String? activeChangeId}) = _$SnapDataImpl; _SnapData._() : super._(); @@ -349,6 +368,8 @@ abstract class _SnapData extends SnapData { @override String? get selectedChannel; @override + bool get hasUpdate; + @override String? get activeChangeId; @override @JsonKey(ignore: true) diff --git a/packages/app_center/lib/snapd/snap_model.dart b/packages/app_center/lib/snapd/snap_model.dart index 3c22d7c70..861a8de1b 100644 --- a/packages/app_center/lib/snapd/snap_model.dart +++ b/packages/app_center/lib/snapd/snap_model.dart @@ -39,6 +39,7 @@ class SnapModel extends _$SnapModel { if (localSnap == null && storeSnap == null) { throw SnapDataNotFoundException(snapName); } + final hasUpdate = ref.watch(hasUpdateProvider(snapName)); return SnapData( name: snapName, @@ -49,6 +50,7 @@ class SnapModel extends _$SnapModel { localSnap, storeSnap, ), + hasUpdate: hasUpdate, ); } diff --git a/packages/app_center/lib/snapd/snap_model.g.dart b/packages/app_center/lib/snapd/snap_model.g.dart index 7c83f5044..a368e9b05 100644 --- a/packages/app_center/lib/snapd/snap_model.g.dart +++ b/packages/app_center/lib/snapd/snap_model.g.dart @@ -6,7 +6,7 @@ part of 'snap_model.dart'; // RiverpodGenerator // ************************************************************************** -String _$snapModelHash() => r'eb4ff3186941e12eb5c6ebe7272429f601c5ab81'; +String _$snapModelHash() => r'53cf3173dbb8535cd5982c2b2033cbbad67927e5'; /// Copied from Dart SDK class _SystemHash { diff --git a/packages/app_center/lib/snapd/snap_page.dart b/packages/app_center/lib/snapd/snap_page.dart index be6062032..f6d8e13b2 100644 --- a/packages/app_center/lib/snapd/snap_page.dart +++ b/packages/app_center/lib/snapd/snap_page.dart @@ -35,7 +35,6 @@ class SnapPage extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final snap = ref.watch(snapModelProvider(snapName)); - final updatesModel = ref.watch(updatesModelProvider); final snapDataNotFound = snap.hasError && snap.error is SnapDataNotFoundException; @@ -51,10 +50,7 @@ class SnapPage extends ConsumerWidget { return snap.when( data: (snapData) => ResponsiveLayoutBuilder( builder: (_) { - return _SnapView( - snapData: snapData, - updatesModel: updatesModel, - ); + return _SnapView(snapData: snapData); }, ), error: (error, stackTrace) => ErrorView( @@ -67,10 +63,9 @@ class SnapPage extends ConsumerWidget { } class _SnapView extends StatelessWidget { - const _SnapView({required this.snapData, required this.updatesModel}); + const _SnapView({required this.snapData}); final SnapData snapData; - final UpdatesModel updatesModel; @override Widget build(BuildContext context) { @@ -300,7 +295,6 @@ class _SnapActionButtons extends ConsumerWidget { final snapLauncher = snapData.isInstalled && localSnap != null ? ref.watch(launchProvider(localSnap)) : null; - final updatesModel = ref.watch(updatesModelProvider); final snapModel = ref.watch(snapModelProvider(snapData.name).notifier); final SnapAction primaryAction; @@ -353,7 +347,7 @@ class _SnapActionButtons extends ConsumerWidget { ); final secondaryActions = [ - if (updatesModel.hasUpdate(snapData.name)) SnapAction.update, + if (snapData.hasUpdate) SnapAction.update, SnapAction.remove, ]; final secondaryActionsButton = MenuAnchor( diff --git a/packages/app_center/lib/snapd/updates_model.dart b/packages/app_center/lib/snapd/updates_model.dart index 7e77a3dfa..c137ed4a1 100644 --- a/packages/app_center/lib/snapd/updates_model.dart +++ b/packages/app_center/lib/snapd/updates_model.dart @@ -1,77 +1,54 @@ import 'dart:async'; -import 'package:app_center/snapd/logger.dart'; +import 'package:app_center/providers/error_stream_provider.dart'; import 'package:app_center/snapd/snapd.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:snapd/snapd.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; -// TODO(Lukas): Rewrite to modern style provider -final updatesModelProvider = ChangeNotifierProvider( - (ref) => UpdatesModel(getService())..refresh(), -); +part 'updates_model.g.dart'; -class UpdatesModel extends ChangeNotifier { - UpdatesModel(this.snapd) : _state = const AsyncValue.loading(); - final SnapdService snapd; - Iterable get refreshableSnapNames => - _refreshableSnaps?.map((snap) => snap.name) ?? const Iterable.empty(); +final updateChangeIdProvider = StateProvider((_) => null); - Iterable? _refreshableSnaps; - - String? get activeChangeId => _activeChangeId; - String? _activeChangeId; - - AsyncValue get state => _state; - AsyncValue _state; - - Stream get errorStream => _errorStreamController.stream; - final StreamController _errorStreamController = - StreamController.broadcast(); +@Riverpod(keepAlive: true) +bool hasUpdate(HasUpdateRef ref, String snapName) { + final updatesModel = ref.watch(updatesModelProvider); + return updatesModel.value?.any((s) => s.name == snapName) ?? false; +} - void _handleError(SnapdException e) { - _errorStreamController.add(e); - log.error( - 'Caught exception when handling updates for $refreshableSnapNames', - e, - ); - } +@Riverpod(keepAlive: true) +class UpdatesModel extends _$UpdatesModel { + late final _snapd = getService(); - Future refresh() async { - _state = const AsyncValue.loading(); - notifyListeners(); - _state = await AsyncValue.guard(() async { - try { - _refreshableSnaps = await snapd.find(filter: SnapFindFilter.refresh); - notifyListeners(); - } on SnapdException catch (e) { - _handleError(e); - } - }); + @override + Future> build() { + try { + return _snapd.find(filter: SnapFindFilter.refresh); + } on SnapdException catch (e) { + ref.read(errorStreamControllerProvider).add(e); + return Future.value([]); + } } - bool hasUpdate(String snapName) => refreshableSnapNames.contains(snapName); - Future updateAll() async { - if (_refreshableSnaps == null) return; + if (!state.hasValue) return; try { - final changeId = await snapd.refreshMany([]); - _activeChangeId = changeId; - notifyListeners(); - await snapd.waitChange(changeId); + final changeId = await _snapd.refreshMany([]); + ref.read(updateChangeIdProvider.notifier).state = changeId; + await _snapd.waitChange(changeId); } on SnapdException catch (e) { - _handleError(e); + ref.read(errorStreamControllerProvider).add(e); } - _activeChangeId = null; - await refresh(); + ref.read(updateChangeIdProvider.notifier).state = null; + ref.invalidateSelf(); } Future cancelChange(String changeId) async { if (changeId.isEmpty) return; try { - final changeDetails = await snapd.getChange(changeId); + final changeDetails = await _snapd.getChange(changeId); // If the change is already completed, ignore silently. // If it wouldn't be ignored, an error would be displayed to the user, @@ -80,12 +57,15 @@ class UpdatesModel extends ChangeNotifier { return; } - final abortChange = await snapd.abortChange(changeId); - await snapd.waitChange(abortChange.id); - _activeChangeId = null; - notifyListeners(); + final abortChange = await _snapd.abortChange(changeId); + await _snapd.waitChange(abortChange.id); + ref.read(updateChangeIdProvider.notifier).state = null; } on SnapdException catch (e) { - _handleError(e); + ref.read(errorStreamControllerProvider).add(e); } } } + +extension IterableSnapExtensions on Iterable { + List get snapNames => map((snap) => snap.name).toList(); +} diff --git a/packages/app_center/lib/snapd/updates_model.g.dart b/packages/app_center/lib/snapd/updates_model.g.dart new file mode 100644 index 000000000..1dae56f56 --- /dev/null +++ b/packages/app_center/lib/snapd/updates_model.g.dart @@ -0,0 +1,173 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'updates_model.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$hasUpdateHash() => r'11c9797560e1bf807eaa921f44b2a8e21a2e9058'; + +/// Copied from Dart SDK +class _SystemHash { + _SystemHash._(); + + static int combine(int hash, int value) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + value); + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); + return hash ^ (hash >> 6); + } + + static int finish(int hash) { + // ignore: parameter_assignments + hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); + // ignore: parameter_assignments + hash = hash ^ (hash >> 11); + return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + } +} + +/// See also [hasUpdate]. +@ProviderFor(hasUpdate) +const hasUpdateProvider = HasUpdateFamily(); + +/// See also [hasUpdate]. +class HasUpdateFamily extends Family { + /// See also [hasUpdate]. + const HasUpdateFamily(); + + /// See also [hasUpdate]. + HasUpdateProvider call( + String snapName, + ) { + return HasUpdateProvider( + snapName, + ); + } + + @override + HasUpdateProvider getProviderOverride( + covariant HasUpdateProvider provider, + ) { + return call( + provider.snapName, + ); + } + + static const Iterable? _dependencies = null; + + @override + Iterable? get dependencies => _dependencies; + + static const Iterable? _allTransitiveDependencies = null; + + @override + Iterable? get allTransitiveDependencies => + _allTransitiveDependencies; + + @override + String? get name => r'hasUpdateProvider'; +} + +/// See also [hasUpdate]. +class HasUpdateProvider extends Provider { + /// See also [hasUpdate]. + HasUpdateProvider( + String snapName, + ) : this._internal( + (ref) => hasUpdate( + ref as HasUpdateRef, + snapName, + ), + from: hasUpdateProvider, + name: r'hasUpdateProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$hasUpdateHash, + dependencies: HasUpdateFamily._dependencies, + allTransitiveDependencies: HasUpdateFamily._allTransitiveDependencies, + snapName: snapName, + ); + + HasUpdateProvider._internal( + super._createNotifier, { + required super.name, + required super.dependencies, + required super.allTransitiveDependencies, + required super.debugGetCreateSourceHash, + required super.from, + required this.snapName, + }) : super.internal(); + + final String snapName; + + @override + Override overrideWith( + bool Function(HasUpdateRef provider) create, + ) { + return ProviderOverride( + origin: this, + override: HasUpdateProvider._internal( + (ref) => create(ref as HasUpdateRef), + from: from, + name: null, + dependencies: null, + allTransitiveDependencies: null, + debugGetCreateSourceHash: null, + snapName: snapName, + ), + ); + } + + @override + ProviderElement createElement() { + return _HasUpdateProviderElement(this); + } + + @override + bool operator ==(Object other) { + return other is HasUpdateProvider && other.snapName == snapName; + } + + @override + int get hashCode { + var hash = _SystemHash.combine(0, runtimeType.hashCode); + hash = _SystemHash.combine(hash, snapName.hashCode); + + return _SystemHash.finish(hash); + } +} + +mixin HasUpdateRef on ProviderRef { + /// The parameter `snapName` of this provider. + String get snapName; +} + +class _HasUpdateProviderElement extends ProviderElement + with HasUpdateRef { + _HasUpdateProviderElement(super.provider); + + @override + String get snapName => (origin as HasUpdateProvider).snapName; +} + +String _$updatesModelHash() => r'99cb3795ae4ca89b5549f521c2b92065177c656f'; + +/// See also [UpdatesModel]. +@ProviderFor(UpdatesModel) +final updatesModelProvider = + AsyncNotifierProvider>.internal( + UpdatesModel.new, + name: r'updatesModelProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') ? null : _$updatesModelHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$UpdatesModel = AsyncNotifier>; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/packages/app_center/lib/store/store_pages.dart b/packages/app_center/lib/store/store_pages.dart index b57a20b11..369bb1026 100644 --- a/packages/app_center/lib/store/store_pages.dart +++ b/packages/app_center/lib/store/store_pages.dart @@ -58,7 +58,7 @@ final pages = [ trailing: Consumer( builder: (context, ref, child) { final availableUpdates = - ref.watch(updatesModelProvider).refreshableSnapNames.length; + ref.watch(updatesModelProvider).value?.length ?? 0; return availableUpdates > 0 ? Badge(label: Text('$availableUpdates')) : const SizedBox.shrink(); diff --git a/packages/app_center/test/manage_model_test.dart b/packages/app_center/test/manage_model_test.dart index 49c504d43..7e159fad6 100644 --- a/packages/app_center/test/manage_model_test.dart +++ b/packages/app_center/test/manage_model_test.dart @@ -5,15 +5,14 @@ import 'test_utils.dart'; void main() { test('no updates available', () async { - final snapd = registerMockSnapdService( + registerMockSnapdService( installedSnaps: [ createSnap(name: 'firefox'), createSnap(name: 'thunderbird'), ], ); - final updatesModel = createMockUpdatesModel(); - final model = ManageModel(snapd: snapd, updatesModel: updatesModel); - await model.init(); + final container = createContainer(); + final model = await container.read(manageModelProvider.future); expect( model.nonRefreshableSnaps, @@ -21,17 +20,19 @@ void main() { ); expect(model.refreshableSnaps, isEmpty); }); + test('update available', () async { - final snapd = registerMockSnapdService( + registerMockSnapdService( installedSnaps: [ createSnap(name: 'firefox'), createSnap(name: 'thunderbird'), ], + refreshableSnaps: [ + createSnap(name: 'firefox'), + ], ); - final updatesModel = - createMockUpdatesModel(refreshableSnapNames: ['firefox']); - final model = ManageModel(snapd: snapd, updatesModel: updatesModel); - await model.init(); + final container = createContainer(); + final model = await container.read(manageModelProvider.future); expect( model.nonRefreshableSnaps, diff --git a/packages/app_center/test/manage_page_test.dart b/packages/app_center/test/manage_page_test.dart index e4a1ddf2d..9885eae53 100644 --- a/packages/app_center/test/manage_page_test.dart +++ b/packages/app_center/test/manage_page_test.dart @@ -1,6 +1,6 @@ import 'package:app_center/manage/local_snap_providers.dart'; import 'package:app_center/manage/manage.dart'; -import 'package:app_center/manage/manage_model.dart'; +import 'package:app_center/providers/error_stream_provider.dart'; import 'package:app_center/snapd/snapd.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -12,6 +12,7 @@ import 'package:yaru/yaru.dart'; import 'package:yaru_test/yaru_test.dart'; import 'test_utils.dart'; +import 'test_utils.mocks.dart'; void main() { final nonRefreshableSnaps = [ @@ -57,6 +58,15 @@ void main() { storeSnap: refreshableSnaps[0], ); + late MockSnapdService snapd; + setUp(() { + snapd = registerMockSnapdService( + localSnap: snapData.localSnap, + storeSnap: snapData.storeSnap, + installedSnaps: nonRefreshableSnaps + refreshableSnaps, + refreshableSnaps: refreshableSnaps, + ); + }); tearDown(resetAllServices); testWidgets('list installed snaps', (tester) async { @@ -64,17 +74,13 @@ void main() { (_) => ProviderScope( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => - createMockManageModel(nonRefreshableSnaps: nonRefreshableSnaps), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith((_) => createMockUpdatesModel()), ], child: const ManagePage(), ), ); + await tester.pumpAndSettle(); final testTile = find.snapTile('Test Snap'); expect(testTile, findsOneWidget); expect( @@ -99,6 +105,12 @@ void main() { }); testWidgets('launch desktop snap', (tester) async { + await resetAllServices(); + registerMockSnapdService( + installedSnaps: nonRefreshableSnaps, + refreshableSnaps: refreshableSnaps, + ); + final snapLauncher = createMockSnapLauncher(isLaunchable: true); await tester.pumpApp( (_) => ProviderScope( @@ -109,22 +121,16 @@ void main() { _ => createMockSnapLauncher(), }, ), - manageModelProvider.overrideWith( - (_) => createMockManageModel( - nonRefreshableSnaps: nonRefreshableSnaps, - ), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith((_) => createMockUpdatesModel()), ], child: const ManagePage(), ), ); - await tester.pumpAndSettle(); final testTile = find.snapTile('Test Snap'); final testTile2 = find.snapTile('Another Test Snap'); + expect(testTile, findsOneWidget); final openButton = find .descendant( @@ -149,24 +155,16 @@ void main() { }); testWidgets('refresh snaps', (tester) async { - final mockUpdatesModel = createMockUpdatesModel( - refreshableSnapNames: refreshableSnaps.map((snap) => snap.name), - ); await tester.pumpApp( (_) => ProviderScope( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => createMockManageModel( - refreshableSnaps: refreshableSnaps, - ), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith((_) => mockUpdatesModel), ], child: const ManagePage(), ), ); + await tester.pumpAndSettle(); final testTile = find.snapTile('Snap with an update'); expect(testTile, findsOneWidget); @@ -180,26 +178,14 @@ void main() { ); await tester.tap(find.text(tester.l10n.managePageUpdateAllLabel)); - verify(mockUpdatesModel.updateAll()).called(1); + verify(snapd.refreshMany([])).called(1); }); testWidgets('refresh individual snap', (tester) async { - final service = registerMockSnapdService( - localSnap: snapData.localSnap, - storeSnap: snapData.storeSnap, - refreshableSnaps: refreshableSnaps, - ); - final mockUpdatesModel = createMockUpdatesModel( - refreshableSnapNames: refreshableSnaps.map((snap) => snap.name), - ); final container = createContainer( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => createMockManageModel(refreshableSnaps: refreshableSnaps), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith((_) => mockUpdatesModel), ], ); @@ -224,20 +210,12 @@ void main() { ); await tester.pumpAndSettle(); - verifyNever(service.refresh(any)); + verifyNever(snapd.refresh(any)); await tester.tap(find.text(tester.l10n.snapActionUpdateLabel)); - verify(service.refresh(any, channel: anyNamed('channel'))).called(1); + verify(snapd.refresh(any, channel: anyNamed('channel'))).called(1); }); testWidgets('refreshing all', (tester) async { - registerMockSnapdService( - localSnap: snapData.localSnap, - storeSnap: snapData.storeSnap, - ); - final mockUpdatesModel = createMockUpdatesModel( - refreshableSnapNames: refreshableSnaps.map((snap) => snap.name), - isBusy: true, - ); final mockChange = SnapdChange( id: '', spawnTime: DateTime(1970), @@ -246,23 +224,27 @@ void main() { const SnapdTask(id: '', progress: SnapdTaskProgress(done: 1, total: 4)), ], ); + + await resetAllServices(); + registerMockSnapdService( + localSnap: snapData.localSnap, + storeSnap: snapData.storeSnap, + refreshableSnaps: refreshableSnaps, + changes: [mockChange], + ); + await tester.pumpApp( (_) => ProviderScope( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => createMockManageModel( - refreshableSnaps: refreshableSnaps, - ), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith((_) => mockUpdatesModel), activeChangeProvider.overrideWith((_, __) => mockChange), + updateChangeIdProvider.overrideWith((_) => mockChange.id), ], child: const ManagePage(), ), ); - await tester.pump(); + await tester.pumpAndSettle(); final refreshButton = find.buttonWithText(tester.l10n.snapActionUpdatingLabel); @@ -281,33 +263,19 @@ void main() { }); testWidgets('cancel refresh all', (tester) async { - registerMockSnapdService( - localSnap: snapData.localSnap, - storeSnap: snapData.storeSnap, - ); - final mockUpdatesModel = createMockUpdatesModel( - refreshableSnapNames: refreshableSnaps.map((snap) => snap.name), - isBusy: true, - ); + final mockChange = SnapdChange(id: '', spawnTime: DateTime(1970)); await tester.pumpApp( (_) => ProviderScope( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => createMockManageModel( - refreshableSnaps: refreshableSnaps, - ), - ), - activeChangeProvider.overrideWith( - (_, __) => SnapdChange(id: '', spawnTime: DateTime(1970)), - ), - updatesModelProvider.overrideWith((_) => mockUpdatesModel), + activeChangeProvider.overrideWith((_, __) => mockChange), + updateChangeIdProvider.overrideWith((_) => mockChange.id), ], child: const ManagePage(), ), ); - await tester.pump(); + await tester.pumpAndSettle(); final cancelButton = find.buttonWithText(tester.l10n.snapActionCancelLabel); expect(cancelButton, findsOneWidget); @@ -315,36 +283,29 @@ void main() { }); testWidgets('error dialog', (tester) async { - registerMockSnapdService( - localSnap: snapData.localSnap, - storeSnap: snapData.storeSnap, + registerMockErrorStreamControllerService(); + + when(snapd.find(filter: SnapFindFilter.refresh)).thenThrow( + SnapdException( + message: 'error message', + kind: 'error kind', + ), ); await tester.pumpApp( (_) => ProviderScope( overrides: [ launchProvider.overrideWith((_, __) => createMockSnapLauncher()), - manageModelProvider.overrideWith( - (_) => createMockManageModel( - refreshableSnaps: refreshableSnaps, - ), - ), showLocalSystemAppsProvider.overrideWith((ref) => true), - updatesModelProvider.overrideWith( - (_) => createMockUpdatesModel( - refreshableSnapNames: refreshableSnaps.map((snap) => snap.name), - errorStream: Stream.value( - SnapdException( - message: 'error message', - kind: 'error kind', - ), - ), + errorStreamProvider.overrideWith( + (ref) => Stream.value( + SnapdException(message: 'error message', kind: 'error kind'), ), ), ], child: const ManagePage(), ), ); - await tester.pump(); + await tester.pumpAndSettle(); expect(find.text('error message'), findsOneWidget); expect(find.text('error kind'), findsOneWidget); diff --git a/packages/app_center/test/snap_page_test.dart b/packages/app_center/test/snap_page_test.dart index 17e2543b7..9a8f1a459 100644 --- a/packages/app_center/test/snap_page_test.dart +++ b/packages/app_center/test/snap_page_test.dart @@ -120,12 +120,10 @@ void main() { final ratingsService = getService() as MockRatingsService; final snapLauncher = createMockSnapLauncher(isLaunchable: true); - final updatesModel = createMockUpdatesModel(); final container = createContainer( overrides: [ launchProvider.overrideWith((ref, arg) => snapLauncher), - updatesModelProvider.overrideWith((ref) => updatesModel), ], ); await tester.pumpApp( @@ -186,16 +184,14 @@ void main() { final service = registerMockSnapdService( localSnap: localSnap, storeSnap: storeSnap, + refreshableSnaps: [localSnap], ); final ratingsService = getService() as MockRatingsService; final snapLauncher = createMockSnapLauncher(isLaunchable: true); - final updatesModel = - createMockUpdatesModel(refreshableSnapNames: [localSnap.name]); final container = createContainer( overrides: [ launchProvider.overrideWith((ref, arg) => snapLauncher), - updatesModelProvider.overrideWith((ref) => updatesModel), ], ); @@ -257,10 +253,8 @@ void main() { final service = registerMockSnapdService( storeSnap: storeSnap, ); - final updatesModel = createMockUpdatesModel(); final container = createContainer( overrides: [ - updatesModelProvider.overrideWith((ref) => updatesModel), launchProvider.overrideWith((ref, arg) => createMockSnapLauncher()), ], ); @@ -296,13 +290,11 @@ void main() { final service = registerMockSnapdService(localSnap: localSnap); final ratingsService = getService() as MockRatingsService; final snapLauncher = createMockSnapLauncher(isLaunchable: true); - final updatesModel = createMockUpdatesModel(); await tester.pumpApp( (_) => ProviderScope( overrides: [ launchProvider.overrideWith((ref, arg) => snapLauncher), - updatesModelProvider.overrideWith((ref) => updatesModel), ], child: SnapPage(snapName: localSnap.name), ), @@ -357,12 +349,10 @@ void main() { testWidgets('loading', (tester) async { registerMockSnapdService(localSnap: localSnap, storeSnap: storeSnap); final snapLauncher = createMockSnapLauncher(isLaunchable: true); - final updatesModel = createMockUpdatesModel(); final container = createContainer( overrides: [ launchProvider.overrideWith((ref, arg) => snapLauncher), - updatesModelProvider.overrideWith((ref) => updatesModel), ], ); diff --git a/packages/app_center/test/store_app_test.dart b/packages/app_center/test/store_app_test.dart index 76f16a0b0..e4de5624d 100644 --- a/packages/app_center/test/store_app_test.dart +++ b/packages/app_center/test/store_app_test.dart @@ -24,13 +24,10 @@ void main() { createMockGtkApplicationNotifier(), ); registerMockService(registerMockRatingsService()); + registerMockSnapdService(); await tester.pumpApp( - (_) => ProviderScope( - overrides: [ - updatesModelProvider - .overrideWith((ref) => createMockUpdatesModel()), - ], - child: const StoreApp(), + (_) => const ProviderScope( + child: StoreApp(), ), ); await tester.pump(); @@ -43,20 +40,21 @@ void main() { }); testWidgets('updates available', (tester) async { + final snaps = [ + createSnap(name: 'firefox'), + createSnap(name: 'thunderbird'), + ]; + registerMockSnapdService( + refreshableSnaps: snaps, + installedSnaps: snaps, + ); registerMockService( createMockGtkApplicationNotifier(), ); registerMockService(registerMockRatingsService()); await tester.pumpApp( - (_) => ProviderScope( - overrides: [ - updatesModelProvider.overrideWith( - (ref) => createMockUpdatesModel( - refreshableSnapNames: ['firefox', 'thunderbird'], - ), - ), - ], - child: const StoreApp(), + (_) => const ProviderScope( + child: StoreApp(), ), ); await tester.pump(); diff --git a/packages/app_center/test/test_utils.dart b/packages/app_center/test/test_utils.dart index d9f090348..eb687d4e3 100644 --- a/packages/app_center/test/test_utils.dart +++ b/packages/app_center/test/test_utils.dart @@ -4,8 +4,8 @@ import 'dart:io'; import 'package:app_center/appstream/appstream.dart'; import 'package:app_center/deb/deb_model.dart'; import 'package:app_center/l10n.dart'; -import 'package:app_center/manage/manage_model.dart'; import 'package:app_center/packagekit/packagekit.dart'; +import 'package:app_center/providers/error_stream_provider.dart'; import 'package:app_center/providers/file_system_provider.dart'; import 'package:app_center/ratings/ratings.dart'; import 'package:app_center/snapd/multisnap_model.dart'; @@ -134,19 +134,11 @@ DebModel createMockDebModel({ return model; } -@GenerateMocks([ManageModel]) -ManageModel createMockManageModel({ - Iterable? refreshableSnaps, - Iterable? nonRefreshableSnaps, - AsyncValue? state, -}) { - final model = MockManageModel(); - when(model.state).thenReturn(state ?? AsyncValue.data(() {}())); - when(model.refreshableSnaps) - .thenReturn(refreshableSnaps ?? const Iterable.empty()); - when(model.nonRefreshableSnaps) - .thenReturn(nonRefreshableSnaps ?? const Iterable.empty()); - return model; +@GenerateMocks([ErrorStreamController]) +MockErrorStreamController registerMockErrorStreamControllerService() { + final service = MockErrorStreamController(); + registerMockService(service); + return service; } @GenerateMocks([SnapdService]) @@ -220,26 +212,6 @@ MockSnapdService registerMockSnapdService({ return service; } -@GenerateMocks([UpdatesModel]) -MockUpdatesModel createMockUpdatesModel({ - Iterable? refreshableSnapNames, - Stream? errorStream, - bool isBusy = false, -}) { - final model = MockUpdatesModel(); - when(model.refreshableSnapNames) - .thenReturn(refreshableSnapNames ?? const Iterable.empty()); - when(model.hasUpdate(any)).thenAnswer( - (i) => - refreshableSnapNames?.contains(i.positionalArguments.single) ?? false, - ); - when(model.state).thenReturn(AsyncValue.data(() {}())); - when(model.activeChangeId).thenReturn(isBusy ? 'changeId' : null); - when(model.errorStream) - .thenAnswer((_) => errorStream ?? const Stream.empty()); - return model; -} - @GenerateMocks([GtkApplicationNotifier]) MockGtkApplicationNotifier createMockGtkApplicationNotifier() { final notifier = MockGtkApplicationNotifier(); @@ -394,15 +366,9 @@ MockPackageKitService createMockPackageKitService({ return packageKit; } -// TODO: Move down to dummy class -@GenerateMocks([Vote]) -Vote createMockVote() { - final model = MockVote(); - return model; -} - @GenerateMocks([ MultiSnapModel, + Vote, ]) class _Dummy {} // ignore: unused_element diff --git a/packages/app_center/test/test_utils.mocks.dart b/packages/app_center/test/test_utils.mocks.dart index e8c1732e4..d6673dc24 100644 --- a/packages/app_center/test/test_utils.mocks.dart +++ b/packages/app_center/test/test_utils.mocks.dart @@ -3,30 +3,29 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i13; -import 'dart:ui' as _i14; +import 'dart:async' as _i10; +import 'dart:ui' as _i13; -import 'package:app_center/appstream/appstream.dart' as _i6; +import 'package:app_center/appstream/appstream.dart' as _i7; import 'package:app_center/deb/deb_model.dart' as _i15; -import 'package:app_center/manage/manage_model.dart' as _i18; -import 'package:app_center/manage/manage_snaps_data.dart' as _i9; -import 'package:app_center/packagekit/packagekit.dart' as _i7; -import 'package:app_center/ratings/ratings_service.dart' as _i21; +import 'package:app_center/packagekit/packagekit.dart' as _i8; +import 'package:app_center/providers/error_stream_provider.dart' as _i17; +import 'package:app_center/ratings/ratings_service.dart' as _i20; import 'package:app_center/snapd/multisnap_model.dart' as _i12; import 'package:app_center/snapd/snapd.dart' as _i2; import 'package:app_center_ratings_client/app_center_ratings_client.dart' - as _i11; -import 'package:app_center_ratings_client/src/chart.dart' as _i22; -import 'package:appstream/appstream.dart' as _i8; -import 'package:dbus/dbus.dart' as _i20; -import 'package:file/file.dart' as _i10; + as _i4; +import 'package:app_center_ratings_client/src/chart.dart' as _i21; +import 'package:appstream/appstream.dart' as _i9; +import 'package:dbus/dbus.dart' as _i19; +import 'package:file/file.dart' as _i11; import 'package:flutter_riverpod/flutter_riverpod.dart' as _i3; -import 'package:gtk/src/gtk_application_notifier.dart' as _i19; +import 'package:gtk/src/gtk_application_notifier.dart' as _i18; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i16; -import 'package:packagekit/packagekit.dart' as _i17; -import 'package:snapcraft_launcher/snapcraft_launcher.dart' as _i5; -import 'package:snapd/snapd.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i14; +import 'package:packagekit/packagekit.dart' as _i16; +import 'package:snapcraft_launcher/snapcraft_launcher.dart' as _i6; +import 'package:snapd/snapd.dart' as _i5; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -61,8 +60,8 @@ class _FakeAsyncValue_1 extends _i1.SmartFake implements _i3.AsyncValue { ); } -class _FakeSnap_2 extends _i1.SmartFake implements _i4.Snap { - _FakeSnap_2( +class _FakeDateTime_2 extends _i1.SmartFake implements DateTime { + _FakeDateTime_2( Object parent, Invocation parentInvocation, ) : super( @@ -71,9 +70,9 @@ class _FakeSnap_2 extends _i1.SmartFake implements _i4.Snap { ); } -class _FakePrivilegedDesktopLauncher_3 extends _i1.SmartFake - implements _i5.PrivilegedDesktopLauncher { - _FakePrivilegedDesktopLauncher_3( +class _Fake$VoteCopyWith_3<$Res> extends _i1.SmartFake + implements _i4.$VoteCopyWith<$Res> { + _Fake$VoteCopyWith_3( Object parent, Invocation parentInvocation, ) : super( @@ -82,9 +81,8 @@ class _FakePrivilegedDesktopLauncher_3 extends _i1.SmartFake ); } -class _FakeAppstreamService_4 extends _i1.SmartFake - implements _i6.AppstreamService { - _FakeAppstreamService_4( +class _FakeSnap_4 extends _i1.SmartFake implements _i5.Snap { + _FakeSnap_4( Object parent, Invocation parentInvocation, ) : super( @@ -93,9 +91,9 @@ class _FakeAppstreamService_4 extends _i1.SmartFake ); } -class _FakePackageKitService_5 extends _i1.SmartFake - implements _i7.PackageKitService { - _FakePackageKitService_5( +class _FakePrivilegedDesktopLauncher_5 extends _i1.SmartFake + implements _i6.PrivilegedDesktopLauncher { + _FakePrivilegedDesktopLauncher_5( Object parent, Invocation parentInvocation, ) : super( @@ -104,9 +102,9 @@ class _FakePackageKitService_5 extends _i1.SmartFake ); } -class _FakeAppstreamComponent_6 extends _i1.SmartFake - implements _i8.AppstreamComponent { - _FakeAppstreamComponent_6( +class _FakeAppstreamService_6 extends _i1.SmartFake + implements _i7.AppstreamService { + _FakeAppstreamService_6( Object parent, Invocation parentInvocation, ) : super( @@ -115,9 +113,9 @@ class _FakeAppstreamComponent_6 extends _i1.SmartFake ); } -class _FakeAsyncNotifierProviderRef_7 extends _i1.SmartFake - implements _i3.AsyncNotifierProviderRef { - _FakeAsyncNotifierProviderRef_7( +class _FakePackageKitService_7 extends _i1.SmartFake + implements _i8.PackageKitService { + _FakePackageKitService_7( Object parent, Invocation parentInvocation, ) : super( @@ -126,9 +124,9 @@ class _FakeAsyncNotifierProviderRef_7 extends _i1.SmartFake ); } -class _FakeManageSnapsData_8 extends _i1.SmartFake - implements _i9.ManageSnapsData { - _FakeManageSnapsData_8( +class _FakeAppstreamComponent_8 extends _i1.SmartFake + implements _i9.AppstreamComponent { + _FakeAppstreamComponent_8( Object parent, Invocation parentInvocation, ) : super( @@ -137,8 +135,8 @@ class _FakeManageSnapsData_8 extends _i1.SmartFake ); } -class _FakeFileSystem_9 extends _i1.SmartFake implements _i10.FileSystem { - _FakeFileSystem_9( +class _FakeStreamSink_9 extends _i1.SmartFake implements _i10.StreamSink { + _FakeStreamSink_9( Object parent, Invocation parentInvocation, ) : super( @@ -147,9 +145,8 @@ class _FakeFileSystem_9 extends _i1.SmartFake implements _i10.FileSystem { ); } -class _FakeSnapdSystemInfoResponse_10 extends _i1.SmartFake - implements _i4.SnapdSystemInfoResponse { - _FakeSnapdSystemInfoResponse_10( +class _FakeFileSystem_10 extends _i1.SmartFake implements _i11.FileSystem { + _FakeFileSystem_10( Object parent, Invocation parentInvocation, ) : super( @@ -158,9 +155,9 @@ class _FakeSnapdSystemInfoResponse_10 extends _i1.SmartFake ); } -class _FakeSnapdConnectionsResponse_11 extends _i1.SmartFake - implements _i4.SnapdConnectionsResponse { - _FakeSnapdConnectionsResponse_11( +class _FakeSnapdSystemInfoResponse_11 extends _i1.SmartFake + implements _i5.SnapdSystemInfoResponse { + _FakeSnapdSystemInfoResponse_11( Object parent, Invocation parentInvocation, ) : super( @@ -169,9 +166,9 @@ class _FakeSnapdConnectionsResponse_11 extends _i1.SmartFake ); } -class _FakeSnapdLoginResponse_12 extends _i1.SmartFake - implements _i4.SnapdLoginResponse { - _FakeSnapdLoginResponse_12( +class _FakeSnapdConnectionsResponse_12 extends _i1.SmartFake + implements _i5.SnapdConnectionsResponse { + _FakeSnapdConnectionsResponse_12( Object parent, Invocation parentInvocation, ) : super( @@ -180,8 +177,9 @@ class _FakeSnapdLoginResponse_12 extends _i1.SmartFake ); } -class _FakeSnapdChange_13 extends _i1.SmartFake implements _i4.SnapdChange { - _FakeSnapdChange_13( +class _FakeSnapdLoginResponse_13 extends _i1.SmartFake + implements _i5.SnapdLoginResponse { + _FakeSnapdLoginResponse_13( Object parent, Invocation parentInvocation, ) : super( @@ -190,9 +188,8 @@ class _FakeSnapdChange_13 extends _i1.SmartFake implements _i4.SnapdChange { ); } -class _FakePackageKitTransaction_14 extends _i1.SmartFake - implements _i7.PackageKitTransaction { - _FakePackageKitTransaction_14( +class _FakeSnapdChange_14 extends _i1.SmartFake implements _i5.SnapdChange { + _FakeSnapdChange_14( Object parent, Invocation parentInvocation, ) : super( @@ -201,9 +198,9 @@ class _FakePackageKitTransaction_14 extends _i1.SmartFake ); } -class _FakeRatingsClient_15 extends _i1.SmartFake - implements _i11.RatingsClient { - _FakeRatingsClient_15( +class _FakePackageKitTransaction_15 extends _i1.SmartFake + implements _i8.PackageKitTransaction { + _FakePackageKitTransaction_15( Object parent, Invocation parentInvocation, ) : super( @@ -212,8 +209,8 @@ class _FakeRatingsClient_15 extends _i1.SmartFake ); } -class _FakeRating_16 extends _i1.SmartFake implements _i11.Rating { - _FakeRating_16( +class _FakeRatingsClient_16 extends _i1.SmartFake implements _i4.RatingsClient { + _FakeRatingsClient_16( Object parent, Invocation parentInvocation, ) : super( @@ -222,19 +219,8 @@ class _FakeRating_16 extends _i1.SmartFake implements _i11.Rating { ); } -class _FakeDateTime_17 extends _i1.SmartFake implements DateTime { - _FakeDateTime_17( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _Fake$VoteCopyWith_18<$Res> extends _i1.SmartFake - implements _i11.$VoteCopyWith<$Res> { - _Fake$VoteCopyWith_18( +class _FakeRating_17 extends _i1.SmartFake implements _i4.Rating { + _FakeRating_17( Object parent, Invocation parentInvocation, ) : super( @@ -267,13 +253,13 @@ class MockMultiSnapModel extends _i1.Mock implements _i12.MultiSnapModel { ) as _i2.SnapCategoryEnum); @override - List<_i4.Snap> get categorySnaps => (super.noSuchMethod( + List<_i5.Snap> get categorySnaps => (super.noSuchMethod( Invocation.getter(#categorySnaps), - returnValue: <_i4.Snap>[], - ) as List<_i4.Snap>); + returnValue: <_i5.Snap>[], + ) as List<_i5.Snap>); @override - set categorySnaps(List<_i4.Snap>? _categorySnaps) => super.noSuchMethod( + set categorySnaps(List<_i5.Snap>? _categorySnaps) => super.noSuchMethod( Invocation.setter( #categorySnaps, _categorySnaps, @@ -297,47 +283,47 @@ class MockMultiSnapModel extends _i1.Mock implements _i12.MultiSnapModel { ) as bool); @override - _i13.Future init() => (super.noSuchMethod( + _i10.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future dispose() => (super.noSuchMethod( + _i10.Future dispose() => (super.noSuchMethod( Invocation.method( #dispose, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future cancel() => (super.noSuchMethod( + _i10.Future cancel() => (super.noSuchMethod( Invocation.method( #cancel, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future installAll() => (super.noSuchMethod( + _i10.Future installAll() => (super.noSuchMethod( Invocation.method( #installAll, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -346,7 +332,7 @@ class MockMultiSnapModel extends _i1.Mock implements _i12.MultiSnapModel { ); @override - void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -364,6 +350,54 @@ class MockMultiSnapModel extends _i1.Mock implements _i12.MultiSnapModel { ); } +/// A class which mocks [Vote]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockVote extends _i1.Mock implements _i4.Vote { + MockVote() { + _i1.throwOnMissingStub(this); + } + + @override + String get snapId => (super.noSuchMethod( + Invocation.getter(#snapId), + returnValue: _i14.dummyValue( + this, + Invocation.getter(#snapId), + ), + ) as String); + + @override + int get snapRevision => (super.noSuchMethod( + Invocation.getter(#snapRevision), + returnValue: 0, + ) as int); + + @override + bool get voteUp => (super.noSuchMethod( + Invocation.getter(#voteUp), + returnValue: false, + ) as bool); + + @override + DateTime get dateTime => (super.noSuchMethod( + Invocation.getter(#dateTime), + returnValue: _FakeDateTime_2( + this, + Invocation.getter(#dateTime), + ), + ) as DateTime); + + @override + _i4.$VoteCopyWith<_i4.Vote> get copyWith => (super.noSuchMethod( + Invocation.getter(#copyWith), + returnValue: _Fake$VoteCopyWith_3<_i4.Vote>( + this, + Invocation.getter(#copyWith), + ), + ) as _i4.$VoteCopyWith<_i4.Vote>); +} + /// A class which mocks [SnapLauncher]. /// /// See the documentation for Mockito's code generation for more information. @@ -373,22 +407,22 @@ class MockSnapLauncher extends _i1.Mock implements _i2.SnapLauncher { } @override - _i4.Snap get snap => (super.noSuchMethod( + _i5.Snap get snap => (super.noSuchMethod( Invocation.getter(#snap), - returnValue: _FakeSnap_2( + returnValue: _FakeSnap_4( this, Invocation.getter(#snap), ), - ) as _i4.Snap); + ) as _i5.Snap); @override - _i5.PrivilegedDesktopLauncher get launcher => (super.noSuchMethod( + _i6.PrivilegedDesktopLauncher get launcher => (super.noSuchMethod( Invocation.getter(#launcher), - returnValue: _FakePrivilegedDesktopLauncher_3( + returnValue: _FakePrivilegedDesktopLauncher_5( this, Invocation.getter(#launcher), ), - ) as _i5.PrivilegedDesktopLauncher); + ) as _i6.PrivilegedDesktopLauncher); @override bool get isLaunchable => (super.noSuchMethod( @@ -415,43 +449,43 @@ class MockDebModel extends _i1.Mock implements _i15.DebModel { } @override - _i6.AppstreamService get appstream => (super.noSuchMethod( + _i7.AppstreamService get appstream => (super.noSuchMethod( Invocation.getter(#appstream), - returnValue: _FakeAppstreamService_4( + returnValue: _FakeAppstreamService_6( this, Invocation.getter(#appstream), ), - ) as _i6.AppstreamService); + ) as _i7.AppstreamService); @override - _i7.PackageKitService get packageKit => (super.noSuchMethod( + _i8.PackageKitService get packageKit => (super.noSuchMethod( Invocation.getter(#packageKit), - returnValue: _FakePackageKitService_5( + returnValue: _FakePackageKitService_7( this, Invocation.getter(#packageKit), ), - ) as _i7.PackageKitService); + ) as _i8.PackageKitService); @override String get id => (super.noSuchMethod( Invocation.getter(#id), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#id), ), ) as String); @override - _i8.AppstreamComponent get component => (super.noSuchMethod( + _i9.AppstreamComponent get component => (super.noSuchMethod( Invocation.getter(#component), - returnValue: _FakeAppstreamComponent_6( + returnValue: _FakeAppstreamComponent_8( this, Invocation.getter(#component), ), - ) as _i8.AppstreamComponent); + ) as _i9.AppstreamComponent); @override - set packageInfo(_i17.PackageKitPackageEvent? _packageInfo) => + set packageInfo(_i16.PackageKitPackageEvent? _packageInfo) => super.noSuchMethod( Invocation.setter( #packageInfo, @@ -476,11 +510,11 @@ class MockDebModel extends _i1.Mock implements _i15.DebModel { ) as bool); @override - _i13.Stream<_i17.PackageKitErrorCodeEvent> get errorStream => + _i10.Stream<_i16.PackageKitErrorCodeEvent> get errorStream => (super.noSuchMethod( Invocation.getter(#errorStream), - returnValue: _i13.Stream<_i17.PackageKitErrorCodeEvent>.empty(), - ) as _i13.Stream<_i17.PackageKitErrorCodeEvent>); + returnValue: _i10.Stream<_i16.PackageKitErrorCodeEvent>.empty(), + ) as _i10.Stream<_i16.PackageKitErrorCodeEvent>); @override bool get hasListeners => (super.noSuchMethod( @@ -489,47 +523,47 @@ class MockDebModel extends _i1.Mock implements _i15.DebModel { ) as bool); @override - _i13.Future init() => (super.noSuchMethod( + _i10.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future install() => (super.noSuchMethod( + _i10.Future install() => (super.noSuchMethod( Invocation.method( #install, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future remove() => (super.noSuchMethod( + _i10.Future remove() => (super.noSuchMethod( Invocation.method( #remove, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future cancel() => (super.noSuchMethod( + _i10.Future cancel() => (super.noSuchMethod( Invocation.method( #cancel, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -538,7 +572,7 @@ class MockDebModel extends _i1.Mock implements _i15.DebModel { ); @override - void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -565,109 +599,137 @@ class MockDebModel extends _i1.Mock implements _i15.DebModel { ); } -/// A class which mocks [ManageModel]. +/// A class which mocks [ErrorStreamController]. /// /// See the documentation for Mockito's code generation for more information. -class MockManageModel extends _i1.Mock implements _i18.ManageModel { - MockManageModel() { +class MockErrorStreamController extends _i1.Mock + implements _i17.ErrorStreamController { + MockErrorStreamController() { _i1.throwOnMissingStub(this); } @override - _i3.AsyncNotifierProviderRef<_i9.ManageSnapsData> get ref => - (super.noSuchMethod( - Invocation.getter(#ref), - returnValue: _FakeAsyncNotifierProviderRef_7<_i9.ManageSnapsData>( - this, - Invocation.getter(#ref), + set onListen(void Function()? _onListen) => super.noSuchMethod( + Invocation.setter( + #onListen, + _onListen, ), - ) as _i3.AsyncNotifierProviderRef<_i9.ManageSnapsData>); + returnValueForMissingStub: null, + ); @override - _i3.AsyncValue<_i9.ManageSnapsData> get state => (super.noSuchMethod( - Invocation.getter(#state), - returnValue: _FakeAsyncValue_1<_i9.ManageSnapsData>( - this, - Invocation.getter(#state), + set onPause(void Function()? _onPause) => super.noSuchMethod( + Invocation.setter( + #onPause, + _onPause, ), - ) as _i3.AsyncValue<_i9.ManageSnapsData>); + returnValueForMissingStub: null, + ); @override - set state(_i3.AsyncValue<_i9.ManageSnapsData>? newState) => - super.noSuchMethod( + set onResume(void Function()? _onResume) => super.noSuchMethod( Invocation.setter( - #state, - newState, + #onResume, + _onResume, ), returnValueForMissingStub: null, ); @override - _i13.Future<_i9.ManageSnapsData> get future => (super.noSuchMethod( - Invocation.getter(#future), - returnValue: - _i13.Future<_i9.ManageSnapsData>.value(_FakeManageSnapsData_8( + set onCancel(_i10.FutureOr Function()? _onCancel) => super.noSuchMethod( + Invocation.setter( + #onCancel, + _onCancel, + ), + returnValueForMissingStub: null, + ); + + @override + _i10.Stream get stream => (super.noSuchMethod( + Invocation.getter(#stream), + returnValue: _i10.Stream.empty(), + ) as _i10.Stream); + + @override + _i10.StreamSink get sink => (super.noSuchMethod( + Invocation.getter(#sink), + returnValue: _FakeStreamSink_9( this, - Invocation.getter(#future), - )), - ) as _i13.Future<_i9.ManageSnapsData>); + Invocation.getter(#sink), + ), + ) as _i10.StreamSink); + + @override + bool get isClosed => (super.noSuchMethod( + Invocation.getter(#isClosed), + returnValue: false, + ) as bool); + + @override + bool get isPaused => (super.noSuchMethod( + Invocation.getter(#isPaused), + returnValue: false, + ) as bool); + + @override + bool get hasListener => (super.noSuchMethod( + Invocation.getter(#hasListener), + returnValue: false, + ) as bool); + + @override + _i10.Future get done => (super.noSuchMethod( + Invocation.getter(#done), + returnValue: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future<_i9.ManageSnapsData> build() => (super.noSuchMethod( + void add(Exception? event) => super.noSuchMethod( Invocation.method( - #build, - [], + #add, + [event], ), - returnValue: - _i13.Future<_i9.ManageSnapsData>.value(_FakeManageSnapsData_8( - this, - Invocation.method( - #build, - [], - ), - )), - ) as _i13.Future<_i9.ManageSnapsData>); + returnValueForMissingStub: null, + ); @override - _i13.Future<_i9.ManageSnapsData> update( - _i13.FutureOr<_i9.ManageSnapsData> Function(_i9.ManageSnapsData)? cb, { - _i13.FutureOr<_i9.ManageSnapsData> Function( - Object, - StackTrace, - )? onError, - }) => - (super.noSuchMethod( + void addError( + Object? error, [ + StackTrace? stackTrace, + ]) => + super.noSuchMethod( Invocation.method( - #update, - [cb], - {#onError: onError}, + #addError, + [ + error, + stackTrace, + ], ), - returnValue: - _i13.Future<_i9.ManageSnapsData>.value(_FakeManageSnapsData_8( - this, - Invocation.method( - #update, - [cb], - {#onError: onError}, - ), - )), - ) as _i13.Future<_i9.ManageSnapsData>); + returnValueForMissingStub: null, + ); @override - bool updateShouldNotify( - _i3.AsyncValue<_i9.ManageSnapsData>? previous, - _i3.AsyncValue<_i9.ManageSnapsData>? next, - ) => + _i10.Future close() => (super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValue: _i10.Future.value(), + ) as _i10.Future); + + @override + _i10.Future addStream( + _i10.Stream? source, { + bool? cancelOnError, + }) => (super.noSuchMethod( Invocation.method( - #updateShouldNotify, - [ - previous, - next, - ], + #addStream, + [source], + {#cancelOnError: cancelOnError}, ), - returnValue: false, - ) as bool); + returnValue: _i10.Future.value(), + ) as _i10.Future); } /// A class which mocks [SnapdService]. @@ -703,34 +765,34 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ); @override - _i10.FileSystem get defaultFileSystem => (super.noSuchMethod( + _i11.FileSystem get defaultFileSystem => (super.noSuchMethod( Invocation.getter(#defaultFileSystem), - returnValue: _FakeFileSystem_9( + returnValue: _FakeFileSystem_10( this, Invocation.getter(#defaultFileSystem), ), - ) as _i10.FileSystem); + ) as _i11.FileSystem); @override - _i13.Future waitChange(String? changeId) => (super.noSuchMethod( + _i10.Future waitChange(String? changeId) => (super.noSuchMethod( Invocation.method( #waitChange, [changeId], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future loadAuthorization({String? path}) => (super.noSuchMethod( + _i10.Future loadAuthorization({String? path}) => (super.noSuchMethod( Invocation.method( #loadAuthorization, [], {#path: path}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override void setAuthorization( @@ -749,49 +811,49 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ); @override - _i13.Future<_i4.SnapdSystemInfoResponse> systemInfo() => (super.noSuchMethod( + _i10.Future<_i5.SnapdSystemInfoResponse> systemInfo() => (super.noSuchMethod( Invocation.method( #systemInfo, [], ), - returnValue: _i13.Future<_i4.SnapdSystemInfoResponse>.value( - _FakeSnapdSystemInfoResponse_10( + returnValue: _i10.Future<_i5.SnapdSystemInfoResponse>.value( + _FakeSnapdSystemInfoResponse_11( this, Invocation.method( #systemInfo, [], ), )), - ) as _i13.Future<_i4.SnapdSystemInfoResponse>); + ) as _i10.Future<_i5.SnapdSystemInfoResponse>); @override - _i13.Future> getSnaps() => (super.noSuchMethod( + _i10.Future> getSnaps() => (super.noSuchMethod( Invocation.method( #getSnaps, [], ), - returnValue: _i13.Future>.value(<_i4.Snap>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i5.Snap>[]), + ) as _i10.Future>); @override - _i13.Future<_i4.Snap> getSnap(String? name) => (super.noSuchMethod( + _i10.Future<_i5.Snap> getSnap(String? name) => (super.noSuchMethod( Invocation.method( #getSnap, [name], ), - returnValue: _i13.Future<_i4.Snap>.value(_FakeSnap_2( + returnValue: _i10.Future<_i5.Snap>.value(_FakeSnap_4( this, Invocation.method( #getSnap, [name], ), )), - ) as _i13.Future<_i4.Snap>); + ) as _i10.Future<_i5.Snap>); @override - _i13.Future> getApps({ + _i10.Future> getApps({ List? names, - _i4.SnapdAppFilter? filter, + _i5.SnapdAppFilter? filter, }) => (super.noSuchMethod( Invocation.method( @@ -802,25 +864,25 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #filter: filter, }, ), - returnValue: _i13.Future>.value(<_i4.SnapApp>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i5.SnapApp>[]), + ) as _i10.Future>); @override - _i13.Future> getCategories() => + _i10.Future> getCategories() => (super.noSuchMethod( Invocation.method( #getCategories, [], ), - returnValue: _i13.Future>.value( - <_i4.SnapCategoryDetails>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value( + <_i5.SnapCategoryDetails>[]), + ) as _i10.Future>); @override - _i13.Future<_i4.SnapdConnectionsResponse> getConnections({ + _i10.Future<_i5.SnapdConnectionsResponse> getConnections({ String? snap, String? interface, - _i4.SnapdConnectionFilter? filter, + _i5.SnapdConnectionFilter? filter, }) => (super.noSuchMethod( Invocation.method( @@ -832,8 +894,8 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #filter: filter, }, ), - returnValue: _i13.Future<_i4.SnapdConnectionsResponse>.value( - _FakeSnapdConnectionsResponse_11( + returnValue: _i10.Future<_i5.SnapdConnectionsResponse>.value( + _FakeSnapdConnectionsResponse_12( this, Invocation.method( #getConnections, @@ -845,25 +907,25 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { }, ), )), - ) as _i13.Future<_i4.SnapdConnectionsResponse>); + ) as _i10.Future<_i5.SnapdConnectionsResponse>); @override - _i13.Future refreshMany(List? names) => (super.noSuchMethod( + _i10.Future refreshMany(List? names) => (super.noSuchMethod( Invocation.method( #refreshMany, [names], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #refreshMany, [names], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future installMany( + _i10.Future installMany( List? names, { bool? classic = false, }) => @@ -873,7 +935,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { [names], {#classic: classic}, ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #installMany, @@ -881,10 +943,10 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { {#classic: classic}, ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future connect( + _i10.Future connect( String? snap, String? plug, String? slotSnap, @@ -900,7 +962,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { slot, ], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #connect, @@ -912,10 +974,10 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future disconnect( + _i10.Future disconnect( String? plugSnap, String? plug, String? slotSnap, @@ -931,7 +993,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { slot, ], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #disconnect, @@ -943,16 +1005,16 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future> find({ + _i10.Future> find({ String? query, String? name, String? category, String? section, - _i4.SnapFindFilter? filter, - _i4.SnapFindScope? scope, + _i5.SnapFindFilter? filter, + _i5.SnapFindScope? scope, }) => (super.noSuchMethod( Invocation.method( @@ -967,11 +1029,11 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #scope: scope, }, ), - returnValue: _i13.Future>.value(<_i4.Snap>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i5.Snap>[]), + ) as _i10.Future>); @override - _i13.Future> getAssertions({ + _i10.Future> getAssertions({ String? assertion, Map? params, }) => @@ -985,11 +1047,11 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { }, ), returnValue: - _i13.Future>.value({}), - ) as _i13.Future>); + _i10.Future>.value({}), + ) as _i10.Future>); @override - _i13.Future<_i4.SnapdLoginResponse> login( + _i10.Future<_i5.SnapdLoginResponse> login( String? email, String? password, { String? otp, @@ -1003,8 +1065,8 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ], {#otp: otp}, ), - returnValue: _i13.Future<_i4.SnapdLoginResponse>.value( - _FakeSnapdLoginResponse_12( + returnValue: _i10.Future<_i5.SnapdLoginResponse>.value( + _FakeSnapdLoginResponse_13( this, Invocation.method( #login, @@ -1015,20 +1077,20 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { {#otp: otp}, ), )), - ) as _i13.Future<_i4.SnapdLoginResponse>); + ) as _i10.Future<_i5.SnapdLoginResponse>); @override - _i13.Future logout(int? id) => (super.noSuchMethod( + _i10.Future logout(int? id) => (super.noSuchMethod( Invocation.method( #logout, [id], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future install( + _i10.Future install( String? name, { String? channel, String? revision, @@ -1050,7 +1112,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #jailmode: jailmode, }, ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #install, @@ -1065,10 +1127,10 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { }, ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future refresh( + _i10.Future refresh( String? name, { String? channel, bool? classic = false, @@ -1082,7 +1144,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #classic: classic, }, ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #refresh, @@ -1093,10 +1155,10 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { }, ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future remove( + _i10.Future remove( String? name, { bool? purge = false, }) => @@ -1106,7 +1168,7 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { [name], {#purge: purge}, ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #remove, @@ -1114,56 +1176,56 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { {#purge: purge}, ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future enable(String? name) => (super.noSuchMethod( + _i10.Future enable(String? name) => (super.noSuchMethod( Invocation.method( #enable, [name], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #enable, [name], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future disable(String? name) => (super.noSuchMethod( + _i10.Future disable(String? name) => (super.noSuchMethod( Invocation.method( #disable, [name], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #disable, [name], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future<_i4.SnapdChange> getChange(String? id) => (super.noSuchMethod( + _i10.Future<_i5.SnapdChange> getChange(String? id) => (super.noSuchMethod( Invocation.method( #getChange, [id], ), - returnValue: _i13.Future<_i4.SnapdChange>.value(_FakeSnapdChange_13( + returnValue: _i10.Future<_i5.SnapdChange>.value(_FakeSnapdChange_14( this, Invocation.method( #getChange, [id], ), )), - ) as _i13.Future<_i4.SnapdChange>); + ) as _i10.Future<_i5.SnapdChange>); @override - _i13.Future> getChanges({ - _i4.SnapdChangeFilter? filter, + _i10.Future> getChanges({ + _i5.SnapdChangeFilter? filter, String? name, }) => (super.noSuchMethod( @@ -1176,23 +1238,23 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { }, ), returnValue: - _i13.Future>.value(<_i4.SnapdChange>[]), - ) as _i13.Future>); + _i10.Future>.value(<_i5.SnapdChange>[]), + ) as _i10.Future>); @override - _i13.Future<_i4.SnapdChange> abortChange(String? id) => (super.noSuchMethod( + _i10.Future<_i5.SnapdChange> abortChange(String? id) => (super.noSuchMethod( Invocation.method( #abortChange, [id], ), - returnValue: _i13.Future<_i4.SnapdChange>.value(_FakeSnapdChange_13( + returnValue: _i10.Future<_i5.SnapdChange>.value(_FakeSnapdChange_14( this, Invocation.method( #abortChange, [id], ), )), - ) as _i13.Future<_i4.SnapdChange>); + ) as _i10.Future<_i5.SnapdChange>); @override void close() => super.noSuchMethod( @@ -1204,10 +1266,10 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { ); @override - _i13.Stream> getCategory( + _i10.Stream> getCategory( String? name, { Duration? expiry = const Duration(days: 1), - _i10.FileSystem? fileSystem, + _i11.FileSystem? fileSystem, }) => (super.noSuchMethod( Invocation.method( @@ -1218,14 +1280,14 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #fileSystem: fileSystem, }, ), - returnValue: _i13.Stream>.empty(), - ) as _i13.Stream>); + returnValue: _i10.Stream>.empty(), + ) as _i10.Stream>); @override - _i13.Stream> getStoreSnaps( + _i10.Stream> getStoreSnaps( List? names, { Duration? expiry = const Duration(minutes: 1), - _i10.FileSystem? fileSystem, + _i11.FileSystem? fileSystem, }) => (super.noSuchMethod( Invocation.method( @@ -1236,11 +1298,11 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #fileSystem: fileSystem, }, ), - returnValue: _i13.Stream>.empty(), - ) as _i13.Stream>); + returnValue: _i10.Stream>.empty(), + ) as _i10.Stream>); @override - _i13.Stream<_i4.SnapdChange> watchChange( + _i10.Stream<_i5.SnapdChange> watchChange( String? id, { Duration? interval = const Duration(milliseconds: 100), }) => @@ -1250,11 +1312,11 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { [id], {#interval: interval}, ), - returnValue: _i13.Stream<_i4.SnapdChange>.empty(), - ) as _i13.Stream<_i4.SnapdChange>); + returnValue: _i10.Stream<_i5.SnapdChange>.empty(), + ) as _i10.Stream<_i5.SnapdChange>); @override - _i13.Stream> watchChanges({ + _i10.Stream> watchChanges({ String? name, Duration? interval = const Duration(milliseconds: 100), }) => @@ -1267,141 +1329,21 @@ class MockSnapdService extends _i1.Mock implements _i2.SnapdService { #interval: interval, }, ), - returnValue: _i13.Stream>.empty(), - ) as _i13.Stream>); -} - -/// A class which mocks [UpdatesModel]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockUpdatesModel extends _i1.Mock implements _i2.UpdatesModel { - MockUpdatesModel() { - _i1.throwOnMissingStub(this); - } - - @override - _i2.SnapdService get snapd => (super.noSuchMethod( - Invocation.getter(#snapd), - returnValue: _FakeSnapdService_0( - this, - Invocation.getter(#snapd), - ), - ) as _i2.SnapdService); - - @override - Iterable get refreshableSnapNames => (super.noSuchMethod( - Invocation.getter(#refreshableSnapNames), - returnValue: [], - ) as Iterable); - - @override - _i3.AsyncValue get state => (super.noSuchMethod( - Invocation.getter(#state), - returnValue: _FakeAsyncValue_1( - this, - Invocation.getter(#state), - ), - ) as _i3.AsyncValue); - - @override - _i13.Stream<_i4.SnapdException> get errorStream => (super.noSuchMethod( - Invocation.getter(#errorStream), - returnValue: _i13.Stream<_i4.SnapdException>.empty(), - ) as _i13.Stream<_i4.SnapdException>); - - @override - bool get hasListeners => (super.noSuchMethod( - Invocation.getter(#hasListeners), - returnValue: false, - ) as bool); - - @override - _i13.Future refresh() => (super.noSuchMethod( - Invocation.method( - #refresh, - [], - ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); - - @override - bool hasUpdate(String? snapName) => (super.noSuchMethod( - Invocation.method( - #hasUpdate, - [snapName], - ), - returnValue: false, - ) as bool); - - @override - _i13.Future updateAll() => (super.noSuchMethod( - Invocation.method( - #updateAll, - [], - ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); - - @override - _i13.Future cancelChange(String? changeId) => (super.noSuchMethod( - Invocation.method( - #cancelChange, - [changeId], - ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); - - @override - void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #addListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( - Invocation.method( - #removeListener, - [listener], - ), - returnValueForMissingStub: null, - ); - - @override - void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); - - @override - void notifyListeners() => super.noSuchMethod( - Invocation.method( - #notifyListeners, - [], - ), - returnValueForMissingStub: null, - ); + returnValue: _i10.Stream>.empty(), + ) as _i10.Stream>); } /// A class which mocks [GtkApplicationNotifier]. /// /// See the documentation for Mockito's code generation for more information. class MockGtkApplicationNotifier extends _i1.Mock - implements _i19.GtkApplicationNotifier { + implements _i18.GtkApplicationNotifier { MockGtkApplicationNotifier() { _i1.throwOnMissingStub(this); } @override - void addCommandLineListener(_i19.GtkCommandLineListener? listener) => + void addCommandLineListener(_i18.GtkCommandLineListener? listener) => super.noSuchMethod( Invocation.method( #addCommandLineListener, @@ -1411,7 +1353,7 @@ class MockGtkApplicationNotifier extends _i1.Mock ); @override - void removeCommandLineListener(_i19.GtkCommandLineListener? listener) => + void removeCommandLineListener(_i18.GtkCommandLineListener? listener) => super.noSuchMethod( Invocation.method( #removeCommandLineListener, @@ -1421,7 +1363,7 @@ class MockGtkApplicationNotifier extends _i1.Mock ); @override - void addOpenListener(_i19.GtkOpenListener? listener) => super.noSuchMethod( + void addOpenListener(_i18.GtkOpenListener? listener) => super.noSuchMethod( Invocation.method( #addOpenListener, [listener], @@ -1430,7 +1372,7 @@ class MockGtkApplicationNotifier extends _i1.Mock ); @override - void removeOpenListener(_i19.GtkOpenListener? listener) => super.noSuchMethod( + void removeOpenListener(_i18.GtkOpenListener? listener) => super.noSuchMethod( Invocation.method( #removeOpenListener, [listener], @@ -1477,7 +1419,7 @@ class MockGtkApplicationNotifier extends _i1.Mock /// A class which mocks [PackageKitClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { +class MockPackageKitClient extends _i1.Mock implements _i16.PackageKitClient { MockPackageKitClient() { _i1.throwOnMissingStub(this); } @@ -1554,7 +1496,7 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { @override String get backendAuthor => (super.noSuchMethod( Invocation.getter(#backendAuthor), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#backendAuthor), ), @@ -1563,7 +1505,7 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { @override String get backendDescription => (super.noSuchMethod( Invocation.getter(#backendDescription), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#backendDescription), ), @@ -1572,7 +1514,7 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { @override String get backendName => (super.noSuchMethod( Invocation.getter(#backendName), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#backendName), ), @@ -1581,23 +1523,23 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { @override String get distroId => (super.noSuchMethod( Invocation.getter(#distroId), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#distroId), ), ) as String); @override - Set<_i17.PackageKitFilter> get filters => (super.noSuchMethod( + Set<_i16.PackageKitFilter> get filters => (super.noSuchMethod( Invocation.getter(#filters), - returnValue: <_i17.PackageKitFilter>{}, - ) as Set<_i17.PackageKitFilter>); + returnValue: <_i16.PackageKitFilter>{}, + ) as Set<_i16.PackageKitFilter>); @override - Set<_i17.PackageKitGroup> get groups => (super.noSuchMethod( + Set<_i16.PackageKitGroup> get groups => (super.noSuchMethod( Invocation.getter(#groups), - returnValue: <_i17.PackageKitGroup>{}, - ) as Set<_i17.PackageKitGroup>); + returnValue: <_i16.PackageKitGroup>{}, + ) as Set<_i16.PackageKitGroup>); @override bool get locked => (super.noSuchMethod( @@ -1612,16 +1554,16 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { ) as List); @override - Set<_i17.PackageKitRole> get roles => (super.noSuchMethod( + Set<_i16.PackageKitRole> get roles => (super.noSuchMethod( Invocation.getter(#roles), - returnValue: <_i17.PackageKitRole>{}, - ) as Set<_i17.PackageKitRole>); + returnValue: <_i16.PackageKitRole>{}, + ) as Set<_i16.PackageKitRole>); @override - _i17.PackageKitNetworkState get networkState => (super.noSuchMethod( + _i16.PackageKitNetworkState get networkState => (super.noSuchMethod( Invocation.getter(#networkState), - returnValue: _i17.PackageKitNetworkState.unknown, - ) as _i17.PackageKitNetworkState); + returnValue: _i16.PackageKitNetworkState.unknown, + ) as _i16.PackageKitNetworkState); @override int get versionMajor => (super.noSuchMethod( @@ -1642,84 +1584,84 @@ class MockPackageKitClient extends _i1.Mock implements _i17.PackageKitClient { ) as int); @override - _i13.Stream> get propertiesChanged => (super.noSuchMethod( + _i10.Stream> get propertiesChanged => (super.noSuchMethod( Invocation.getter(#propertiesChanged), - returnValue: _i13.Stream>.empty(), - ) as _i13.Stream>); + returnValue: _i10.Stream>.empty(), + ) as _i10.Stream>); @override - _i13.Future connect() => (super.noSuchMethod( + _i10.Future connect() => (super.noSuchMethod( Invocation.method( #connect, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future<_i7.PackageKitTransaction> getTransaction( - _i20.DBusObjectPath? path) => + _i10.Future<_i8.PackageKitTransaction> getTransaction( + _i19.DBusObjectPath? path) => (super.noSuchMethod( Invocation.method( #getTransaction, [path], ), - returnValue: _i13.Future<_i7.PackageKitTransaction>.value( - _FakePackageKitTransaction_14( + returnValue: _i10.Future<_i8.PackageKitTransaction>.value( + _FakePackageKitTransaction_15( this, Invocation.method( #getTransaction, [path], ), )), - ) as _i13.Future<_i7.PackageKitTransaction>); + ) as _i10.Future<_i8.PackageKitTransaction>); @override - _i13.Future<_i7.PackageKitTransaction> createTransaction() => + _i10.Future<_i8.PackageKitTransaction> createTransaction() => (super.noSuchMethod( Invocation.method( #createTransaction, [], ), - returnValue: _i13.Future<_i7.PackageKitTransaction>.value( - _FakePackageKitTransaction_14( + returnValue: _i10.Future<_i8.PackageKitTransaction>.value( + _FakePackageKitTransaction_15( this, Invocation.method( #createTransaction, [], ), )), - ) as _i13.Future<_i7.PackageKitTransaction>); + ) as _i10.Future<_i8.PackageKitTransaction>); @override - _i13.Future close() => (super.noSuchMethod( + _i10.Future close() => (super.noSuchMethod( Invocation.method( #close, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); } /// A class which mocks [PackageKitTransaction]. /// /// See the documentation for Mockito's code generation for more information. class MockPackageKitTransaction extends _i1.Mock - implements _i7.PackageKitTransaction { + implements _i8.PackageKitTransaction { MockPackageKitTransaction() { _i1.throwOnMissingStub(this); } @override - _i13.Stream<_i17.PackageKitEvent> get events => (super.noSuchMethod( + _i10.Stream<_i16.PackageKitEvent> get events => (super.noSuchMethod( Invocation.getter(#events), - returnValue: _i13.Stream<_i17.PackageKitEvent>.empty(), - ) as _i13.Stream<_i17.PackageKitEvent>); + returnValue: _i10.Stream<_i16.PackageKitEvent>.empty(), + ) as _i10.Stream<_i16.PackageKitEvent>); @override - set events(_i13.Stream<_i17.PackageKitEvent>? _events) => super.noSuchMethod( + set events(_i10.Stream<_i16.PackageKitEvent>? _events) => super.noSuchMethod( Invocation.setter( #events, _events, @@ -1728,21 +1670,21 @@ class MockPackageKitTransaction extends _i1.Mock ); @override - _i17.PackageKitRole get role => (super.noSuchMethod( + _i16.PackageKitRole get role => (super.noSuchMethod( Invocation.getter(#role), - returnValue: _i17.PackageKitRole.unknown, - ) as _i17.PackageKitRole); + returnValue: _i16.PackageKitRole.unknown, + ) as _i16.PackageKitRole); @override - _i17.PackageKitStatus get status => (super.noSuchMethod( + _i16.PackageKitStatus get status => (super.noSuchMethod( Invocation.getter(#status), - returnValue: _i17.PackageKitStatus.unknown, - ) as _i17.PackageKitStatus); + returnValue: _i16.PackageKitStatus.unknown, + ) as _i16.PackageKitStatus); @override String get lastPackage => (super.noSuchMethod( Invocation.getter(#lastPackage), - returnValue: _i16.dummyValue( + returnValue: _i14.dummyValue( this, Invocation.getter(#lastPackage), ), @@ -1797,32 +1739,32 @@ class MockPackageKitTransaction extends _i1.Mock ) as int); @override - Set<_i17.PackageKitTransactionFlag> get transactionFlags => + Set<_i16.PackageKitTransactionFlag> get transactionFlags => (super.noSuchMethod( Invocation.getter(#transactionFlags), - returnValue: <_i17.PackageKitTransactionFlag>{}, - ) as Set<_i17.PackageKitTransactionFlag>); + returnValue: <_i16.PackageKitTransactionFlag>{}, + ) as Set<_i16.PackageKitTransactionFlag>); @override - _i13.Stream> get propertiesChanged => (super.noSuchMethod( + _i10.Stream> get propertiesChanged => (super.noSuchMethod( Invocation.getter(#propertiesChanged), - returnValue: _i13.Stream>.empty(), - ) as _i13.Stream>); + returnValue: _i10.Stream>.empty(), + ) as _i10.Stream>); @override - _i13.Future cancel() => (super.noSuchMethod( + _i10.Future cancel() => (super.noSuchMethod( Invocation.method( #cancel, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future dependsOn( - Iterable<_i17.PackageKitPackageId>? packageIds, { - Set<_i17.PackageKitFilter>? filter = const {}, + _i10.Future dependsOn( + Iterable<_i16.PackageKitPackageId>? packageIds, { + Set<_i16.PackageKitFilter>? filter = const {}, bool? recursive = false, }) => (super.noSuchMethod( @@ -1834,36 +1776,36 @@ class MockPackageKitTransaction extends _i1.Mock #recursive: recursive, }, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getDetails( - Iterable<_i17.PackageKitPackageId>? packageIds) => + _i10.Future getDetails( + Iterable<_i16.PackageKitPackageId>? packageIds) => (super.noSuchMethod( Invocation.method( #getDetails, [packageIds], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getDetailsLocal(Iterable? paths) => + _i10.Future getDetailsLocal(Iterable? paths) => (super.noSuchMethod( Invocation.method( #getDetailsLocal, [paths], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future downloadPackages( - Iterable<_i17.PackageKitPackageId>? packageIds, { + _i10.Future downloadPackages( + Iterable<_i16.PackageKitPackageId>? packageIds, { bool? storeInCache = false, }) => (super.noSuchMethod( @@ -1872,60 +1814,60 @@ class MockPackageKitTransaction extends _i1.Mock [packageIds], {#storeInCache: storeInCache}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getFiles(Iterable<_i17.PackageKitPackageId>? packageIds) => + _i10.Future getFiles(Iterable<_i16.PackageKitPackageId>? packageIds) => (super.noSuchMethod( Invocation.method( #getFiles, [packageIds], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getFilesLocal(Iterable? paths) => + _i10.Future getFilesLocal(Iterable? paths) => (super.noSuchMethod( Invocation.method( #getFilesLocal, [paths], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getPackages( - {Set<_i17.PackageKitFilter>? filter = const {}}) => + _i10.Future getPackages( + {Set<_i16.PackageKitFilter>? filter = const {}}) => (super.noSuchMethod( Invocation.method( #getPackages, [], {#filter: filter}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getRepositoryList( - {Set<_i17.PackageKitFilter>? filter = const {}}) => + _i10.Future getRepositoryList( + {Set<_i16.PackageKitFilter>? filter = const {}}) => (super.noSuchMethod( Invocation.method( #getRepositoryList, [], {#filter: filter}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future setRepositoryEnabled( + _i10.Future setRepositoryEnabled( String? id, bool? enabled, ) => @@ -1937,12 +1879,12 @@ class MockPackageKitTransaction extends _i1.Mock enabled, ], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future setRepositoryData( + _i10.Future setRepositoryData( String? id, String? parameter, String? value, @@ -1956,12 +1898,12 @@ class MockPackageKitTransaction extends _i1.Mock value, ], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future removeRepository( + _i10.Future removeRepository( String? id, { bool? autoremovePackages = false, }) => @@ -1971,39 +1913,39 @@ class MockPackageKitTransaction extends _i1.Mock [id], {#autoremovePackages: autoremovePackages}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getUpdateDetail( - Iterable<_i17.PackageKitPackageId>? packageIds) => + _i10.Future getUpdateDetail( + Iterable<_i16.PackageKitPackageId>? packageIds) => (super.noSuchMethod( Invocation.method( #getUpdateDetail, [packageIds], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future getUpdates( - {Set<_i17.PackageKitFilter>? filter = const {}}) => + _i10.Future getUpdates( + {Set<_i16.PackageKitFilter>? filter = const {}}) => (super.noSuchMethod( Invocation.method( #getUpdates, [], {#filter: filter}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future installFiles( + _i10.Future installFiles( Iterable? paths, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2011,14 +1953,14 @@ class MockPackageKitTransaction extends _i1.Mock [paths], {#transactionFlags: transactionFlags}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future installPackages( - Iterable<_i17.PackageKitPackageId>? packageIds, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + _i10.Future installPackages( + Iterable<_i16.PackageKitPackageId>? packageIds, { + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2026,25 +1968,25 @@ class MockPackageKitTransaction extends _i1.Mock [packageIds], {#transactionFlags: transactionFlags}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future refreshCache({bool? force = false}) => (super.noSuchMethod( + _i10.Future refreshCache({bool? force = false}) => (super.noSuchMethod( Invocation.method( #refreshCache, [], {#force: force}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future removePackages( - Iterable<_i17.PackageKitPackageId>? packageIds, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + _i10.Future removePackages( + Iterable<_i16.PackageKitPackageId>? packageIds, { + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, bool? allowDeps = false, bool? autoremove = false, }) => @@ -2058,14 +2000,14 @@ class MockPackageKitTransaction extends _i1.Mock #autoremove: autoremove, }, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future resolve( + _i10.Future resolve( Iterable? packages, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2073,14 +2015,14 @@ class MockPackageKitTransaction extends _i1.Mock [packages], {#transactionFlags: transactionFlags}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future searchFiles( + _i10.Future searchFiles( Iterable? values, { - Set<_i17.PackageKitFilter>? filter = const {}, + Set<_i16.PackageKitFilter>? filter = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2088,14 +2030,14 @@ class MockPackageKitTransaction extends _i1.Mock [values], {#filter: filter}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future searchNames( + _i10.Future searchNames( Iterable? values, { - Set<_i17.PackageKitFilter>? filter = const {}, + Set<_i16.PackageKitFilter>? filter = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2103,14 +2045,14 @@ class MockPackageKitTransaction extends _i1.Mock [values], {#filter: filter}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future updatePackages( - Iterable<_i17.PackageKitPackageId>? packageIds, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + _i10.Future updatePackages( + Iterable<_i16.PackageKitPackageId>? packageIds, { + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2118,15 +2060,15 @@ class MockPackageKitTransaction extends _i1.Mock [packageIds], {#transactionFlags: transactionFlags}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future upgradeSystem( + _i10.Future upgradeSystem( String? distroId, - _i17.PackageKitDistroUpgrade? upgradeKind, { - Set<_i17.PackageKitTransactionFlag>? transactionFlags = const {}, + _i16.PackageKitDistroUpgrade? upgradeKind, { + Set<_i16.PackageKitTransactionFlag>? transactionFlags = const {}, }) => (super.noSuchMethod( Invocation.method( @@ -2137,114 +2079,114 @@ class MockPackageKitTransaction extends _i1.Mock ], {#transactionFlags: transactionFlags}, ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); } /// A class which mocks [RatingsService]. /// /// See the documentation for Mockito's code generation for more information. -class MockRatingsService extends _i1.Mock implements _i21.RatingsService { +class MockRatingsService extends _i1.Mock implements _i20.RatingsService { MockRatingsService() { _i1.throwOnMissingStub(this); } @override - _i11.RatingsClient get client => (super.noSuchMethod( + _i4.RatingsClient get client => (super.noSuchMethod( Invocation.getter(#client), - returnValue: _FakeRatingsClient_15( + returnValue: _FakeRatingsClient_16( this, Invocation.getter(#client), ), - ) as _i11.RatingsClient); + ) as _i4.RatingsClient); @override - _i13.Future<_i11.Rating?> getRating(String? snapId) => (super.noSuchMethod( + _i10.Future<_i4.Rating?> getRating(String? snapId) => (super.noSuchMethod( Invocation.method( #getRating, [snapId], ), - returnValue: _i13.Future<_i11.Rating?>.value(), - ) as _i13.Future<_i11.Rating?>); + returnValue: _i10.Future<_i4.Rating?>.value(), + ) as _i10.Future<_i4.Rating?>); @override - _i13.Future vote(_i11.Vote? vote) => (super.noSuchMethod( + _i10.Future vote(_i4.Vote? vote) => (super.noSuchMethod( Invocation.method( #vote, [vote], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future delete() => (super.noSuchMethod( + _i10.Future delete() => (super.noSuchMethod( Invocation.method( #delete, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future> listMyVotes(String? snapFilter) => + _i10.Future> listMyVotes(String? snapFilter) => (super.noSuchMethod( Invocation.method( #listMyVotes, [snapFilter], ), - returnValue: _i13.Future>.value(<_i11.Vote>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i4.Vote>[]), + ) as _i10.Future>); @override - _i13.Future> getSnapVotes(String? snapId) => + _i10.Future> getSnapVotes(String? snapId) => (super.noSuchMethod( Invocation.method( #getSnapVotes, [snapId], ), - returnValue: _i13.Future>.value(<_i11.Vote>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i4.Vote>[]), + ) as _i10.Future>); } /// A class which mocks [RatingsClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { +class MockRatingsClient extends _i1.Mock implements _i4.RatingsClient { MockRatingsClient() { _i1.throwOnMissingStub(this); } @override - _i13.Future authenticate(String? id) => (super.noSuchMethod( + _i10.Future authenticate(String? id) => (super.noSuchMethod( Invocation.method( #authenticate, [id], ), - returnValue: _i13.Future.value(_i16.dummyValue( + returnValue: _i10.Future.value(_i14.dummyValue( this, Invocation.method( #authenticate, [id], ), )), - ) as _i13.Future); + ) as _i10.Future); @override - _i13.Future delete(String? token) => (super.noSuchMethod( + _i10.Future delete(String? token) => (super.noSuchMethod( Invocation.method( #delete, [token], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future> getChart( - _i22.Timeframe? timeframe, + _i10.Future> getChart( + _i21.Timeframe? timeframe, String? token, ) => (super.noSuchMethod( @@ -2256,11 +2198,11 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { ], ), returnValue: - _i13.Future>.value(<_i22.ChartData>[]), - ) as _i13.Future>); + _i10.Future>.value(<_i21.ChartData>[]), + ) as _i10.Future>); @override - _i13.Future<_i11.Rating> getRating( + _i10.Future<_i4.Rating> getRating( String? snapId, String? token, ) => @@ -2272,7 +2214,7 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { token, ], ), - returnValue: _i13.Future<_i11.Rating>.value(_FakeRating_16( + returnValue: _i10.Future<_i4.Rating>.value(_FakeRating_17( this, Invocation.method( #getRating, @@ -2282,10 +2224,10 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { ], ), )), - ) as _i13.Future<_i11.Rating>); + ) as _i10.Future<_i4.Rating>); @override - _i13.Future> getSnapVotes( + _i10.Future> getSnapVotes( String? snapId, String? token, ) => @@ -2297,11 +2239,11 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { token, ], ), - returnValue: _i13.Future>.value(<_i11.Vote>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i4.Vote>[]), + ) as _i10.Future>); @override - _i13.Future> listMyVotes( + _i10.Future> listMyVotes( String? snapIdFilter, String? token, ) => @@ -2313,11 +2255,11 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { token, ], ), - returnValue: _i13.Future>.value(<_i11.Vote>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value(<_i4.Vote>[]), + ) as _i10.Future>); @override - _i13.Future vote( + _i10.Future vote( String? snapId, int? snapRevision, bool? voteUp, @@ -2333,15 +2275,15 @@ class MockRatingsClient extends _i1.Mock implements _i11.RatingsClient { token, ], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); } /// A class which mocks [AppstreamService]. /// /// See the documentation for Mockito's code generation for more information. -class MockAppstreamService extends _i1.Mock implements _i6.AppstreamService { +class MockAppstreamService extends _i1.Mock implements _i7.AppstreamService { MockAppstreamService() { _i1.throwOnMissingStub(this); } @@ -2359,46 +2301,46 @@ class MockAppstreamService extends _i1.Mock implements _i6.AppstreamService { ) as int); @override - _i13.Future init() => (super.noSuchMethod( + _i10.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future> search(String? search) => + _i10.Future> search(String? search) => (super.noSuchMethod( Invocation.method( #search, [search], ), - returnValue: _i13.Future>.value( - <_i8.AppstreamComponent>[]), - ) as _i13.Future>); + returnValue: _i10.Future>.value( + <_i9.AppstreamComponent>[]), + ) as _i10.Future>); @override - _i8.AppstreamComponent getFromId(String? id) => (super.noSuchMethod( + _i9.AppstreamComponent getFromId(String? id) => (super.noSuchMethod( Invocation.method( #getFromId, [id], ), - returnValue: _FakeAppstreamComponent_6( + returnValue: _FakeAppstreamComponent_8( this, Invocation.method( #getFromId, [id], ), ), - ) as _i8.AppstreamComponent); + ) as _i9.AppstreamComponent); } /// A class which mocks [PackageKitService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPackageKitService extends _i1.Mock implements _i7.PackageKitService { +class MockPackageKitService extends _i1.Mock implements _i8.PackageKitService { MockPackageKitService() { _i1.throwOnMissingStub(this); } @@ -2410,80 +2352,80 @@ class MockPackageKitService extends _i1.Mock implements _i7.PackageKitService { ) as bool); @override - _i13.Stream<_i17.PackageKitErrorCodeEvent> get errorStream => + _i10.Stream<_i16.PackageKitErrorCodeEvent> get errorStream => (super.noSuchMethod( Invocation.getter(#errorStream), - returnValue: _i13.Stream<_i17.PackageKitErrorCodeEvent>.empty(), - ) as _i13.Stream<_i17.PackageKitErrorCodeEvent>); + returnValue: _i10.Stream<_i16.PackageKitErrorCodeEvent>.empty(), + ) as _i10.Stream<_i16.PackageKitErrorCodeEvent>); @override - _i7.PackageKitTransaction? getTransaction(int? id) => + _i8.PackageKitTransaction? getTransaction(int? id) => (super.noSuchMethod(Invocation.method( #getTransaction, [id], - )) as _i7.PackageKitTransaction?); + )) as _i8.PackageKitTransaction?); @override - _i13.Future activateService() => (super.noSuchMethod( + _i10.Future activateService() => (super.noSuchMethod( Invocation.method( #activateService, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future waitTransaction(int? id) => (super.noSuchMethod( + _i10.Future waitTransaction(int? id) => (super.noSuchMethod( Invocation.method( #waitTransaction, [id], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future cancelTransaction(int? id) => (super.noSuchMethod( + _i10.Future cancelTransaction(int? id) => (super.noSuchMethod( Invocation.method( #cancelTransaction, [id], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); @override - _i13.Future install(_i17.PackageKitPackageId? packageId) => + _i10.Future install(_i16.PackageKitPackageId? packageId) => (super.noSuchMethod( Invocation.method( #install, [packageId], ), - returnValue: _i13.Future.value(0), - ) as _i13.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i13.Future installLocal(String? path) => (super.noSuchMethod( + _i10.Future installLocal(String? path) => (super.noSuchMethod( Invocation.method( #installLocal, [path], ), - returnValue: _i13.Future.value(0), - ) as _i13.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i13.Future remove(_i17.PackageKitPackageId? packageId) => + _i10.Future remove(_i16.PackageKitPackageId? packageId) => (super.noSuchMethod( Invocation.method( #remove, [packageId], ), - returnValue: _i13.Future.value(0), - ) as _i13.Future); + returnValue: _i10.Future.value(0), + ) as _i10.Future); @override - _i13.Future<_i17.PackageKitPackageEvent?> resolve( + _i10.Future<_i16.PackageKitPackageEvent?> resolve( String? name, [ String? architecture, ]) => @@ -2495,74 +2437,26 @@ class MockPackageKitService extends _i1.Mock implements _i7.PackageKitService { architecture, ], ), - returnValue: _i13.Future<_i17.PackageKitPackageEvent?>.value(), - ) as _i13.Future<_i17.PackageKitPackageEvent?>); + returnValue: _i10.Future<_i16.PackageKitPackageEvent?>.value(), + ) as _i10.Future<_i16.PackageKitPackageEvent?>); @override - _i13.Future<_i17.PackageKitDetailsEvent?> getDetailsLocal(String? path) => + _i10.Future<_i16.PackageKitDetailsEvent?> getDetailsLocal(String? path) => (super.noSuchMethod( Invocation.method( #getDetailsLocal, [path], ), - returnValue: _i13.Future<_i17.PackageKitDetailsEvent?>.value(), - ) as _i13.Future<_i17.PackageKitDetailsEvent?>); + returnValue: _i10.Future<_i16.PackageKitDetailsEvent?>.value(), + ) as _i10.Future<_i16.PackageKitDetailsEvent?>); @override - _i13.Future dispose() => (super.noSuchMethod( + _i10.Future dispose() => (super.noSuchMethod( Invocation.method( #dispose, [], ), - returnValue: _i13.Future.value(), - returnValueForMissingStub: _i13.Future.value(), - ) as _i13.Future); -} - -/// A class which mocks [Vote]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockVote extends _i1.Mock implements _i11.Vote { - MockVote() { - _i1.throwOnMissingStub(this); - } - - @override - String get snapId => (super.noSuchMethod( - Invocation.getter(#snapId), - returnValue: _i16.dummyValue( - this, - Invocation.getter(#snapId), - ), - ) as String); - - @override - int get snapRevision => (super.noSuchMethod( - Invocation.getter(#snapRevision), - returnValue: 0, - ) as int); - - @override - bool get voteUp => (super.noSuchMethod( - Invocation.getter(#voteUp), - returnValue: false, - ) as bool); - - @override - DateTime get dateTime => (super.noSuchMethod( - Invocation.getter(#dateTime), - returnValue: _FakeDateTime_17( - this, - Invocation.getter(#dateTime), - ), - ) as DateTime); - - @override - _i11.$VoteCopyWith<_i11.Vote> get copyWith => (super.noSuchMethod( - Invocation.getter(#copyWith), - returnValue: _Fake$VoteCopyWith_18<_i11.Vote>( - this, - Invocation.getter(#copyWith), - ), - ) as _i11.$VoteCopyWith<_i11.Vote>); + returnValue: _i10.Future.value(), + returnValueForMissingStub: _i10.Future.value(), + ) as _i10.Future); } diff --git a/packages/app_center/test/updates_model_test.dart b/packages/app_center/test/updates_model_test.dart index 6b9a52657..c1cc810f1 100644 --- a/packages/app_center/test/updates_model_test.dart +++ b/packages/app_center/test/updates_model_test.dart @@ -1,3 +1,4 @@ +import 'package:app_center/providers/error_stream_provider.dart'; import 'package:app_center/snapd/snapd.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; @@ -8,18 +9,19 @@ import 'test_utils.dart'; void main() { group('refresh', () { test('no updates available', () async { - final service = registerMockSnapdService(); - final model = UpdatesModel(service); - await model.refresh(); - expect(model.refreshableSnapNames, isEmpty); + registerMockSnapdService(); + final container = createContainer(); + final model = await container.read(updatesModelProvider.future); + expect(model, isEmpty); }); + test('updates available', () async { - final service = registerMockSnapdService( + registerMockSnapdService( refreshableSnaps: [createSnap(name: 'firefox')], ); - final model = UpdatesModel(service); - await model.refresh(); - expect(model.refreshableSnapNames.single, equals('firefox')); + final container = createContainer(); + final model = await container.read(updatesModelProvider.future); + expect(model.single.name, equals('firefox')); }); }); @@ -27,16 +29,17 @@ void main() { final service = registerMockSnapdService( refreshableSnaps: [createSnap(name: 'firefox')], ); - final model = UpdatesModel(service); - await model.refresh(); - await model.updateAll(); + final container = createContainer(); + await container.read(updatesModelProvider.future); + await container.read(updatesModelProvider.notifier).updateAll(); verify(service.refreshMany(const [])).called(1); }); group('error stream', () { test('refresh', () async { + registerMockErrorStreamControllerService(); final service = registerMockSnapdService(); - final model = UpdatesModel(service); + final container = createContainer(); when(service.find(filter: SnapFindFilter.refresh)).thenThrow( SnapdException( message: 'error while checking for updates', @@ -44,38 +47,46 @@ void main() { ), ); - model.errorStream.listen( - expectAsync1( - (e) { - expect(e.kind, equals('error kind')); - expect(e.message, equals('error while checking for updates')); - }, - ), + container.listen( + errorStreamProvider, + (_, __) { + expectAsync1( + (e) { + expect(e.kind, equals('error kind')); + expect(e.message, equals('error while checking for updates')); + }, + ); + }, ); - await model.refresh(); + await container.read(updatesModelProvider.future); }); + test('update all', () async { + registerMockErrorStreamControllerService(); final service = registerMockSnapdService( refreshableSnaps: [createSnap(id: '', name: 'firefox')], ); - final model = UpdatesModel(service); + final container = createContainer(); when(service.refreshMany(any)).thenThrow( SnapdException( message: 'error while updating snaps', kind: 'error kind', ), ); + await container.read(updatesModelProvider.future); - model.errorStream.listen( - expectAsync1( - (e) { - expect(e.kind, equals('error kind')); - expect(e.message, equals('error while updating snaps')); - }, - ), + container.listen( + errorStreamProvider, + (_, __) { + expectAsync1( + (e) { + expect(e.kind, equals('error kind')); + expect(e.message, equals('error while updating snaps')); + }, + ); + }, ); - await model.refresh(); - await model.updateAll(); + await container.read(updatesModelProvider.notifier).updateAll(); }); }); }