TestGui.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
  3. * Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 2 or (at your option)
  8. * version 3 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef KEEPASSX_TESTGUI_H
  19. #define KEEPASSX_TESTGUI_H
  20. #include "gui/MainWindow.h"
  21. #include "util/TemporaryFile.h"
  22. class Database;
  23. class DatabaseTabWidget;
  24. class DatabaseWidget;
  25. class QAbstractItemView;
  26. class TestGui : public QObject
  27. {
  28. Q_OBJECT
  29. private slots:
  30. void initTestCase();
  31. void init();
  32. void cleanup();
  33. void cleanupTestCase();
  34. void testSettingsDefaultTabOrder();
  35. void testCreateDatabase();
  36. void testMergeDatabase();
  37. void testRemoteSyncDatabaseSameKey();
  38. void testRemoteSyncDatabaseRequiresPassword();
  39. void testOpenRemoteDatabase();
  40. void testAutoreloadDatabase();
  41. void testTabs();
  42. void testEditEntry();
  43. void testSearchEditEntry();
  44. void testAddEntry();
  45. void testPasswordEntryEntropy();
  46. void testPasswordEntryEntropy_data();
  47. void testDicewareEntryEntropy();
  48. void testTotp();
  49. void testSearch();
  50. void testDeleteEntry();
  51. void testCloneEntry();
  52. void testEntryPlaceholders();
  53. void testDragAndDropEntry();
  54. void testDragAndDropGroup();
  55. void testSaveAs();
  56. void testSaveBackup();
  57. void testSave();
  58. void testSaveBackupPath();
  59. void testSaveBackupPath_data();
  60. void testDatabaseSettings();
  61. void testDatabaseLocking();
  62. void testDragAndDropKdbxFiles();
  63. void testSortGroups();
  64. void testAutoType();
  65. void testTrayRestoreHide();
  66. void testShortcutConfig();
  67. void testMenuActionStates();
  68. private:
  69. void addCannedEntries();
  70. void checkDatabase(const QString& filePath, const QString& expectedDbName);
  71. void checkDatabase(const QString& filePath = {});
  72. void triggerAction(const QString& name);
  73. void dragAndDropGroup(const QModelIndex& sourceIndex,
  74. const QModelIndex& targetIndex,
  75. int row,
  76. bool expectedResult,
  77. const QString& expectedParentName,
  78. int expectedPos);
  79. void clickIndex(const QModelIndex& index,
  80. QAbstractItemView* view,
  81. Qt::MouseButton button,
  82. Qt::KeyboardModifiers stateKey = {});
  83. void checkSaveDatabase();
  84. void checkStatusBarText(const QString& textFragment);
  85. void prepareAndTriggerRemoteSync(const QString& sourceToSync);
  86. QScopedPointer<MainWindow> m_mainWindow;
  87. QPointer<QLabel> m_statusBarLabel;
  88. QPointer<DatabaseTabWidget> m_tabWidget;
  89. QPointer<DatabaseWidget> m_dbWidget;
  90. QSharedPointer<Database> m_db;
  91. TemporaryFile m_dbFile;
  92. QString m_dbFileName;
  93. QString m_dbFilePath;
  94. };
  95. #endif // KEEPASSX_TESTGUI_H