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.
37
* This file contains simple helpers to access test files
40
inline QString pathForTestFile(const QString& name) {
41
return QString("%1/%2").arg(KDESRCDIR).arg(name);
44
inline KUrl urlForTestFile(const QString& name) {
46
url.setPath(pathForTestFile(name));
50
inline QString pathForTestOutputFile(const QString& name) {
51
return QString("%1/%2").arg(QDir::currentPath()).arg(name);
54
inline KUrl urlForTestOutputFile(const QString& name) {
56
url.setPath(pathForTestOutputFile(name));
60
inline bool waitForSignal(const QSignalSpy& spy, int timeout = 5) {
61
for (int x = 0; x < timeout; ++x) {
62
if (spy.count() > 0) {
70
inline bool fuzzyImageCompare(const QImage& img1, const QImage& img2) {
71
if (img1.size() != img2.size()) {
72
kWarning() << "Different sizes" << img1.size() << img2.size();
75
if (img1.format() != img2.format()) {
76
kWarning() << "Different formats" << img1.format() << img2.format();
80
for(int posY = 0; posY < img1.height(); ++posY) {
81
for (int posX = 0; posX < img2.width(); ++posX) {
82
if (!(int)abs((double)img1.pixel(posX, posY) - img2.pixel(posX, posY)) > 2) {
83
kWarning() << "Different at" << QPoint(posX, posY);
92
* Returns the url of the remote url dir if remote test dir was successfully
94
* If testFile is valid, it is copied into the test dir.
96
KUrl setUpRemoteTestDir(const QString& testFile = QString());
98
#endif /* TESTUTILS_H */