2
Gwenview: an image viewer
3
Copyright 2008 Aurélien Gâteau <agateau@kde.org>
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.
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.
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.
36
class SandBoxDir : public QDir
40
: mTempDir(QDir::currentPath() + "/sandbox-") {
41
setPath(mTempDir.name());
49
* This file contains simple helpers to access test files
52
inline QString pathForTestFile(const QString& name)
54
return QDir::cleanPath(QString("%1/../data/%2").arg(KDESRCDIR).arg(name));
57
inline KUrl urlForTestFile(const QString& name)
60
url.setPath(pathForTestFile(name));
64
inline QString pathForTestOutputFile(const QString& name)
66
return QString("%1/%2").arg(QDir::currentPath()).arg(name);
69
inline KUrl urlForTestOutputFile(const QString& name)
72
url.setPath(pathForTestOutputFile(name));
76
inline bool waitForSignal(const QSignalSpy& spy, int timeout = 5)
78
for (int x = 0; x < timeout; ++x) {
79
if (spy.count() > 0) {
87
inline bool fuzzyImageCompare(const QImage& img1, const QImage& img2)
89
if (img1.size() != img2.size()) {
90
kWarning() << "Different sizes" << img1.size() << img2.size();
93
if (img1.format() != img2.format()) {
94
kWarning() << "Different formats" << img1.format() << img2.format();
98
for (int posY = 0; posY < img1.height(); ++posY) {
99
for (int posX = 0; posX < img2.width(); ++posX) {
100
if (!(int)abs((double)img1.pixel(posX, posY) - img2.pixel(posX, posY)) > 2) {
101
kWarning() << "Different at" << QPoint(posX, posY);
109
void createEmptyFile(const QString& path);
112
* Returns the url of the remote url dir if remote test dir was successfully
114
* If testFile is valid, it is copied into the test dir.
116
KUrl setUpRemoteTestDir(const QString& testFile = QString());
118
#endif /* TESTUTILS_H */