More auto-type tests.

This commit is contained in:
Florian Geyer 2012-11-02 15:07:44 +01:00
parent 848abfc1a7
commit 8347fd36ba
4 changed files with 46 additions and 1 deletions

View File

@ -34,6 +34,7 @@ AutoType* AutoType::m_instance = Q_NULLPTR;
AutoType::AutoType(QObject* parent, bool test)
: QObject(parent)
, m_test(test)
, m_inAutoType(false)
, m_pluginLoader(new QPluginLoader(this))
, m_plugin(Q_NULLPTR)
@ -132,7 +133,9 @@ void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow, const QS
hideWindow->showMinimized();
}
Tools::wait(500);
if (!m_test) {
Tools::wait(500);
}
if (!window) {
window = m_plugin->activeWindow();

View File

@ -69,6 +69,7 @@ private:
QString autoTypeSequence(const Entry* entry, const QString& windowTitle = QString());
bool windowMatches(const QString& windowTitle, const QString& windowPattern);
bool m_test;
bool m_inAutoType;
Qt::Key m_currentGlobalKey;
Qt::KeyboardModifiers m_currentGlobalModifiers;

View File

@ -52,13 +52,20 @@ void TestAutoType::init()
{
m_test->clearActions();
m_db = new Database();
m_group = new Group();
m_db->setRootGroup(m_group);
m_entry = new Entry();
m_entry->setGroup(m_group);
m_entry->setUsername("myuser");
m_entry->setPassword("mypass");
}
void TestAutoType::cleanup()
{
delete m_db;
}
void TestAutoType::testInternal()
{
QVERIFY(m_platform->activeWindowTitle().isEmpty());
@ -89,4 +96,32 @@ void TestAutoType::testAutoTypeWithSequence()
.arg(m_entry->password()));
}
void TestAutoType::testGlobalAutoTypeWithNoMatch()
{
QList<Database*> dbList;
dbList.append(m_db);
m_autoType->performGlobalAutoType(dbList);
QCOMPARE(m_test->actionChars(), QString());
}
void TestAutoType::testGlobalAutoTypeWithOneMatch()
{
QList<Database*> dbList;
dbList.append(m_db);
AutoTypeAssociations::Association association;
association.window = "custom window";
association.sequence = "{username}association{password}";
m_entry->autoTypeAssociations()->add(association);
m_test->setActiveWindowTitle("custom window");
m_autoType->performGlobalAutoType(dbList);
QCOMPARE(m_test->actionChars(),
QString("%1association%2")
.arg(m_entry->username())
.arg(m_entry->password()));
}
QTEST_GUILESS_MAIN(TestAutoType)

View File

@ -23,6 +23,7 @@
class AutoType;
class AutoTypePlatformInterface;
class AutoTypeTestInterface;
class Database;
class Entry;
class Group;
@ -33,14 +34,19 @@ class TestAutoType : public QObject
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testInternal();
void testAutoTypeWithoutSequence();
void testAutoTypeWithSequence();
void testGlobalAutoTypeWithNoMatch();
void testGlobalAutoTypeWithOneMatch();
private:
AutoTypePlatformInterface* m_platform;
AutoTypeTestInterface* m_test;
AutoType* m_autoType;
Database* m_db;
Group* m_group;
Entry* m_entry;
};