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:
Marco Bubke
2017-01-31 11:14:54 +01:00
parent 9678c09355
commit 2c55a9c569
12 changed files with 426 additions and 51 deletions

View File

@@ -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());
}
}