~ubuntu-branches/ubuntu/trusty/gwenview/trusty

« back to all changes in this revision

Viewing changes to tests/auto/cmsprofiletest.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-11-19 15:42:29 UTC
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: package-import@ubuntu.com-20121119154229-selaegu8d5rzxtln
Tags: upstream-4.9.80
Import upstream version 4.9.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
 
2
/*
 
3
Gwenview: an image viewer
 
4
Copyright 2012 Aurélien Gâteau <agateau@kde.org>
 
5
 
 
6
This program is free software; you can redistribute it and/or
 
7
modify it under the terms of the GNU General Public License
 
8
as published by the Free Software Foundation; either version 2
 
9
of the License, or (at your option) any later version.
 
10
 
 
11
This program is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
GNU General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public License
 
17
along with this program; if not, write to the Free Software
 
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
 
19
 
 
20
*/
 
21
// Self
 
22
#include "cmsprofiletest.moc"
 
23
 
 
24
// Local
 
25
#include <lib/cms/cmsprofile.h>
 
26
#include <lib/exiv2imageloader.h>
 
27
#include <testutils.h>
 
28
 
 
29
// KDE
 
30
#include <qtest_kde.h>
 
31
 
 
32
// Qt
 
33
 
 
34
QTEST_KDEMAIN(CmsProfileTest, GUI)
 
35
 
 
36
using namespace Gwenview;
 
37
 
 
38
void CmsProfileTest::testLoadFromImageData()
 
39
{
 
40
    QFETCH(QString, fileName);
 
41
    QFETCH(QByteArray, format);
 
42
    QByteArray data;
 
43
    {
 
44
        QString path = pathForTestFile(fileName);
 
45
        QFile file(path);
 
46
        QVERIFY(file.open(QIODevice::ReadOnly));
 
47
        data = file.readAll();
 
48
    }
 
49
    Cms::Profile::Ptr ptr = Cms::Profile::loadFromImageData(data, format);
 
50
    QVERIFY(!ptr.isNull());
 
51
}
 
52
 
 
53
#define NEW_ROW(fileName, format) QTest::newRow(fileName) << fileName << QByteArray(format)
 
54
void CmsProfileTest::testLoadFromImageData_data()
 
55
{
 
56
    QTest::addColumn<QString>("fileName");
 
57
    QTest::addColumn<QByteArray>("format");
 
58
    NEW_ROW("cms/colourTestFakeBRG.png", "png");
 
59
    NEW_ROW("cms/colourTestsRGB.png", "png");
 
60
    NEW_ROW("cms/Upper_Left.jpg", "jpeg");
 
61
    NEW_ROW("cms/Upper_Right.jpg", "jpeg");
 
62
    NEW_ROW("cms/Lower_Left.jpg", "jpeg");
 
63
    NEW_ROW("cms/Lower_Right.jpg", "jpeg");
 
64
}
 
65
#undef NEW_ROW
 
66
 
 
67
#if 0
 
68
 
 
69
void CmsProfileTest::testLoadFromExiv2Image()
 
70
{
 
71
    QFETCH(QString, fileName);
 
72
    Exiv2::Image::AutoPtr image;
 
73
    {
 
74
        QByteArray data;
 
75
        QString path = pathForTestFile(fileName);
 
76
        kWarning() << path;
 
77
        QFile file(path);
 
78
        QVERIFY(file.open(QIODevice::ReadOnly));
 
79
        data = file.readAll();
 
80
 
 
81
        Exiv2ImageLoader loader;
 
82
        QVERIFY(loader.load(data));
 
83
        image = loader.popImage();
 
84
    }
 
85
    Cms::Profile::Ptr ptr = Cms::Profile::loadFromExiv2Image(image.get());
 
86
    QVERIFY(!ptr.isNull());
 
87
}
 
88
 
 
89
#define NEW_ROW(fileName) QTest::newRow(fileName) << fileName
 
90
void CmsProfileTest::testLoadFromExiv2Image_data()
 
91
{
 
92
    QTest::addColumn<QString>("fileName");
 
93
}
 
94
#undef NEW_ROW
 
95
 
 
96
#endif