forked from qt-creator/qt-creator
Clang: Add timer based path notification compression
QFileWatcher is only reporting one path per signal which is suboptimal if you change many files at once. This patch is introducing a timer which is waiting some time time to see if more path changes are reported and is collecting them in a vector. Change-Id: I50f7c21186353b199634e7b3cd5a41f8d581a31d Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "googletest.h"
|
||||
|
||||
#include "faketimer.h"
|
||||
#include "mockqfilesystemwatcher.h"
|
||||
#include "mockclangpathwatchernotifier.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ using testing::IsEmpty;
|
||||
using testing::SizeIs;
|
||||
using testing::NiceMock;
|
||||
|
||||
using Watcher = ClangBackEnd::ClangPathWatcher<NiceMock<MockQFileSytemWatcher>>;
|
||||
using Watcher = ClangBackEnd::ClangPathWatcher<NiceMock<MockQFileSytemWatcher>, FakeTimer>;
|
||||
using ClangBackEnd::WatcherEntry;
|
||||
|
||||
class ClangPathWatcher : public testing::Test
|
||||
@@ -310,4 +311,14 @@ TEST_F(ClangPathWatcher, NotifyFileChange)
|
||||
mockQFileSytemWatcher.fileChanged(path1.toQString());
|
||||
}
|
||||
|
||||
TEST_F(ClangPathWatcher, TwoNotifyFileChanges)
|
||||
{
|
||||
watcher.addEntries({watcherEntry1, watcherEntry2, watcherEntry3, watcherEntry4, watcherEntry5});
|
||||
|
||||
EXPECT_CALL(notifier, pathsWithIdsChanged(ElementsAre(id2, id3, id1)));
|
||||
|
||||
mockQFileSytemWatcher.fileChanged(path2.toQString());
|
||||
mockQFileSytemWatcher.fileChanged(path1.toQString());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user