Clean up gui test.

This commit is contained in:
Florian Geyer 2011-12-29 20:10:19 +01:00
parent 42773f51a4
commit ccc8725bb3
2 changed files with 24 additions and 8 deletions

View File

@ -32,28 +32,37 @@
void TestGui::initTestCase()
{
Crypto::init();
m_mainWindow = new MainWindow();
}
void TestGui::testOpenDatabase()
{
MainWindow mainWindow;
mainWindow.show();
QAction* actionDatabaseOpen = mainWindow.findChild<QAction*>("actionDatabaseOpen");
m_mainWindow->show();
QAction* actionDatabaseOpen = m_mainWindow->findChild<QAction*>("actionDatabaseOpen");
fileDialog()->setNextFileName(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx"));
actionDatabaseOpen->trigger();
QWidget* keyDialog = m_mainWindow->findChild<QWidget*>("KeyOpenDialog");
QVERIFY(keyDialog);
QTest::qWaitForWindowShown(keyDialog);
QTest::qWait(500);
QLineEdit* editPassword = QApplication::activeWindow()->findChild<QLineEdit*>("editPassword");
QLineEdit* editPassword = keyDialog->findChild<QLineEdit*>("editPassword");
QVERIFY(editPassword);
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);
}
QTabWidget* tabWidget = mainWindow.findChild<QTabWidget*>("tabWidget");
void TestGui::testTabs()
{
QTabWidget* tabWidget = m_mainWindow->findChild<QTabWidget*>("tabWidget");
QCOMPARE(tabWidget->count(), 1);
QCOMPARE(tabWidget->tabText(tabWidget->currentIndex()), QString("NewDatabase.kdbx"));
}
void TestGui::cleanupTestCase()
{
delete m_mainWindow;
}
QTEST_MAIN(TestGui);

View File

@ -20,6 +20,8 @@
#include <QtCore/QObject>
class MainWindow;
class TestGui : public QObject
{
Q_OBJECT
@ -27,6 +29,11 @@ class TestGui : public QObject
private Q_SLOTS:
void initTestCase();
void testOpenDatabase();
void testTabs();
void cleanupTestCase();
private:
MainWindow* m_mainWindow;
};
#endif // KEEPASSX_TESTGUI_H