compile
[kdegraphics.git] / gwenview / tests / testutils.h
blob637ee061ca74b1076acf0bb4e79f7672df059853
1 /*
2 Gwenview: an image viewer
3 Copyright 2008 Aurélien Gâteau <aurelien.gateau@free.fr>
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.
20 #ifndef TESTUTILS_H
21 #define TESTUTILS_H
23 // Qt
24 #include <QDir>
25 #include <QSignalSpy>
26 #include <QTest>
28 // KDE
29 #include <kurl.h>
33 * This file contains simple helpers to access test files
36 inline QString pathForTestFile(const QString& name) {
37 return QString("%1/%2").arg(KDESRCDIR).arg(name);
40 inline KUrl urlForTestFile(const QString& name) {
41 KUrl url;
42 url.setPath(pathForTestFile(name));
43 return url;
46 inline QString pathForTestOutputFile(const QString& name) {
47 return QString("%1/%2").arg(QDir::currentPath()).arg(name);
50 inline KUrl urlForTestOutputFile(const QString& name) {
51 KUrl url;
52 url.setPath(pathForTestOutputFile(name));
53 return url;
56 bool waitForSignal(const QSignalSpy& spy, int timeout = 5) {
57 for (int x = 0; x < timeout; ++x) {
58 if (spy.count() > 0) {
59 return true;
61 QTest::qWait(1000);
63 return false;
66 #endif /* TESTUTILS_H */