fix warning
[kdegraphics.git] / gwenview / tests / testutils.h
blob1e1d2d5ff52eb35bf8f3b9de392c0b70176027a3
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>
26 // KDE
27 #include <kurl.h>
31 * This file contains simple helpers to access test files
34 inline QString pathForTestFile(const QString& name) {
35 return QString("%1/%2").arg(KDESRCDIR).arg(name);
38 inline KUrl urlForTestFile(const QString& name) {
39 KUrl url;
40 url.setPath(pathForTestFile(name));
41 return url;
44 inline QString pathForTestOutputFile(const QString& name) {
45 return QString("%1/%2").arg(QDir::currentPath()).arg(name);
48 inline KUrl urlForTestOutputFile(const QString& name) {
49 KUrl url;
50 url.setPath(pathForTestOutputFile(name));
51 return url;
54 bool waitForSignal(const QSignalSpy& spy, int timeout = 5) {
55 for (int x = 0; x < timeout; ++x) {
56 if (spy.count() > 0) {
57 return true;
59 QTest::qWait(1000);
61 return false;
64 #endif /* TESTUTILS_H */