Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Keep device picker media queries unconstrained

r4khuld4f6054510a9
diff --git a/mobile/apps/photos/lib/ui/device_picker/device_media_library.dart b/mobile/apps/photos/lib/ui/device_picker/device_media_library.dart
index 8722ddbb4d..af01387ce8 100644
--- a/mobile/apps/photos/lib/ui/device_picker/device_media_library.dart
+++ b/mobile/apps/photos/lib/ui/device_picker/device_media_library.dart
@@ -30,6 +30,10 @@ class PhotoManagerDeviceLibrary implements DeviceMediaLibrary {
imageOption: const FilterOption(
sizeConstraint: SizeConstraint(ignoreSize: true),
),
+ videoOption: const FilterOption(
+ sizeConstraint: SizeConstraint(ignoreSize: true),
+ ),
+ createTimeCond: DateTimeCond.def().copyWith(ignore: true),
orders: [const OrderOption(type: OrderOptionType.createDate)],
),
);
diff --git a/mobile/apps/photos/test/ui/device_picker/device_media_library_test.dart b/mobile/apps/photos/test/ui/device_picker/device_media_library_test.dart
new file mode 100644
index 0000000000..43363ddc35
--- /dev/null
+++ b/mobile/apps/photos/test/ui/device_picker/device_media_library_test.dart
@@ -0,0 +1,44 @@
+import "package:flutter/services.dart";
+import "package:flutter_test/flutter_test.dart";
+import "package:photo_manager/photo_manager.dart";
+import "package:photos/ui/device_picker/device_media_library.dart";
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ test(
+ 'album queries keep media regardless of dimensions or creation date',
+ () async {
+ const channel = MethodChannel('com.fluttercandies/photo_manager');
+ final messenger =
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
+ messenger.setMockMethodCallHandler(channel, (call) async {
+ final arguments = call.arguments as Map;
+ final filter = (arguments['option'] as Map)['child'] as Map;
+ expect(arguments['type'], RequestType.common.value);
+ for (final type in ['image', 'video']) {
+ expect(((filter[type] as Map)['size'] as Map)['ignoreSize'], isTrue);
+ }
+ expect((filter['createDate'] as Map)['ignore'], isTrue);
+ return switch (call.method) {
+ 'getAssetPathList' => {
+ 'data': [
+ {'id': 'recent', 'name': 'Recent', 'isAll': true},
+ ],
+ },
+ 'getAssetCountFromPath' => 1,
+ 'getAssetListRange' => {'data': []},
+ _ => throw StateError(
+ 'Unexpected photo manager call: ${call.method}',
+ ),
+ };
+ });
+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
+
+ final library = PhotoManagerDeviceLibrary();
+ final album = (await library.albums()).single;
+ expect(await library.count(album), 1);
+ expect(await library.read(album, start: 0, end: 1), isEmpty);
+ },
+ );
+}