TestMerge.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 or (at your option)
  7. * version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef KEEPASSX_TESTMERGE_H
  18. #define KEEPASSX_TESTMERGE_H
  19. #include "core/Database.h"
  20. #include <QDateTime>
  21. #include <QMap>
  22. #include <QObject>
  23. #include <functional>
  24. class TestMerge : public QObject
  25. {
  26. Q_OBJECT
  27. private slots:
  28. void initTestCase();
  29. void init();
  30. void cleanup();
  31. void testMergeIntoNew();
  32. void testMergeNoChanges();
  33. void testResolveConflictNewer();
  34. void testResolveConflictExisting();
  35. void testResolveGroupConflictOlder();
  36. void testMergeNotModified();
  37. void testMergeModified();
  38. void testResolveConflictDuplicate();
  39. void testResolveConflictEntry_Synchronize();
  40. void testResolveConflictEntry_KeepLocal();
  41. void testResolveConflictEntry_KeepRemote();
  42. void testResolveConflictEntry_KeepNewer();
  43. void testDeletionConflictEntry_Duplicate();
  44. void testDeletionConflictEntry_Synchronized();
  45. void testDeletionConflictEntry_KeepLocal();
  46. void testDeletionConflictEntry_KeepRemote();
  47. void testDeletionConflictEntry_KeepNewer();
  48. void testMoveEntry();
  49. void testMoveEntryPreserveChanges();
  50. void testMoveEntryIntoNewGroup();
  51. void testCreateNewGroups();
  52. void testUpdateEntryDifferentLocation();
  53. void testUpdateGroup();
  54. void testUpdateGroupLocation();
  55. void testMergeAndSync();
  56. void testMergeCustomIcons();
  57. void testMergeDuplicateCustomIcons();
  58. void testMetadata();
  59. void testCustomData();
  60. void testDeletedEntry();
  61. void testDeletedGroup();
  62. void testDeletedRevertedEntry();
  63. void testDeletedRevertedGroup();
  64. private:
  65. Database* createTestDatabase();
  66. Database* createTestDatabaseStructureClone(Database* source, int entryFlags, int groupFlags);
  67. void testResolveConflictTemplate(int mergeMode,
  68. std::function<void(Database*, const QMap<const char*, QDateTime>&)> verification);
  69. void testDeletionConflictTemplate(int mergeMode,
  70. std::function<void(Database*, const QMap<QString, QUuid>&)> verification);
  71. static void assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers);
  72. static void assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers);
  73. static void assertUpdateMergedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  74. static void assertUpdateReappliedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  75. static void assertUpdateReappliedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  76. static void assertUpdateMergedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  77. };
  78. #endif // KEEPASSX_TESTMERGE_H