Changeset View
Changeset View
Standalone View
Standalone View
tests/auto/exiv2contenttest.cpp
- This file was moved from tests/auto/jpegcontenttest.cpp.
Context not available. | |||||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
---|---|---|---|---|---|
18 | 18 | | |||
19 | */ | 19 | */ | ||
20 | #include "jpegcontenttest.h" | 20 | #include "exiv2contenttest.h" | ||
21 | #include <iostream> | 21 | #include <iostream> | ||
22 | 22 | | |||
23 | // Qt | 23 | // Qt | ||
Context not available. | |||||
32 | 32 | | |||
33 | // Local | 33 | // Local | ||
34 | #include "../lib/orientation.h" | 34 | #include "../lib/orientation.h" | ||
35 | #include "../lib/jpegcontent.h" | 35 | #include "../lib/exiv2imageloader.h" | ||
36 | #include "testutils.h" | 36 | #include "testutils.h" | ||
37 | 37 | | |||
38 | using namespace std; | 38 | using namespace std; | ||
Context not available. | |||||
47 | const int ORIENT6_HEIGHT = 256; // has been applied | 47 | const int ORIENT6_HEIGHT = 256; // has been applied | ||
48 | const QString ORIENT6_COMMENT = "a comment"; | 48 | const QString ORIENT6_COMMENT = "a comment"; | ||
49 | 49 | | |||
50 | QTEST_MAIN(JpegContentTest) | 50 | QTEST_MAIN(Exiv2ImageLoaderTest) | ||
51 | 51 | | |||
52 | void JpegContentTest::initTestCase() | 52 | void Exiv2ImageLoaderTest::initTestCase() | ||
53 | { | 53 | { | ||
54 | bool result; | 54 | bool result; | ||
55 | QFile in(pathForTestFile(ORIENT6_FILE)); | 55 | QFile in(pathForTestFile(ORIENT6_FILE)); | ||
Context not available. | |||||
72 | delete []data; | 72 | delete []data; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | void JpegContentTest::cleanupTestCase() | 75 | void Exiv2ImageLoaderTest::cleanupTestCase() | ||
76 | { | 76 | { | ||
77 | QDir::current().remove(CUT_FILE); | 77 | QDir::current().remove(CUT_FILE); | ||
78 | } | 78 | } | ||
Context not available. | |||||
118 | } | 118 | } | ||
119 | #endif | 119 | #endif | ||
120 | 120 | | |||
121 | void JpegContentTest::testResetOrientation() | 121 | void Exiv2ImageLoaderTest::testResetOrientation() | ||
122 | { | 122 | { | ||
123 | Gwenview::JpegContent content; | 123 | Gwenview::Exiv2ImageLoader content; | ||
124 | bool result; | 124 | bool result; | ||
125 | 125 | | |||
126 | // Test resetOrientation without transform | 126 | // Test resetOrientation without transform | ||
127 | result = content.load(pathForTestFile(ORIENT6_FILE)); | 127 | result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
128 | QVERIFY(result); | 128 | QVERIFY(result); | ||
129 | QCOMPARE(content.orientation(), Gwenview::ROT_90); | ||||
129 | 130 | | |||
130 | content.resetOrientation(); | 131 | content.resetOrientation(); | ||
131 | 132 | | |||
Context not available. | |||||
148 | 149 | | |||
149 | result = content.load(TMP_FILE); | 150 | result = content.load(TMP_FILE); | ||
150 | QVERIFY(result); | 151 | QVERIFY(result); | ||
151 | QCOMPARE(content.orientation(), Gwenview::NORMAL); | 152 | QCOMPARE(content.orientation(), Gwenview::ROT_90); | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | /** | 155 | /** | ||
155 | * This function tests JpegContent::transform() by applying a ROT_90 | 156 | * This function tests Exiv2ImageLoader::transform() by applying a ROT_90 | ||
156 | * transformation, saving, reloading and applying a ROT_270 to undo the ROT_90. | 157 | * transformation, saving, reloading and applying a ROT_270 to undo the ROT_90. | ||
157 | * Saving and reloading are necessary because lossless transformation only | 158 | * Saving and reloading are necessary because lossless transformation only | ||
158 | * happens in JpegContent::save() | 159 | * happens in Exiv2ImageLoader::save() | ||
159 | */ | 160 | */ | ||
160 | void JpegContentTest::testTransform() | 161 | void Exiv2ImageLoaderTest::testTransform() | ||
161 | { | 162 | { | ||
162 | bool result; | 163 | bool result; | ||
163 | QImage finalImage, expectedImage; | 164 | QImage finalImage, expectedImage; | ||
164 | 165 | | |||
165 | Gwenview::JpegContent content; | 166 | Gwenview::Exiv2ImageLoader content; | ||
166 | result = content.load(pathForTestFile(ORIENT6_FILE)); | 167 | result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
167 | QVERIFY(result); | 168 | QVERIFY(result); | ||
168 | 169 | | |||
Context not available. | |||||
185 | QCOMPARE(finalImage , expectedImage); | 186 | QCOMPARE(finalImage , expectedImage); | ||
186 | } | 187 | } | ||
187 | 188 | | |||
188 | void JpegContentTest::testSetComment() | 189 | void Exiv2ImageLoaderTest::testSetComment() | ||
189 | { | 190 | { | ||
190 | QString comment = "test comment"; | 191 | QString comment = "test comment"; | ||
191 | Gwenview::JpegContent content; | 192 | Gwenview::Exiv2ImageLoader content; | ||
192 | bool result; | 193 | bool result; | ||
193 | result = content.load(pathForTestFile(ORIENT6_FILE)); | 194 | result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
194 | QVERIFY(result); | 195 | QVERIFY(result); | ||
Context not available. | |||||
203 | QCOMPARE(content.comment() , comment); | 204 | QCOMPARE(content.comment() , comment); | ||
204 | } | 205 | } | ||
205 | 206 | | |||
206 | void JpegContentTest::testReadInfo() | 207 | void Exiv2ImageLoaderTest::testReadInfo() | ||
207 | { | 208 | { | ||
208 | Gwenview::JpegContent content; | 209 | Gwenview::Exiv2ImageLoader content; | ||
209 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | 210 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
210 | QVERIFY(result); | 211 | QVERIFY(result); | ||
211 | QCOMPARE(int(content.orientation()), 6); | 212 | QCOMPARE(int(content.orientation()), 6); | ||
Context not available. | |||||
213 | QCOMPARE(content.size() , QSize(ORIENT6_WIDTH, ORIENT6_HEIGHT)); | 214 | QCOMPARE(content.size() , QSize(ORIENT6_WIDTH, ORIENT6_HEIGHT)); | ||
214 | } | 215 | } | ||
215 | 216 | | |||
216 | void JpegContentTest::testThumbnail() | 217 | void Exiv2ImageLoaderTest::testThumbnail() | ||
217 | { | 218 | { | ||
218 | Gwenview::JpegContent content; | 219 | Gwenview::Exiv2ImageLoader content; | ||
219 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | 220 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
220 | QVERIFY(result); | 221 | QVERIFY(result); | ||
221 | QImage thumbnail = content.thumbnail(); | 222 | QImage thumbnail = content.thumbnail(); | ||
Context not available. | |||||
223 | QVERIFY(result); | 224 | QVERIFY(result); | ||
224 | } | 225 | } | ||
225 | 226 | | |||
226 | void JpegContentTest::testMultipleRotations() | 227 | void Exiv2ImageLoaderTest::testMultipleRotations() | ||
227 | { | 228 | { | ||
228 | // Test that rotating a file a lot of times does not cause findJxform() to fail | 229 | // Test that rotating a file a lot of times does not cause findJxform() to fail | ||
229 | Gwenview::JpegContent content; | 230 | Gwenview::Exiv2ImageLoader content; | ||
230 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | 231 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
231 | QVERIFY(result); | 232 | QVERIFY(result); | ||
232 | result = content.load(pathForTestFile(ORIENT6_FILE)); | 233 | result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
Context not available. | |||||
242 | result = content.load(TMP_FILE); | 243 | result = content.load(TMP_FILE); | ||
243 | QVERIFY(result); | 244 | QVERIFY(result); | ||
244 | 245 | | |||
245 | QCOMPARE(content.size() , QSize(ORIENT6_HEIGHT, ORIENT6_WIDTH)); | 246 | QCOMPARE(content.size() , QSize(ORIENT6_WIDTH, ORIENT6_HEIGHT)); | ||
246 | 247 | | |||
247 | // Check the other meta info are still here | 248 | // Check the other meta info are still here | ||
248 | // QStringList ignoredKeys; | 249 | // QStringList ignoredKeys; | ||
Context not available. | |||||
250 | // compareMetaInfo(pathForTestFile(ORIENT6_FILE), pathForTestFile(ORIENT1_VFLIP_FILE), ignoredKeys); | 251 | // compareMetaInfo(pathForTestFile(ORIENT6_FILE), pathForTestFile(ORIENT1_VFLIP_FILE), ignoredKeys); | ||
251 | } | 252 | } | ||
252 | 253 | | |||
253 | void JpegContentTest::testLoadTruncated() | 254 | void Exiv2ImageLoaderTest::testLoadTruncated() | ||
254 | { | 255 | { | ||
255 | // Test that loading and manipulating a truncated file does not crash | 256 | // Test that loading and manipulating a truncated file does not crash | ||
256 | Gwenview::JpegContent content; | 257 | Gwenview::Exiv2ImageLoader content; | ||
257 | bool result = content.load(CUT_FILE); | 258 | bool result = content.load(CUT_FILE); | ||
258 | QVERIFY(result); | 259 | QVERIFY(result); | ||
259 | QCOMPARE(int(content.orientation()), 6); | 260 | QCOMPARE(int(content.orientation()), 6); | ||
Context not available. | |||||
264 | qWarning() << "#" ; | 265 | qWarning() << "#" ; | ||
265 | } | 266 | } | ||
266 | 267 | | |||
267 | void JpegContentTest::testRawData() | 268 | void Exiv2ImageLoaderTest::testSetImage() | ||
268 | { | | |||
269 | Gwenview::JpegContent content; | | |||
270 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | | |||
271 | QVERIFY(result); | | |||
272 | | ||||
273 | QByteArray fileData; | | |||
274 | QFile file(pathForTestFile(ORIENT6_FILE)); | | |||
275 | result = file.open(QIODevice::ReadOnly); | | |||
276 | QVERIFY(result); | | |||
277 | fileData = file.readAll(); | | |||
278 | | ||||
279 | QCOMPARE(content.rawData(), fileData); | | |||
280 | } | | |||
281 | | ||||
282 | void JpegContentTest::testSetImage() | | |||
283 | { | 269 | { | ||
284 | Gwenview::JpegContent content; | 270 | Gwenview::Exiv2ImageLoader content; | ||
285 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | 271 | bool result = content.load(pathForTestFile(ORIENT6_FILE)); | ||
286 | QVERIFY(result); | 272 | QVERIFY(result); | ||
287 | 273 | | |||
Context not available. |