Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2018-09-30 15:45:06 +0300
committerJonathan White <droidmonkey@users.noreply.github.com>2018-09-30 16:36:39 +0300
commitc1e9f45df9f21b7697241037643770a2862bb7ef (patch)
treebbb7a840c0199613203d2de90ece7dd47e87038e /tests/TestModified.cpp
parentb40e5686dccfb9f60abc186120e9db17edfa81c0 (diff)
Introduce synchronize merge method
* Create history-based merging that keeps older data in history instead of discarding or deleting it * Extract merge logic into the Merger class * Allows special merge behavior * Improve handling of deletion and changes on groups * Enable basic change tracking while merging * Prevent unintended timestamp changes while merging * Handle differences in timestamp precision * Introduce comparison operators to allow for more sophisticated comparisons (ignore special properties, ...) * Introduce Clock class to handle datetime across the app Merge Strategies: * Default (use inherited/fallback method) * Duplicate (duplicate conflicting nodes, apply all deletions) * KeepLocal (use local values, but apply all deletions) * KeepRemote (use remote values, but apply all deletions) * KeepNewer (merge history only) * Synchronize (merge history, newest value stays on top, apply all deletions)
Diffstat (limited to 'tests/TestModified.cpp')
-rw-r--r--tests/TestModified.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/TestModified.cpp b/tests/TestModified.cpp
index 6e033f25e..b1ad09443 100644
--- a/tests/TestModified.cpp
+++ b/tests/TestModified.cpp
@@ -16,10 +16,12 @@
*/
#include "TestModified.h"
+#include "stub/TestClock.h"
#include <QSignalSpy>
#include <QTest>
+#include "core/Clock.h"
#include "core/Database.h"
#include "core/Group.h"
#include "core/Metadata.h"
@@ -27,11 +29,29 @@
QTEST_GUILESS_MAIN(TestModified)
+namespace
+{
+ TestClock* m_clock = nullptr;
+}
+
void TestModified::initTestCase()
{
QVERIFY(Crypto::init());
}
+void TestModified::init()
+{
+ Q_ASSERT(m_clock == nullptr);
+ m_clock = new TestClock(2010, 5, 5, 10, 30, 10);
+ TestClock::setup(m_clock);
+}
+
+void TestModified::cleanup()
+{
+ TestClock::teardown();
+ m_clock = nullptr;
+}
+
void TestModified::testSignals()
{
int spyCount = 0;
@@ -230,7 +250,7 @@ void TestModified::testEntrySets()
entry->setExpires(entry->timeInfo().expires());
QCOMPARE(spyModified.count(), spyCount);
- entry->setExpiryTime(QDateTime::currentDateTimeUtc().addYears(1));
+ entry->setExpiryTime(Clock::currentDateTimeUtc().addYears(1));
QCOMPARE(spyModified.count(), ++spyCount);
entry->setExpiryTime(entry->timeInfo().expiryTime());
QCOMPARE(spyModified.count(), spyCount);
@@ -300,7 +320,7 @@ void TestModified::testHistoryItems()
QCOMPARE(entry->historyItems().size(), historyItemsSize);
QDateTime modified = entry->timeInfo().lastModificationTime();
- QTest::qSleep(10);
+ m_clock->advanceSecond(10);
entry->beginUpdate();
entry->setTitle("b");
entry->endUpdate();