diff --git a/np_api/test/entity/file_parser_test.dart b/np_api/test/entity/file_parser_test.dart index c45a19f0..32f63d60 100644 --- a/np_api/test/entity/file_parser_test.dart +++ b/np_api/test/entity/file_parser_test.dart @@ -13,6 +13,9 @@ void main() { test("multiple files", _filesMultiple); test("directory", _filesDir); test("nextcloud hosted in subdir", _filesServerHostedInSubdir); + test("file w/ metadata-photos-ifd0", _filesNc28MetadataIfd0); + test("file w/ metadata-photos-exif", _filesNc28MetadataExif); + test("file w/ metadata-photos-gps", _filesNc28MetadataGps); }); }); } @@ -380,3 +383,208 @@ Future _filesServerHostedInSubdir() async { ), ]); } + +Future _filesNc28MetadataIfd0() async { + const xml = """ + + + + /nextcloud/remote.php/dav/files/admin/1.jpg + + + Fri, 01 Jan 2021 02:03:04 GMT + "1324f58d4d5c8d81bed6e4ed9d5ea862" + image/jpeg + + 123 + 3963036 + false + + SUPER + Phone 1 + 1 + 72/1 + 72/1 + 2 + 1.0 + 2020:01:02 03:04:05 + 1 + + + HTTP/1.1 200 OK + + + +"""; + final results = await FileParser().parse(xml); + expect(results, [ + File( + href: "/nextcloud/remote.php/dav/files/admin/1.jpg", + contentLength: 3963036, + contentType: "image/jpeg", + etag: "1324f58d4d5c8d81bed6e4ed9d5ea862", + lastModified: DateTime.utc(2021, 1, 1, 2, 3, 4), + hasPreview: false, + fileId: 123, + isCollection: false, + metadataPhotosIfd0: { + "Make": "SUPER", + "Model": "Phone 1", + "Orientation": "1", + "XResolution": "72/1", + "YResolution": "72/1", + "ResolutionUnit": "2", + "Software": "1.0", + "DateTime": "2020:01:02 03:04:05", + "YCbCrPositioning": "1", + }, + ), + ]); +} + +Future _filesNc28MetadataExif() async { + const xml = """ + + + + /nextcloud/remote.php/dav/files/admin/1.jpg + + + Fri, 01 Jan 2021 02:03:04 GMT + "1324f58d4d5c8d81bed6e4ed9d5ea862" + image/jpeg + + 123 + 3963036 + false + + 1/381 + 9/5 + 2 + 20 + 0231 + 2020:01:02 03:04:05 + 2020:01:02 03:04:05 + +01:00 + + 126682/14777 + 54823/32325 + 69659/9080 + 0/1 + 5 + 16 + 4/1 + SUPER + 65535 + 4032 + 3024 + 2 + + 0 + 0 + 28 + 0 + + + HTTP/1.1 200 OK + + + +"""; + final results = await FileParser().parse(xml); + expect(results, [ + File( + href: "/nextcloud/remote.php/dav/files/admin/1.jpg", + contentLength: 3963036, + contentType: "image/jpeg", + etag: "1324f58d4d5c8d81bed6e4ed9d5ea862", + lastModified: DateTime.utc(2021, 1, 1, 2, 3, 4), + hasPreview: false, + fileId: 123, + isCollection: false, + metadataPhotosExif: { + "ExposureTime": "1/381", + "FNumber": "9/5", + "ExposureProgram": "2", + "ISOSpeedRatings": "20", + "ExifVersion": "0231", + "DateTimeOriginal": "2020:01:02 03:04:05", + "DateTimeDigitized": "2020:01:02 03:04:05", + "UndefinedTag__x____": "+01:00", + "ComponentsConfiguration": "", + "ShutterSpeedValue": "126682/14777", + "ApertureValue": "54823/32325", + "BrightnessValue": "69659/9080", + "ExposureBiasValue": "0/1", + "MeteringMode": "5", + "Flash": "16", + "FocalLength": "4/1", + "MakerNote": "SUPER", + "ColorSpace": "65535", + "ExifImageWidth": "4032", + "ExifImageLength": "3024", + "SensingMethod": "2", + "SceneType": "", + "ExposureMode": "0", + "WhiteBalance": "0", + "FocalLengthIn__mmFilm": "28", + "SceneCaptureType": "0", + }, + ), + ]); +} + +Future _filesNc28MetadataGps() async { + const xml = """ + + + + /nextcloud/remote.php/dav/files/admin/1.jpg + + + Fri, 01 Jan 2021 02:03:04 GMT + "1324f58d4d5c8d81bed6e4ed9d5ea862" + image/jpeg + + 123 + 3963036 + false + + 1.23456 + 2.34567 + 3.45678 + + + HTTP/1.1 200 OK + + + +"""; + final results = await FileParser().parse(xml); + expect(results, [ + File( + href: "/nextcloud/remote.php/dav/files/admin/1.jpg", + contentLength: 3963036, + contentType: "image/jpeg", + etag: "1324f58d4d5c8d81bed6e4ed9d5ea862", + lastModified: DateTime.utc(2021, 1, 1, 2, 3, 4), + hasPreview: false, + fileId: 123, + isCollection: false, + metadataPhotosGps: { + "latitude": "1.23456", + "longitude": "2.34567", + "altitude": "3.45678", + }, + ), + ]); +}