TestMerge.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 <functional>
  21. class TestMerge : public QObject
  22. {
  23. Q_OBJECT
  24. private slots:
  25. void initTestCase();
  26. void init();
  27. void cleanup();
  28. void testMergeIntoNew();
  29. void testMergeNoChanges();
  30. void testMergeCustomData();
  31. void testResolveConflictNewer();
  32. void testResolveConflictExisting();
  33. void testResolveGroupConflictOlder();
  34. void testMergeNotModified();
  35. void testMergeModified();
  36. void testResolveConflictEntry_Synchronize();
  37. void testResolveConflictEntry_KeepNewer();
  38. void testDeletionConflictEntry_Synchronized();
  39. void testDeletionConflictEntry_KeepNewer();
  40. void testMoveEntry();
  41. void testMoveEntryPreserveChanges();
  42. void testMoveEntryIntoNewGroup();
  43. void testCreateNewGroups();
  44. void testUpdateEntryDifferentLocation();
  45. void testUpdateGroup();
  46. void testUpdateGroupLocation();
  47. void testMergeAndSync();
  48. void testMergeCustomIcons();
  49. void testMergeDuplicateCustomIcons();
  50. void testMetadata();
  51. void testCustomData();
  52. void testDeletedEntry();
  53. void testDeletedGroup();
  54. void testDeletedRevertedEntry();
  55. void testDeletedRevertedGroup();
  56. private:
  57. Database* createTestDatabase();
  58. Database* createTestDatabaseStructureClone(Database* source, int entryFlags, int groupFlags);
  59. void testResolveConflictTemplate(int mergeMode,
  60. std::function<void(Database*, const QMap<const char*, QDateTime>&)> verification);
  61. void testDeletionConflictTemplate(int mergeMode,
  62. std::function<void(Database*, const QMap<QString, QUuid>&)> verification);
  63. static void assertDeletionNewerOnly(Database* db, const QMap<QString, QUuid>& identifiers);
  64. static void assertDeletionLocalOnly(Database* db, const QMap<QString, QUuid>& identifiers);
  65. static void assertUpdateMergedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  66. static void assertUpdateReappliedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  67. static void assertUpdateReappliedEntry1(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  68. static void assertUpdateMergedEntry2(Entry* entry, const QMap<const char*, QDateTime>& timestamps);
  69. };
  70. #endif // KEEPASSX_TESTMERGE_H