mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 23:39:45 -05:00
Adding tests for modified signal on merge.
This commit is contained in:
parent
d7f5a15f68
commit
b1d481893e
@ -23,6 +23,8 @@
|
||||
#include "core/Metadata.h"
|
||||
#include "crypto/Crypto.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
|
||||
QTEST_GUILESS_MAIN(TestMerge)
|
||||
|
||||
namespace
|
||||
@ -1355,6 +1357,37 @@ void TestMerge::testResolveGroupConflictOlder()
|
||||
QVERIFY(groupDestinationMerged != nullptr);
|
||||
}
|
||||
|
||||
void TestMerge::testMergeNotModified()
|
||||
{
|
||||
QScopedPointer<Database> dbDestination(createTestDatabase());
|
||||
QScopedPointer<Database> dbSource(
|
||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||
|
||||
QSignalSpy modifiedSignalSpy(dbDestination.data(), SIGNAL(modified()));
|
||||
Merger merger(dbSource.data(), dbDestination.data());
|
||||
merger.merge();
|
||||
QVERIFY(modifiedSignalSpy.empty());
|
||||
}
|
||||
|
||||
void TestMerge::testMergeModified()
|
||||
{
|
||||
QScopedPointer<Database> dbDestination(createTestDatabase());
|
||||
QScopedPointer<Database> dbSource(
|
||||
createTestDatabaseStructureClone(dbDestination.data(), Entry::CloneNoFlags, Group::CloneIncludeEntries));
|
||||
|
||||
QSignalSpy modifiedSignalSpy(dbDestination.data(), SIGNAL(modified()));
|
||||
// Make sure the two changes have a different timestamp.
|
||||
QTest::qSleep(1);
|
||||
Entry* entry = dbSource->rootGroup()->findEntryByPath("entry1");
|
||||
entry->beginUpdate();
|
||||
entry->setTitle("new title");
|
||||
entry->endUpdate();
|
||||
|
||||
Merger merger(dbSource.data(), dbDestination.data());
|
||||
merger.merge();
|
||||
QVERIFY(!modifiedSignalSpy.empty());
|
||||
}
|
||||
|
||||
Database* TestMerge::createTestDatabase()
|
||||
{
|
||||
Database* db = new Database();
|
||||
|
@ -36,6 +36,8 @@ private slots:
|
||||
void testResolveConflictNewer();
|
||||
void testResolveConflictExisting();
|
||||
void testResolveGroupConflictOlder();
|
||||
void testMergeNotModified();
|
||||
void testMergeModified();
|
||||
void testResolveConflictDuplicate();
|
||||
void testResolveConflictEntry_Synchronize();
|
||||
void testResolveConflictEntry_KeepLocal();
|
||||
|
Loading…
Reference in New Issue
Block a user