Adding tests for modified signal on merge.

This commit is contained in:
louis 2018-11-04 15:59:13 -05:00 committed by Jonathan White
parent d7f5a15f68
commit b1d481893e
2 changed files with 35 additions and 0 deletions

View File

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

View File

@ -36,6 +36,8 @@ private slots:
void testResolveConflictNewer();
void testResolveConflictExisting();
void testResolveGroupConflictOlder();
void testMergeNotModified();
void testMergeModified();
void testResolveConflictDuplicate();
void testResolveConflictEntry_Synchronize();
void testResolveConflictEntry_KeepLocal();