mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Add test case
This commit is contained in:
parent
76cf08d6fb
commit
b86e2ef33b
1 changed files with 208 additions and 0 deletions
|
@ -13,6 +13,9 @@ void main() {
|
||||||
test("multiple files", _filesMultiple);
|
test("multiple files", _filesMultiple);
|
||||||
test("directory", _filesDir);
|
test("directory", _filesDir);
|
||||||
test("nextcloud hosted in subdir", _filesServerHostedInSubdir);
|
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<void> _filesServerHostedInSubdir() async {
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _filesNc28MetadataIfd0() async {
|
||||||
|
const xml = """
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<d:multistatus xmlns:d="DAV:"
|
||||||
|
xmlns:s="http://sabredav.org/ns"
|
||||||
|
xmlns:oc="http://owncloud.org/ns"
|
||||||
|
xmlns:nc="http://nextcloud.org/ns">
|
||||||
|
<d:response>
|
||||||
|
<d:href>/nextcloud/remote.php/dav/files/admin/1.jpg</d:href>
|
||||||
|
<d:propstat>
|
||||||
|
<d:prop>
|
||||||
|
<d:getlastmodified>Fri, 01 Jan 2021 02:03:04 GMT</d:getlastmodified>
|
||||||
|
<d:getetag>"1324f58d4d5c8d81bed6e4ed9d5ea862"</d:getetag>
|
||||||
|
<d:getcontenttype>image/jpeg</d:getcontenttype>
|
||||||
|
<d:resourcetype/>
|
||||||
|
<oc:fileid>123</oc:fileid>
|
||||||
|
<d:getcontentlength>3963036</d:getcontentlength>
|
||||||
|
<nc:has-preview>false</nc:has-preview>
|
||||||
|
<nc:metadata-photos-ifd0>
|
||||||
|
<Make>SUPER</Make>
|
||||||
|
<Model>Phone 1</Model>
|
||||||
|
<Orientation>1</Orientation>
|
||||||
|
<XResolution>72/1</XResolution>
|
||||||
|
<YResolution>72/1</YResolution>
|
||||||
|
<ResolutionUnit>2</ResolutionUnit>
|
||||||
|
<Software>1.0</Software>
|
||||||
|
<DateTime>2020:01:02 03:04:05</DateTime>
|
||||||
|
<YCbCrPositioning>1</YCbCrPositioning>
|
||||||
|
</nc:metadata-photos-ifd0>
|
||||||
|
</d:prop>
|
||||||
|
<d:status>HTTP/1.1 200 OK</d:status>
|
||||||
|
</d:propstat>
|
||||||
|
</d:response>
|
||||||
|
</d:multistatus>
|
||||||
|
""";
|
||||||
|
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<void> _filesNc28MetadataExif() async {
|
||||||
|
const xml = """
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<d:multistatus xmlns:d="DAV:"
|
||||||
|
xmlns:s="http://sabredav.org/ns"
|
||||||
|
xmlns:oc="http://owncloud.org/ns"
|
||||||
|
xmlns:nc="http://nextcloud.org/ns">
|
||||||
|
<d:response>
|
||||||
|
<d:href>/nextcloud/remote.php/dav/files/admin/1.jpg</d:href>
|
||||||
|
<d:propstat>
|
||||||
|
<d:prop>
|
||||||
|
<d:getlastmodified>Fri, 01 Jan 2021 02:03:04 GMT</d:getlastmodified>
|
||||||
|
<d:getetag>"1324f58d4d5c8d81bed6e4ed9d5ea862"</d:getetag>
|
||||||
|
<d:getcontenttype>image/jpeg</d:getcontenttype>
|
||||||
|
<d:resourcetype/>
|
||||||
|
<oc:fileid>123</oc:fileid>
|
||||||
|
<d:getcontentlength>3963036</d:getcontentlength>
|
||||||
|
<nc:has-preview>false</nc:has-preview>
|
||||||
|
<nc:metadata-photos-exif>
|
||||||
|
<ExposureTime>1/381</ExposureTime>
|
||||||
|
<FNumber>9/5</FNumber>
|
||||||
|
<ExposureProgram>2</ExposureProgram>
|
||||||
|
<ISOSpeedRatings>20</ISOSpeedRatings>
|
||||||
|
<ExifVersion>0231</ExifVersion>
|
||||||
|
<DateTimeOriginal>2020:01:02 03:04:05</DateTimeOriginal>
|
||||||
|
<DateTimeDigitized>2020:01:02 03:04:05</DateTimeDigitized>
|
||||||
|
<UndefinedTag__x____>+01:00</UndefinedTag__x____>
|
||||||
|
<ComponentsConfiguration/>
|
||||||
|
<ShutterSpeedValue>126682/14777</ShutterSpeedValue>
|
||||||
|
<ApertureValue>54823/32325</ApertureValue>
|
||||||
|
<BrightnessValue>69659/9080</BrightnessValue>
|
||||||
|
<ExposureBiasValue>0/1</ExposureBiasValue>
|
||||||
|
<MeteringMode>5</MeteringMode>
|
||||||
|
<Flash>16</Flash>
|
||||||
|
<FocalLength>4/1</FocalLength>
|
||||||
|
<MakerNote>SUPER</MakerNote>
|
||||||
|
<ColorSpace>65535</ColorSpace>
|
||||||
|
<ExifImageWidth>4032</ExifImageWidth>
|
||||||
|
<ExifImageLength>3024</ExifImageLength>
|
||||||
|
<SensingMethod>2</SensingMethod>
|
||||||
|
<SceneType/>
|
||||||
|
<ExposureMode>0</ExposureMode>
|
||||||
|
<WhiteBalance>0</WhiteBalance>
|
||||||
|
<FocalLengthIn__mmFilm>28</FocalLengthIn__mmFilm>
|
||||||
|
<SceneCaptureType>0</SceneCaptureType>
|
||||||
|
</nc:metadata-photos-exif>
|
||||||
|
</d:prop>
|
||||||
|
<d:status>HTTP/1.1 200 OK</d:status>
|
||||||
|
</d:propstat>
|
||||||
|
</d:response>
|
||||||
|
</d:multistatus>
|
||||||
|
""";
|
||||||
|
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<void> _filesNc28MetadataGps() async {
|
||||||
|
const xml = """
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<d:multistatus xmlns:d="DAV:"
|
||||||
|
xmlns:s="http://sabredav.org/ns"
|
||||||
|
xmlns:oc="http://owncloud.org/ns"
|
||||||
|
xmlns:nc="http://nextcloud.org/ns">
|
||||||
|
<d:response>
|
||||||
|
<d:href>/nextcloud/remote.php/dav/files/admin/1.jpg</d:href>
|
||||||
|
<d:propstat>
|
||||||
|
<d:prop>
|
||||||
|
<d:getlastmodified>Fri, 01 Jan 2021 02:03:04 GMT</d:getlastmodified>
|
||||||
|
<d:getetag>"1324f58d4d5c8d81bed6e4ed9d5ea862"</d:getetag>
|
||||||
|
<d:getcontenttype>image/jpeg</d:getcontenttype>
|
||||||
|
<d:resourcetype/>
|
||||||
|
<oc:fileid>123</oc:fileid>
|
||||||
|
<d:getcontentlength>3963036</d:getcontentlength>
|
||||||
|
<nc:has-preview>false</nc:has-preview>
|
||||||
|
<nc:metadata-photos-gps>
|
||||||
|
<latitude>1.23456</latitude>
|
||||||
|
<longitude>2.34567</longitude>
|
||||||
|
<altitude>3.45678</altitude>
|
||||||
|
</nc:metadata-photos-gps>
|
||||||
|
</d:prop>
|
||||||
|
<d:status>HTTP/1.1 200 OK</d:status>
|
||||||
|
</d:propstat>
|
||||||
|
</d:response>
|
||||||
|
</d:multistatus>
|
||||||
|
""";
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue