Changeset View
Changeset View
Standalone View
Standalone View
autotests/unit/file/filewatchtest.cpp
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "filewatch.h" | 21 | #include "filewatch.h" | ||
22 | #include "fileindexerconfigutils.h" | 22 | #include "fileindexerconfigutils.h" | ||
23 | #include "database.h" | 23 | #include "database.h" | ||
24 | #include "fileindexerconfig.h" | 24 | #include "fileindexerconfig.h" | ||
25 | #include "pendingfilequeue.h" | 25 | #include "pendingfilequeue.h" | ||
26 | #include "mainhub.h" | ||||
26 | #include "../lib/xattrdetector.h" | 27 | #include "../lib/xattrdetector.h" | ||
27 | #include "../lib/baloo_xattr_p.h" | 28 | #include "../lib/baloo_xattr_p.h" | ||
28 | 29 | | |||
29 | #include <QTest> | 30 | #include <QTest> | ||
30 | #include <QSignalSpy> | 31 | #include <QSignalSpy> | ||
31 | #include <QTemporaryDir> | 32 | #include <QTemporaryDir> | ||
32 | 33 | | |||
33 | namespace Baloo { | 34 | namespace Baloo { | ||
34 | 35 | | |||
35 | class FileWatchTest : public QObject | 36 | class FileWatchTest : public QObject | ||
36 | { | 37 | { | ||
37 | Q_OBJECT | 38 | Q_OBJECT | ||
38 | private Q_SLOTS: | 39 | private Q_SLOTS: | ||
40 | | ||||
41 | void init() | ||||
42 | { | ||||
43 | m_tempDir = new QTemporaryDir(); | ||||
44 | m_db = new Database(m_tempDir->path()); | ||||
45 | m_db->open(Database::CreateDatabase); | ||||
46 | m_dbusInterface = new MainHub(m_db, &m_config); | ||||
47 | } | ||||
48 | | ||||
39 | void testFileCreation(); | 49 | void testFileCreation(); | ||
50 | | ||||
51 | void cleanupTestCase() | ||||
52 | { | ||||
53 | delete m_dbusInterface; | ||||
54 | m_dbusInterface = nullptr; | ||||
55 | | ||||
56 | delete m_db; | ||||
57 | m_db = nullptr; | ||||
58 | | ||||
59 | delete m_tempDir; | ||||
60 | m_tempDir = nullptr; | ||||
61 | } | ||||
62 | | ||||
63 | private: | ||||
64 | | ||||
65 | FileIndexerConfig m_config; | ||||
66 | | ||||
67 | Database* m_db; | ||||
68 | | ||||
69 | QTemporaryDir* m_tempDir; | ||||
70 | | ||||
71 | Baloo::MainHub *m_dbusInterface; | ||||
40 | }; | 72 | }; | ||
41 | 73 | | |||
42 | } | 74 | } | ||
43 | 75 | | |||
44 | using namespace Baloo; | 76 | using namespace Baloo; | ||
45 | 77 | | |||
46 | namespace { | 78 | namespace { | ||
47 | bool createFile(const QString& fileUrl) { | 79 | bool createFile(const QString& fileUrl) { | ||
Show All 23 Lines | 96 | { | |||
71 | Test::writeIndexerConfig(includeFolders, excludeFolders); | 103 | Test::writeIndexerConfig(includeFolders, excludeFolders); | ||
72 | 104 | | |||
73 | QTemporaryDir dbDir; | 105 | QTemporaryDir dbDir; | ||
74 | Database db(dbDir.path()); | 106 | Database db(dbDir.path()); | ||
75 | db.open(Baloo::Database::CreateDatabase); | 107 | db.open(Baloo::Database::CreateDatabase); | ||
76 | 108 | | |||
77 | FileIndexerConfig config; | 109 | FileIndexerConfig config; | ||
78 | 110 | | |||
79 | FileWatch fileWatch(&db, &config); | 111 | FileWatch fileWatch(&db, &config, m_dbusInterface); | ||
80 | fileWatch.m_pendingFileQueue->setMaximumTimeout(0); | 112 | fileWatch.m_pendingFileQueue->setMaximumTimeout(0); | ||
81 | fileWatch.m_pendingFileQueue->setMinimumTimeout(0); | 113 | fileWatch.m_pendingFileQueue->setMinimumTimeout(0); | ||
82 | fileWatch.m_pendingFileQueue->setTrackingTime(0); | 114 | fileWatch.m_pendingFileQueue->setTrackingTime(0); | ||
83 | 115 | | |||
84 | QSignalSpy spy(&fileWatch, SIGNAL(installedWatches())); | 116 | QSignalSpy spy(&fileWatch, SIGNAL(installedWatches())); | ||
85 | QVERIFY(spy.isValid()); | 117 | QVERIFY(spy.isValid()); | ||
86 | 118 | | |||
87 | fileWatch.watchIndexedFolders(); | 119 | fileWatch.watchIndexedFolders(); | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |