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

« back to all changes in this revision

Viewing changes to tests/documenttest.h

  • 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 2007 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
 
#ifndef DOCUMENTTEST_H
21
 
#define DOCUMENTTEST_H
22
 
 
23
 
// Qt
24
 
#include <QObject>
25
 
 
26
 
// KDE
27
 
#include <kjob.h>
28
 
 
29
 
// Local
30
 
#include "../lib/document/document.h"
31
 
 
32
 
class LoadingStateSpy : public QObject {
33
 
        Q_OBJECT
34
 
public:
35
 
        LoadingStateSpy(const Gwenview::Document::Ptr& doc)
36
 
        : mDocument(doc)
37
 
        , mCallCount(0)
38
 
        {
39
 
        }
40
 
 
41
 
public Q_SLOTS:
42
 
        void readState() {
43
 
                mCallCount++;
44
 
                mState = mDocument->loadingState();
45
 
        }
46
 
 
47
 
public:
48
 
        Gwenview::Document::Ptr mDocument;
49
 
        int mCallCount;
50
 
        Gwenview::Document::LoadingState mState;
51
 
};
52
 
 
53
 
 
54
 
class JobWatcher : public QObject {
55
 
        Q_OBJECT
56
 
public:
57
 
        JobWatcher(KJob* job)
58
 
        : mJob(job)
59
 
        , mDone(false)
60
 
        , mError(0)
61
 
        {
62
 
                connect(job, SIGNAL(result(KJob*)),
63
 
                        SLOT(slotResult(KJob*)));
64
 
                connect(job, SIGNAL(destroyed(QObject*)),
65
 
                        SLOT(slotDestroyed()));
66
 
        }
67
 
 
68
 
        void wait() {
69
 
                while (!mDone) {
70
 
                        QApplication::processEvents();
71
 
                }
72
 
        }
73
 
 
74
 
        int error() const {
75
 
                return mError;
76
 
        }
77
 
 
78
 
private Q_SLOTS:
79
 
        void slotResult(KJob* job) {
80
 
                mError = job->error();
81
 
                mDone = true;
82
 
        }
83
 
 
84
 
        void slotDestroyed() {
85
 
                kWarning() << "Destroyed";
86
 
                mError = -1;
87
 
                mDone = true;
88
 
        }
89
 
 
90
 
private:
91
 
        KJob* mJob;
92
 
        bool mDone;
93
 
        int mError;
94
 
};
95
 
 
96
 
 
97
 
class DocumentTest : public QObject {
98
 
        Q_OBJECT
99
 
 
100
 
private Q_SLOTS:
101
 
        void testLoad();
102
 
        void testLoad_data();
103
 
        void testLoadTwoPasses();
104
 
        void testLoadEmpty();
105
 
        void testLoadDownSampled();
106
 
        void testLoadDownSampled_data();
107
 
        void testLoadDownSampledPng();
108
 
        void testLoadRemote();
109
 
        void testLoadAnimated();
110
 
        void testDeleteWhileLoading();
111
 
        void testLoadRotated();
112
 
        void testMultipleLoads();
113
 
        void testSaveAs();
114
 
        void testSaveRemote();
115
 
        void testLosslessSave();
116
 
        void testLosslessRotate();
117
 
        void testModifyAndSaveAs();
118
 
        void testMetaInfoJpeg();
119
 
        void testMetaInfoBmp();
120
 
        void testForgetModifiedDocument();
121
 
        void testModifiedAndSavedSignals();
122
 
        void testJobQueue();
123
 
        void testCheckDocumentEditor();
124
 
        void testUndoStackPush();
125
 
 
126
 
        void initTestCase();
127
 
        void init();
128
 
};
129
 
 
130
 
#endif // DOCUMENTTEST_H