~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to tests/auto/transformimageoperationtest.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Gwenview: an image viewer
 
3
Copyright 2010 Aurélien Gâteau <agateau@kde.org>
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License
 
7
as published by the Free Software Foundation; either version 2
 
8
of the License, or (at your option) any later version.
 
9
 
 
10
This program is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with this program; if not, write to the Free Software
 
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 
 
19
*/
 
20
// Qt
 
21
#include <QEventLoop>
 
22
#include <QImage>
 
23
 
 
24
// KDE
 
25
#include <kdebug.h>
 
26
#include <qtest_kde.h>
 
27
 
 
28
// Local
 
29
#include "../lib/document/documentfactory.h"
 
30
#include "../lib/imageutils.h"
 
31
#include "../lib/transformimageoperation.h"
 
32
#include "testutils.h"
 
33
 
 
34
#include "transformimageoperationtest.moc"
 
35
 
 
36
QTEST_KDEMAIN(TransformImageOperationTest, GUI)
 
37
 
 
38
using namespace Gwenview;
 
39
 
 
40
void TransformImageOperationTest::initTestCase()
 
41
{
 
42
    qRegisterMetaType<KUrl>("KUrl");
 
43
}
 
44
 
 
45
void TransformImageOperationTest::init()
 
46
{
 
47
    DocumentFactory::instance()->clearCache();
 
48
}
 
49
 
 
50
void TransformImageOperationTest::testRotate90()
 
51
{
 
52
    KUrl url = urlForTestFile("test.png");
 
53
    QImage image;
 
54
 
 
55
    bool ok = image.load(url.toLocalFile());
 
56
    QVERIFY2(ok, "Could not load 'test.png'");
 
57
    QMatrix matrix = ImageUtils::transformMatrix(ROT_90);
 
58
    image = image.transformed(matrix);
 
59
 
 
60
    Document::Ptr doc = DocumentFactory::instance()->load(url);
 
61
 
 
62
    TransformImageOperation* op = new TransformImageOperation(ROT_90);
 
63
    QEventLoop loop;
 
64
    connect(doc.data(), SIGNAL(allTasksDone()), &loop, SLOT(quit()));
 
65
    op->applyToDocument(doc);
 
66
    loop.exec();
 
67
 
 
68
    QCOMPARE(image, doc->image());
 
69
}