π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Prune mosaic test coverage
ashil-pilot1914402f770f
diff --git a/mobile/apps/photos/test/models/ente_file_dimensions_test.dart b/mobile/apps/photos/test/models/ente_file_dimensions_test.dartdeleted file mode 100644index 41d8cbda1e..0000000000--- a/mobile/apps/photos/test/models/ente_file_dimensions_test.dart+++ /dev/null@@ -1,35 +0,0 @@-import "package:flutter_test/flutter_test.dart";-import "package:photos/models/file/file.dart";-import "package:photos/models/metadata/file_magic.dart";--void main() {- test("dimensions are decoded directly from public metadata", () {- final file = EnteFile()- ..pubMmdEncodedJson = '{"caption":"hello","w":4032,"h":"3024"}';-- expect(file.width, 4032);- expect(file.height, 3024);- expect(file.pubMmdEncodedJson, contains('"caption":"hello"'));- });-- test("dimension cache is invalidated when encoded metadata changes", () {- final file = EnteFile()..pubMmdEncodedJson = '{"w":10,"h":20}';- expect((file.width, file.height), (10, 20));-- file.pubMmdEncodedJson = '{"w":30,"h":40}';- expect((file.width, file.height), (30, 40));- });-- test("decoded public metadata supplies and updates dimensions", () {- final file = EnteFile()..pubMagicMetadata = PubMagicMetadata(w: 50, h: 60);- expect((file.width, file.height), (50, 60));-- file.pubMagicMetadata = PubMagicMetadata(w: 70, h: 80);- expect((file.width, file.height), (70, 80));- });-- test("missing dimensions use zero", () {- final file = EnteFile()..pubMmdEncodedJson = '{"caption":"hello"}';- expect((file.width, file.height), (0, 0));- });-}diff --git a/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart b/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dartindex 1f5502a284..8b8171c640 100644--- a/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart+++ b/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart@@ -216,55 +216,6 @@ void main() {expect(groups.layoutType, GalleryLayoutType.grid);expect(groups.groupLayouts, everyElement(isA<FixedExtentSectionLayout>()));});-- test("mosaic falls back to grid when the rollout is unavailable", () {- final files = List<EnteFile>.generate(- 12,- (index) => _file(- index: index,- creationTime: DateTime(2026, 8, 19).microsecondsSinceEpoch,- width: index.isEven ? 100 : 400,- height: index.isEven ? 400 : 100,- ),- growable: false,- );-- final publicGroups = _galleryGroups(- files: files,- groupType: GroupType.none,- groupHeaderExtent: GalleryGroups.spacing,- mosaicLayoutAvailable: false,- );- final publicOverrideGroups = _galleryGroups(- files: files,- groupType: GroupType.none,- groupHeaderExtent: GalleryGroups.spacing,- layoutTypeOverride: GalleryLayoutType.mosaic,- mosaicLayoutAvailable: false,- );- final internalGroups = _galleryGroups(- files: files,- groupType: GroupType.none,- groupHeaderExtent: GalleryGroups.spacing,- );-- expect(- localSettings.getGalleryLayoutType(),- GalleryLayoutType.mosaic,- reason: "the raw preference should be preserved across rollout changes",- );- expect(publicGroups.layoutType, GalleryLayoutType.grid);- expect(- publicGroups.groupLayouts,- everyElement(isA<FixedExtentSectionLayout>()),- );- expect(publicOverrideGroups.layoutType, GalleryLayoutType.grid);- expect(internalGroups.layoutType, GalleryLayoutType.mosaic);- expect(- internalGroups.groupLayouts,- everyElement(isA<MosaicSectionLayout>()),- );- });}GalleryGroups _galleryGroups({@@ -273,7 +224,6 @@ GalleryGroups _galleryGroups({required double groupHeaderExtent,bool sortOrderAsc = false,GalleryLayoutType? layoutTypeOverride,- bool mosaicLayoutAvailable = true,}) {return GalleryGroups(allFiles: files,@@ -285,7 +235,7 @@ GalleryGroups _galleryGroups({groupHeaderExtent: groupHeaderExtent,showSelectAll: false,layoutTypeOverride: layoutTypeOverride,- mosaicLayoutAvailable: mosaicLayoutAvailable,+ mosaicLayoutAvailable: true,);}diff --git a/mobile/apps/photos/test/models/mosaic_grid_row_test.dart b/mobile/apps/photos/test/models/mosaic_grid_row_test.dartindex 319d1a3973..75af24320a 100644--- a/mobile/apps/photos/test/models/mosaic_grid_row_test.dart+++ b/mobile/apps/photos/test/models/mosaic_grid_row_test.dart@@ -53,44 +53,4 @@ void main() {);},);-- testWidgets("MosaicGridRow mirrors child offsets in RTL", (tester) async {- const rowKey = ValueKey("rtl-row");- const firstKey = ValueKey("rtl-first");- const secondKey = ValueKey("rtl-second");-- await tester.pumpWidget(- const MaterialApp(- home: Scaffold(- body: Align(- alignment: Alignment.topLeft,- child: SizedBox(- width: 200,- child: MosaicGridRow(- key: rowKey,- itemWidths: [60, 100],- height: 50,- spacing: 4,- textDirection: TextDirection.rtl,- children: [- ColoredBox(key: firstKey, color: Colors.red),- ColoredBox(key: secondKey, color: Colors.green),- ],- ),- ),- ),- ),- ),- );-- final rowOrigin = tester.getTopLeft(find.byKey(rowKey));- expect(- tester.getTopLeft(find.byKey(firstKey)),- rowOrigin + const Offset(140, 0),- );- expect(- tester.getTopLeft(find.byKey(secondKey)),- rowOrigin + const Offset(36, 0),- );- });}diff --git a/mobile/apps/photos/test/models/mosaic_layout_test.dart b/mobile/apps/photos/test/models/mosaic_layout_test.dartindex 92f4c4ed97..46db7b65bd 100644--- a/mobile/apps/photos/test/models/mosaic_layout_test.dart+++ b/mobile/apps/photos/test/models/mosaic_layout_test.dart@@ -18,34 +18,6 @@ void main() {expect(MosaicLayoutCalculator.aspectRatioForDimensions(100, 1), 4);});- test("normalizes invalid and extreme input ratios", () {- final rows = MosaicLayoutCalculator.computeRows(- aspectRatios: [- double.nan,- double.infinity,- double.negativeInfinity,- -1,- 0,- 1e-9,- 1e9,- ],- availableWidth: 400,- targetRowHeight: 100,- spacing: 2,- );-- expect(rows.first.firstIndex, 0);- expect(rows.last.lastIndex, 6);- for (final row in rows) {- expect(row.height.isFinite, isTrue);- expect(row.height, greaterThan(0));- for (final width in row.itemWidths) {- expect(width.isFinite, isTrue);- expect(width, greaterThan(0));- }- }- });-test("justified rows conserve the full available width", () {const availableWidth = 400.0;const spacing = 2.0;@@ -187,48 +159,6 @@ void main() {expect(rows.single.height, 48);expect(rows.single.itemWidths, [192]);});-- test("lays out 100k ratios quickly and deterministically", () {- final ratios = List<double>.generate(100000, (index) {- return switch (index % 8) {- 0 => 0.25,- 1 => 0.5,- 2 => 0.75,- 3 => 1,- 4 => 4 / 3,- 5 => 1.5,- 6 => 2,- _ => 4,- };- }, growable: false);-- final stopwatch = Stopwatch()..start();- final first = MosaicLayoutCalculator.computeRows(- aspectRatios: ratios,- availableWidth: 430,- targetRowHeight: 105,- spacing: 2,- );- stopwatch.stop();-- expect(stopwatch.elapsed, lessThan(const Duration(seconds: 5)));- expect(first, isNotEmpty);- expect(first.first.firstIndex, 0);- expect(first.last.lastIndex, ratios.length - 1);- _expectValidRows(first, itemCount: ratios.length, spacing: 2);- for (final row in first) {- expect(row.height, greaterThanOrEqualTo(48 - 1e-9));- expect(row.itemWidths, everyElement(greaterThanOrEqualTo(48 - 1e-9)));- }-- final second = MosaicLayoutCalculator.computeRows(- aspectRatios: ratios,- availableWidth: 430,- targetRowHeight: 105,- spacing: 2,- );- _expectSameRows(first, second);- });});group("MosaicSectionLayout", () {@@ -300,39 +230,3 @@ void main() {);});}--void _expectValidRows(- List<MosaicRowLayout> rows, {- required int itemCount,- required double spacing,-}) {- var expectedFirstIndex = 0;- var expectedOffset = 0.0;- for (final row in rows) {- expect(row.firstIndex, expectedFirstIndex);- expect(row.lastIndex, greaterThanOrEqualTo(row.firstIndex));- expect(row.itemWidths, hasLength(row.lastIndex - row.firstIndex + 1));- expect(row.minOffset, closeTo(expectedOffset, 1e-9));- expect(row.height.isFinite, isTrue);- expect(row.height, greaterThan(0));- expectedFirstIndex = row.lastIndex + 1;- expectedOffset = row.maxOffset + spacing;- }- expect(expectedFirstIndex, itemCount);-}--void _expectSameRows(- List<MosaicRowLayout> first,- List<MosaicRowLayout> second,-) {- expect(second, hasLength(first.length));- for (var index = 0; index < first.length; index++) {- final firstRow = first[index];- final secondRow = second[index];- expect(secondRow.firstIndex, firstRow.firstIndex, reason: "row $index");- expect(secondRow.lastIndex, firstRow.lastIndex, reason: "row $index");- expect(secondRow.minOffset, firstRow.minOffset, reason: "row $index");- expect(secondRow.height, firstRow.height, reason: "row $index");- expect(secondRow.itemWidths, firstRow.itemWidths, reason: "row $index");- }-}diff --git a/mobile/apps/photos/test/services/flag_service_cache_test.dart b/mobile/apps/photos/test/services/flag_service_cache_test.dartdeleted file mode 100644index 3235f69452..0000000000--- a/mobile/apps/photos/test/services/flag_service_cache_test.dart+++ /dev/null@@ -1,94 +0,0 @@-import "dart:async";-import "dart:convert";--import "package:dio/dio.dart";-import "package:ente_feature_flag/ente_feature_flag.dart";-import "package:flutter_test/flutter_test.dart";-import "package:shared_preferences/shared_preferences.dart";--void main() {- TestWidgetsFlutterBinding.ensureInitialized();-- test("feature flags follow preference changes across accounts", () async {- SharedPreferences.setMockInitialValues({});- final preferences = await SharedPreferences.getInstance();- final service = FlagService(preferences, Dio(), autoRefresh: false);-- await preferences.setString(- "remote_flags",- jsonEncode({"customDomain": "first.example"}),- );- expect(service.flags.customDomain, "first.example");-- await preferences.setString(- "remote_flags",- jsonEncode({"customDomain": "second.example"}),- );- expect(service.flags.customDomain, "second.example");-- await preferences.remove("remote_flags");- expect(service.flags.customDomain, isEmpty);- });-- test("an account switch discards an in-flight flag response", () async {- SharedPreferences.setMockInitialValues({- "token": "account-a-token",- "user_id": 1,- });- final preferences = await SharedPreferences.getInstance();- final firstRequestStarted = Completer<void>();- final firstResponse = Completer<Map<String, dynamic>>();- var requestCount = 0;- final dio = Dio();- dio.interceptors.add(- InterceptorsWrapper(- onRequest: (options, handler) {- requestCount++;- if (requestCount == 1) {- firstRequestStarted.complete();- firstResponse.future.then((data) {- handler.resolve(- Response<dynamic>(- requestOptions: options,- data: data,- statusCode: 200,- ),- );- });- } else {- handler.resolve(- Response<dynamic>(- requestOptions: options,- data: {- "internalUser": false,- "customDomain": "account-b.example",- },- statusCode: 200,- ),- );- }- },- ),- );- final service = FlagService(preferences, dio, autoRefresh: false);-- final accountARefresh = service.tryRefreshFlags();- await firstRequestStarted.future;- expect(requestCount, 1);-- await preferences.clear();- await preferences.setString("token", "account-b-token");- await preferences.setInt("user_id", 2);- final accountBRefresh = service.tryRefreshFlags();-- firstResponse.complete({- "internalUser": true,- "customDomain": "account-a.example",- });- await Future.wait([accountARefresh, accountBRefresh]);-- expect(requestCount, 2);- expect(service.flags.internalUser, isFalse);- expect(service.flags.customDomain, "account-b.example");- });-}diff --git a/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart b/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dartindex 93b95b614d..e6148f2d37 100644--- a/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart+++ b/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart@@ -25,13 +25,4 @@ void main() {GalleryLayoutType.mosaic.name,);});-- test("unknown persisted gallery layout falls back to grid", () async {- SharedPreferences.setMockInitialValues({- LocalSettings.kGalleryLayoutType: "future-layout",- });- final settings = LocalSettings(await SharedPreferences.getInstance());-- expect(settings.getGalleryLayoutType(), GalleryLayoutType.grid);- });}diff --git a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_availability_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_availability_test.dartdeleted file mode 100644index 0a085d085a..0000000000--- a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_availability_test.dart+++ /dev/null@@ -1,133 +0,0 @@-import "package:dio/dio.dart";-import "package:ente_strings/ente_strings.dart";-import "package:ente_ui/models/settings_search_item.dart";-import "package:flutter/material.dart";-import "package:flutter_test/flutter_test.dart";-import "package:package_info_plus/package_info_plus.dart";-import "package:photos/core/configuration.dart";-import "package:photos/ente_theme_data.dart";-import "package:photos/models/gallery/gallery_layout_config.dart";-import "package:photos/service_locator.dart";-import "package:photos/settings/local_settings.dart";-import "package:photos/ui/settings/gallery_settings_screen.dart";-import "package:photos/ui/settings/search/settings_search_registry.dart";-import "package:photos/ui/viewer/gallery/layout_settings.dart";-import "package:shared_preferences/shared_preferences.dart";--void main() {- TestWidgetsFlutterBinding.ensureInitialized();-- setUpAll(() async {- SharedPreferences.setMockInitialValues({});- final preferences = await SharedPreferences.getInstance();- ServiceLocator.instance.init(- preferences,- Dio(),- Dio(),- Dio(),- PackageInfo(- appName: "Photos",- packageName: "photos",- version: "1.0.0",- buildNumber: "1",- ),- );- try {- await Configuration.instance.init(preferences);- } catch (_) {}-- // Construct the delayed flag refresher outside the widget-test fake clock.- expect(flagService.internalUser, isTrue);- });-- setUp(() async {- await localSettings.setInternalUserDisabled(false);- await localSettings.setGalleryLayoutType(GalleryLayoutType.mosaic);- });-- tearDown(() async {- await localSettings.setInternalUserDisabled(false);- await localSettings.setGalleryLayoutType(GalleryLayoutType.grid);- });-- testWidgets("public users cannot discover mosaic layout controls", (- tester,- ) async {- await localSettings.setInternalUserDisabled(true);- expect(isMosaicLayoutAvailable, isFalse);-- await tester.pumpWidget(- _testApp(const GallerySettingsScreen(fromGalleryLayoutSettingsCTA: true)),- );- await tester.pumpAndSettle();- var context = tester.element(find.byType(GallerySettingsScreen));- var l10n = context.strings;- expect(find.text(l10n.layout), findsNothing);- expect(find.text(l10n.layoutMasonry), findsNothing);-- await tester.pumpWidget(_testApp(const GalleryLayoutSettings()));- await tester.pumpAndSettle();- context = tester.element(find.byType(GalleryLayoutSettings));- l10n = context.strings;- expect(find.text(l10n.layoutMasonry), findsNothing);-- final searchItems = SettingsSearchRegistry.getSearchableItems(context);- expect(- searchItems.every(- (item) =>- item.matchType("mosaic") == SettingsSearchMatchType.none &&- item.matchType("masonry") == SettingsSearchMatchType.none,- ),- isTrue,- );- expect(searchItems.where((item) => item.title == l10n.layout), isEmpty);- expect(localSettings.getGalleryLayoutType(), GalleryLayoutType.mosaic);- });-- testWidgets("internal and debug users can discover mosaic layout controls", (- tester,- ) async {- expect(isMosaicLayoutAvailable, isTrue);-- await tester.pumpWidget(_testApp(const GalleryLayoutSettings()));- await tester.pumpAndSettle();- var context = tester.element(find.byType(GalleryLayoutSettings));- var l10n = context.strings;- expect(find.text(l10n.layoutMasonry), findsOneWidget);-- await localSettings.setGalleryLayoutType(GalleryLayoutType.grid);- await tester.pumpWidget(- _testApp(const GallerySettingsScreen(fromGalleryLayoutSettingsCTA: true)),- );- await tester.pumpAndSettle();- context = tester.element(find.byType(GallerySettingsScreen));- l10n = context.strings;- expect(find.text(l10n.layout), findsOneWidget);- await tester.tap(find.text(l10n.layout));- await tester.pumpAndSettle();- expect(find.text(l10n.layoutMasonry), findsOneWidget);- await tester.tap(find.byKey(const ValueKey(GalleryLayoutType.mosaic)));- await tester.pumpAndSettle();- expect(localSettings.getGalleryLayoutType(), GalleryLayoutType.mosaic);-- final searchItems = SettingsSearchRegistry.getSearchableItems(context);- expect(- searchItems.any(- (item) =>- item.matchType("mosaic") != SettingsSearchMatchType.none &&- item.matchType("masonry") != SettingsSearchMatchType.none,- ),- isTrue,- );- expect(searchItems.where((item) => item.title == l10n.layout), isNotEmpty);- });-}--Widget _testApp(Widget child) {- return MaterialApp(- theme: lightThemeData,- localizationsDelegates: StringsLocalizations.localizationsDelegates,- supportedLocales: StringsLocalizations.supportedLocales,- home: Scaffold(body: child),- );-}diff --git a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dartindex 27fedbbbc5..69d71e2801 100644--- a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart+++ b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart@@ -11,8 +11,6 @@ import "package:photos/models/file/dummy_file.dart";import "package:photos/models/file/file.dart";import "package:photos/models/file/file_type.dart";import "package:photos/models/file_load_result.dart";-import "package:photos/models/gallery/fixed_extent_section_layout.dart";-import "package:photos/models/gallery/gallery_layout_config.dart";import "package:photos/models/metadata/file_magic.dart";import "package:photos/service_locator.dart";import "package:photos/settings/local_settings.dart";@@ -148,56 +146,6 @@ void main() {},);- testWidgets("public galleries ignore a persisted mosaic preference", (- tester,- ) async {- await localSettings.setGalleryLayoutType(GalleryLayoutType.mosaic);- await localSettings.setInternalUserDisabled(true);- expect(isMosaicLayoutAvailable, isFalse);-- final galleryKey = GlobalKey<GalleryState>();- final file = _dummyFile("public");- await tester.pumpWidget(- MaterialApp(- theme: lightThemeData,- localizationsDelegates: StringsLocalizations.localizationsDelegates,- supportedLocales: StringsLocalizations.supportedLocales,- home: _galleryHost(- Gallery(- key: galleryKey,- asyncLoader: (start, end, {limit, asc}) async =>- FileLoadResult([file], false),- tagPrefix: "public_",- limitSelectionToOne: true,- showSelectAll: false,- ),- ),- ),- );- await tester.pumpAndSettle();- await tester.pump(const Duration(milliseconds: 750));- await tester.pump();-- final initialGroups = galleryKey.currentState!.galleryGroups!;- expect(localSettings.getGalleryLayoutType(), GalleryLayoutType.mosaic);- expect(initialGroups.layoutType, GalleryLayoutType.grid);- expect(- initialGroups.groupLayouts,- everyElement(isA<FixedExtentSectionLayout>()),- );-- Bus.instance.fire(GalleryLayoutChangedEvent());- await tester.pumpAndSettle();-- final rebuiltGroups = galleryKey.currentState!.galleryGroups!;- expect(rebuiltGroups, isNot(same(initialGroups)));- expect(rebuiltGroups.layoutType, GalleryLayoutType.grid);- expect(localSettings.getGalleryLayoutType(), GalleryLayoutType.mosaic);-- await tester.pumpWidget(const SizedBox.shrink());- await tester.pump();- });-testWidgets("a deep layout change preserves partial-row progress", (tester,) async {