2
Gwenview: an image viewer
3
Copyright 2010 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.
20
#include "testutils.h"
24
#include <kio/deletejob.h>
25
#include <kio/netaccess.h>
28
static void rm_rf(const QString& pathOrUrl) {
29
KIO::Job* job = KIO::del(pathOrUrl, KIO::HideProgressInfo);
30
job->setUiDelegate(0);
31
KIO::NetAccess::synchronousRun(job, 0);
34
static bool mkdir(const QString& pathOrUrl) {
35
KIO::Job* job = KIO::mkdir(pathOrUrl, -1);
36
job->setUiDelegate(0);
37
return KIO::NetAccess::synchronousRun(job, 0);
40
static bool cp(const QString& src, const QString& _dst) {
41
KIO::Job* job = KIO::file_copy(src, _dst, -1, KIO::Overwrite | KIO::HideProgressInfo);
42
job->setUiDelegate(0);
43
return KIO::NetAccess::synchronousRun(job, 0);
46
KUrl setUpRemoteTestDir(const QString& testFile) {
47
if (!qgetenv("NO_REMOTE_TESTS").isEmpty()) {
48
kWarning() << "Remote tests disabled";
52
QString testDir("/tmp/gwenview-remote-tests/");
55
if (!mkdir(testDir)) {
56
kFatal() << "Could not create dir" << testDir;
60
if (!testFile.isEmpty()) {
61
if (!cp(pathForTestFile(testFile), testDir + testFile)) {
62
kFatal() << "Could not copy" << testFile << "to" << testDir;
67
return KUrl("sftp://localhost" + testDir);