Changeset View
Changeset View
Standalone View
Standalone View
kioslave/desktop/tests/kio_desktop_test.cpp
Show All 12 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
13 | 13 | | |||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include <kdirlister.h> | 20 | #include <kdirlister.h> | ||
21 | #include <ktemporaryfile.h> | | |||
22 | #include <kdebug.h> | | |||
23 | #include <QDesktopServices> | 21 | #include <QDesktopServices> | ||
24 | #include <QStandardPaths> | 22 | #include <QStandardPaths> | ||
25 | #include <QObject> | 23 | #include <QTemporaryFile> | ||
26 | #include <qtest_kde.h> | 24 | #include <QTest> | ||
27 | #include <kio/job.h> | 25 | #include <kio/job.h> | ||
28 | #include <kio/copyjob.h> | 26 | #include <kio/copyjob.h> | ||
29 | 27 | | |||
30 | class TestDesktop : public QObject | 28 | class TestDesktop : public QObject | ||
31 | { | 29 | { | ||
32 | Q_OBJECT | 30 | Q_OBJECT | ||
33 | 31 | | |||
34 | public: | 32 | public: | ||
Show All 14 Lines | 35 | private Q_SLOTS: | |||
49 | void cleanupTestCase() | 47 | void cleanupTestCase() | ||
50 | { | 48 | { | ||
51 | QFile::remove(m_desktopPath + '/' + m_testFileName); | 49 | QFile::remove(m_desktopPath + '/' + m_testFileName); | ||
52 | QFile::remove(m_desktopPath + '/' + m_testFileName + ".part"); | 50 | QFile::remove(m_desktopPath + '/' + m_testFileName + ".part"); | ||
53 | } | 51 | } | ||
54 | 52 | | |||
55 | void testCopyToDesktop() | 53 | void testCopyToDesktop() | ||
56 | { | 54 | { | ||
57 | KTemporaryFile tempFile; | 55 | QTemporaryFile tempFile; | ||
58 | QVERIFY(tempFile.open()); | 56 | QVERIFY(tempFile.open()); | ||
59 | tempFile.write( "Hello world\n", 12 ); | 57 | tempFile.write( "Hello world\n", 12 ); | ||
60 | QString fileName = tempFile.fileName(); | 58 | QString fileName = tempFile.fileName(); | ||
61 | tempFile.close(); | 59 | tempFile.close(); | ||
62 | KIO::Job* job = KIO::file_copy(QUrl::fromLocalFile(fileName), QUrl("desktop:/" + m_testFileName), -1, KIO::HideProgressInfo); | 60 | KIO::Job* job = KIO::file_copy(QUrl::fromLocalFile(fileName), QUrl("desktop:/" + m_testFileName), -1, KIO::HideProgressInfo); | ||
63 | job->setUiDelegate(0); | 61 | job->setUiDelegate(0); | ||
64 | QVERIFY(job->exec()); | 62 | QVERIFY(job->exec()); | ||
65 | QVERIFY(QFile::exists(m_desktopPath + '/' + m_testFileName)); | 63 | QVERIFY(QFile::exists(m_desktopPath + '/' + m_testFileName)); | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 94 | { | |||
123 | QVERIFY(QFile::exists(destFilePath)); | 121 | QVERIFY(QFile::exists(destFilePath)); | ||
124 | } | 122 | } | ||
125 | 123 | | |||
126 | private: | 124 | private: | ||
127 | QString m_desktopPath; | 125 | QString m_desktopPath; | ||
128 | QString m_testFileName; | 126 | QString m_testFileName; | ||
129 | }; | 127 | }; | ||
130 | 128 | | |||
131 | QTEST_KDEMAIN(TestDesktop, NoGUI) | 129 | QTEST_GUILESS_MAIN(TestDesktop) | ||
132 | 130 | | |||
133 | #include "kio_desktop_test.moc" | 131 | #include "kio_desktop_test.moc" |