mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-18 04:04:29 -05:00
Clean up gui test.
This commit is contained in:
parent
42773f51a4
commit
ccc8725bb3
@ -32,28 +32,37 @@
|
|||||||
void TestGui::initTestCase()
|
void TestGui::initTestCase()
|
||||||
{
|
{
|
||||||
Crypto::init();
|
Crypto::init();
|
||||||
|
m_mainWindow = new MainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestGui::testOpenDatabase()
|
void TestGui::testOpenDatabase()
|
||||||
{
|
{
|
||||||
MainWindow mainWindow;
|
m_mainWindow->show();
|
||||||
mainWindow.show();
|
QAction* actionDatabaseOpen = m_mainWindow->findChild<QAction*>("actionDatabaseOpen");
|
||||||
QAction* actionDatabaseOpen = mainWindow.findChild<QAction*>("actionDatabaseOpen");
|
|
||||||
fileDialog()->setNextFileName(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"));
|
fileDialog()->setNextFileName(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"));
|
||||||
actionDatabaseOpen->trigger();
|
actionDatabaseOpen->trigger();
|
||||||
|
QWidget* keyDialog = m_mainWindow->findChild<QWidget*>("KeyOpenDialog");
|
||||||
|
QVERIFY(keyDialog);
|
||||||
|
QTest::qWaitForWindowShown(keyDialog);
|
||||||
|
|
||||||
QTest::qWait(500);
|
QLineEdit* editPassword = keyDialog->findChild<QLineEdit*>("editPassword");
|
||||||
|
|
||||||
QLineEdit* editPassword = QApplication::activeWindow()->findChild<QLineEdit*>("editPassword");
|
|
||||||
QVERIFY(editPassword);
|
QVERIFY(editPassword);
|
||||||
QTest::keyClicks(editPassword, "a");
|
QTest::keyClicks(editPassword, "a");
|
||||||
|
|
||||||
QDialogButtonBox* buttonBox = QApplication::activeWindow()->findChild<QDialogButtonBox*>("buttonBox");
|
QDialogButtonBox* buttonBox = keyDialog->findChild<QDialogButtonBox*>("buttonBox");
|
||||||
QTest::mouseClick(buttonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
QTest::mouseClick(buttonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
|
||||||
|
}
|
||||||
|
|
||||||
QTabWidget* tabWidget = mainWindow.findChild<QTabWidget*>("tabWidget");
|
void TestGui::testTabs()
|
||||||
|
{
|
||||||
|
QTabWidget* tabWidget = m_mainWindow->findChild<QTabWidget*>("tabWidget");
|
||||||
QCOMPARE(tabWidget->count(), 1);
|
QCOMPARE(tabWidget->count(), 1);
|
||||||
QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx"));
|
QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestGui::cleanupTestCase()
|
||||||
|
{
|
||||||
|
delete m_mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestGui);
|
QTEST_MAIN(TestGui);
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
class TestGui : public QObject
|
class TestGui : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -27,6 +29,11 @@ class TestGui : public QObject
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void testOpenDatabase();
|
void testOpenDatabase();
|
||||||
|
void testTabs();
|
||||||
|
void cleanupTestCase();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow* m_mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_TESTGUI_H
|
#endif // KEEPASSX_TESTGUI_H
|
||||||
|
Loading…
Reference in New Issue
Block a user