void ut_metadata::testEditGps_altitude() { QuillMetadata editMetadata; double expected = 60.1639; double actual; QVERIFY(editMetadata.isValid()); // Setting a latitude editMetadata.setEntry(QuillMetadata::Tag_GPSAltitude, QVariant(expected)); actual = editMetadata.entry(QuillMetadata::Tag_GPSAltitude).toDouble(); QCOMPARE(round(actual * PRECISION), round(expected * PRECISION)); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSAltitudeRef).toString(), QString("0")); // Setting a negative altitude (that is: the altitude reference should be now "1" (below sea level) editMetadata.setEntry(QuillMetadata::Tag_GPSAltitude, QVariant(-expected)); actual = editMetadata.entry(QuillMetadata::Tag_GPSAltitude).toDouble(); QCOMPARE(round(actual * PRECISION), round(expected * PRECISION)); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSAltitudeRef).toString(), QString("1")); // 0 meters altitude is over sea level editMetadata.setEntry(QuillMetadata::Tag_GPSAltitude, QVariant(double(0))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSAltitude).toString(), QString("0")); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSAltitudeRef).toString(), QString("0")); // Manually setting the altitude reference editMetadata.setEntry(QuillMetadata::Tag_GPSAltitudeRef, QVariant(int(1))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSAltitudeRef).toString(), QString("1")); }
void ut_metadata::testEditGps_longitude() { QuillMetadata editMetadata; double expected = 60.1639; double actual; QVERIFY(editMetadata.isValid()); // Setting a setEntry editMetadata.setEntry(QuillMetadata::Tag_GPSLongitude, QVariant(expected)); actual = editMetadata.entry(QuillMetadata::Tag_GPSLongitude).toDouble(); QCOMPARE(round(actual * PRECISION), round(expected * PRECISION)); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSLongitudeRef).toString(), QString("E")); // Setting a negative longitude (that is: the longitude reference should be now "W"est) editMetadata.setEntry(QuillMetadata::Tag_GPSLongitude, QVariant(-expected)); actual = editMetadata.entry(QuillMetadata::Tag_GPSLongitude).toDouble(); QCOMPARE(round(actual * PRECISION), round(expected * PRECISION)); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSLongitudeRef).toString(), QString("W")); // 0 degrees longitude is "E"ast editMetadata.setEntry(QuillMetadata::Tag_GPSLongitude, QVariant(double(0))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSLongitude).toString(), QString("0")); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSLongitudeRef).toString(), QString("E")); // Manually setting the longitude reference editMetadata.setEntry(QuillMetadata::Tag_GPSLongitudeRef, QVariant(QString("W"))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSLongitudeRef).toString(), QString("W")); }
void ut_metadata::testOrientationTagSpeedup() { QString str("/usr/share/quillimagefilter-tests/images/16_color_palette.png"); for (int i = 0; i<=8; i++){ QTemporaryFile file; file.open(); sourceImage.save(file.fileName(), "jpg"); QuillMetadata empty; empty.setEntry(QuillMetadata::Tag_Orientation, QVariant(i)); QVERIFY(empty.write(file.fileName())); int orientation1, orientation2; { QuillMetadata *metadata = new QuillMetadata(file.fileName(), QuillMetadata::ExifFormat); QVERIFY(metadata->isValid()); QCOMPARE(metadata->entry(QuillMetadata::Tag_Orientation).toInt(), i); orientation1 = metadata->entry(QuillMetadata::Tag_Orientation).toInt(); delete metadata; } { QuillMetadata *metadata = new QuillMetadata(file.fileName(), QuillMetadata::ExifFormat, QuillMetadata::Tag_Orientation); QVERIFY(metadata->isValid()); QCOMPARE(metadata->entry(QuillMetadata::Tag_Orientation).toInt(), i); orientation2 = metadata->entry(QuillMetadata::Tag_Orientation).toInt(); delete metadata; } QCOMPARE(orientation1, orientation2); } }
void ut_metadata::testEditGps_direction() { QuillMetadata editMetadata; QVERIFY(editMetadata.isValid()); // Setting image direction between 0.00 and 359.99 editMetadata.setEntry(QuillMetadata::Tag_GPSImgDirection, QVariant(double(25.25))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSImgDirection).toString(), QString("25.25")); // Setting image under 0.00 editMetadata.setEntry(QuillMetadata::Tag_GPSImgDirection, QVariant(double(-15))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSImgDirection).toString(), QString("345")); // Setting image over 359.99 editMetadata.setEntry(QuillMetadata::Tag_GPSImgDirection, QVariant(double(400))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSImgDirection).toString(), QString("40")); // Manually setting the direction reference editMetadata.setEntry(QuillMetadata::Tag_GPSImgDirectionRef, QVariant(QString("T"))); QCOMPARE(editMetadata.entry(QuillMetadata::Tag_GPSImgDirectionRef).toString(), QString("T")); }