diff --git a/test/application/splash/splash_bloc_test.dart b/test/application/splash/splash_bloc_test.dart index 56145aa22..0434242f0 100644 --- a/test/application/splash/splash_bloc_test.dart +++ b/test/application/splash/splash_bloc_test.dart @@ -45,8 +45,15 @@ void main() { int resourceVersion = defaultResourcesVersion, String? jsonFileName, List keyNames = const [], - }) => - CheckForUpdatesResult(resourceVersion: resourceVersion, type: type, jsonFileKeyName: jsonFileName, keyNames: keyNames); + }) { + return CheckForUpdatesResult( + resourceVersion: resourceVersion, + type: type, + jsonFileKeyName: jsonFileName, + keyNames: keyNames, + downloadTotalSize: 100, + ); + } test('Initial state', () => expect(getBloc(MockResourceService()).state, const SplashState.loading())); @@ -409,14 +416,15 @@ void main() { ), build: () => getBloc(MockResourceService()), act: (bloc) => bloc - ..add(const SplashEvent.progressChanged(progress: 10)) - ..add(const SplashEvent.progressChanged(progress: 50)) - ..add(const SplashEvent.progressChanged(progress: 100)), + ..add(const SplashEvent.progressChanged(progress: 10, downloadedBytes: 10)) + ..add(const SplashEvent.progressChanged(progress: 50, downloadedBytes: 50)) + ..add(const SplashEvent.progressChanged(progress: 100, downloadedBytes: 100)), expect: () => [ SplashState.loaded( updateResultType: AppResourceUpdateResultType.updatesAvailable, language: language, progress: 10, + downloadedBytes: 10, result: getUpdateResult(AppResourceUpdateResultType.updatesAvailable), noResourcesHasBeenDownloaded: false, isLoading: false, @@ -430,6 +438,7 @@ void main() { updateResultType: AppResourceUpdateResultType.updatesAvailable, language: language, progress: 50, + downloadedBytes: 50, result: getUpdateResult(AppResourceUpdateResultType.updatesAvailable), noResourcesHasBeenDownloaded: false, isLoading: false, @@ -443,6 +452,7 @@ void main() { updateResultType: AppResourceUpdateResultType.updatesAvailable, language: language, progress: 100, + downloadedBytes: 100, result: getUpdateResult(AppResourceUpdateResultType.updatesAvailable), noResourcesHasBeenDownloaded: false, isLoading: false, @@ -471,13 +481,14 @@ void main() { ), build: () => getBloc(MockResourceService()), act: (bloc) => bloc - ..add(const SplashEvent.progressChanged(progress: 100)) - ..add(const SplashEvent.progressChanged(progress: 110)), + ..add(const SplashEvent.progressChanged(progress: 100, downloadedBytes: 100)) + ..add(const SplashEvent.progressChanged(progress: 110, downloadedBytes: 110)), expect: () => [ SplashState.loaded( updateResultType: AppResourceUpdateResultType.updatesAvailable, language: language, progress: 100, + downloadedBytes: 100, result: getUpdateResult(AppResourceUpdateResultType.updatesAvailable), noResourcesHasBeenDownloaded: false, isLoading: false, @@ -506,13 +517,14 @@ void main() { ), build: () => getBloc(MockResourceService()), act: (bloc) => bloc - ..add(const SplashEvent.progressChanged(progress: 10)) - ..add(const SplashEvent.progressChanged(progress: 10.1)), + ..add(const SplashEvent.progressChanged(progress: 10, downloadedBytes: 10)) + ..add(const SplashEvent.progressChanged(progress: 10.1, downloadedBytes: 10)), expect: () => [ SplashState.loaded( updateResultType: AppResourceUpdateResultType.updatesAvailable, language: language, progress: 10, + downloadedBytes: 10, result: getUpdateResult(AppResourceUpdateResultType.updatesAvailable), noResourcesHasBeenDownloaded: false, isLoading: false, @@ -540,7 +552,7 @@ void main() { needsLatestAppVersionOnFirstInstall: false, ), build: () => getBloc(MockResourceService()), - act: (bloc) => bloc.add(const SplashEvent.progressChanged(progress: -1)), + act: (bloc) => bloc.add(const SplashEvent.progressChanged(progress: -1, downloadedBytes: 0)), errors: () => [isA()], ); }); diff --git a/test/infrastructure/resource_service_test.dart b/test/infrastructure/resource_service_test.dart index 6b5819d0d..6b6541471 100644 --- a/test/infrastructure/resource_service_test.dart +++ b/test/infrastructure/resource_service_test.dart @@ -447,7 +447,7 @@ void main() { final networkService = MockNetworkService(); when(networkService.isInternetAvailable()).thenAnswer((_) => Future.value(true)); final apiService = MockApiService(); - when(apiService.downloadAsset(allJson, path.join(tempDir.path, allJson))).thenAnswer((_) => Future.value(false)); + when(apiService.downloadAsset(allJson, path.join(tempDir.path, allJson))).thenAnswer((_) => Future.value()); final service = ResourceServiceImpl( MockLoggingService(), @@ -479,9 +479,9 @@ void main() { 'characters/ganyu$imageFileExtension', ]; - when(apiService.downloadAsset(keyNames[0], path.join(tempDir.path, keyNames[0]))).thenAnswer((_) => Future.value(true)); - when(apiService.downloadAsset(keyNames[1], path.join(tempDir.path, keyNames[1]))).thenAnswer((_) => Future.value(true)); - when(apiService.downloadAsset(keyNames[2], path.join(tempDir.path, keyNames[2]))).thenAnswer((_) => Future.value(false)); + when(apiService.downloadAsset(keyNames[0], path.join(tempDir.path, keyNames[0]))).thenAnswer((_) => Future.value(1)); + when(apiService.downloadAsset(keyNames[1], path.join(tempDir.path, keyNames[1]))).thenAnswer((_) => Future.value(2)); + when(apiService.downloadAsset(keyNames[2], path.join(tempDir.path, keyNames[2]))).thenAnswer((_) => Future.value()); await File(path.join(path.join(tempDir.path, 'keqing$imageFileExtension'))).create(); await File(path.join(path.join(tempDir.path, 'kamisato_ayaka$imageFileExtension'))).create();