mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-24 14:48:48 -04:00
Adding tests for modified signal on merge.
This commit is contained in:
parent
d7f5a15f68
commit
b1d481893e
2 changed files with 35 additions and 0 deletions
|
@ -23,6 +23,8 @@
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
|
|
||||||
|
#include <QSignalSpy>
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(TestMerge)
|
QTEST_GUILESS_MAIN(TestMerge)
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -1355,6 +1357,37 @@ void TestMerge::testResolveGroupConflictOlder()
|
||||||
QVERIFY(groupDestinationMerged != nullptr);
|
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* TestMerge::createTestDatabase()
|
||||||
{
|
{
|
||||||
Database* db = new Database();
|
Database* db = new Database();
|
||||||
|
|
|
@ -36,6 +36,8 @@ private slots:
|
||||||
void testResolveConflictNewer();
|
void testResolveConflictNewer();
|
||||||
void testResolveConflictExisting();
|
void testResolveConflictExisting();
|
||||||
void testResolveGroupConflictOlder();
|
void testResolveGroupConflictOlder();
|
||||||
|
void testMergeNotModified();
|
||||||
|
void testMergeModified();
|
||||||
void testResolveConflictDuplicate();
|
void testResolveConflictDuplicate();
|
||||||
void testResolveConflictEntry_Synchronize();
|
void testResolveConflictEntry_Synchronize();
|
||||||
void testResolveConflictEntry_KeepLocal();
|
void testResolveConflictEntry_KeepLocal();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue