diff --git a/tests/TestAutoType.cpp b/tests/TestAutoType.cpp new file mode 100644 index 000000000..3a5d8d18e --- /dev/null +++ b/tests/TestAutoType.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "TestAutoType.h" + +#include +#include + +#include "tests.h" +#include "core/FilePath.h" +#include "crypto/Crypto.h" +#include "autotype/AutoType.h" +#include "autotype/AutoTypePlatformPlugin.h" +#include "autotype/test/AutoTypeTestInterface.h" + +void TestAutoType::initTestCase() +{ + Crypto::init(); + + AutoType::createTestInstance(); + + QPluginLoader loader(filePath()->pluginPath("keepassx-autotype-test")); + loader.setLoadHints(QLibrary::ResolveAllSymbolsHint); + QVERIFY(loader.instance()); + + m_platform = qobject_cast(loader.instance()); + QVERIFY(m_platform); + + m_test = qobject_cast(loader.instance()); + QVERIFY(m_test); +} + +void TestAutoType::testInternal() +{ + QVERIFY(m_platform->activeWindowTitle().isEmpty()); + + m_test->setActiveWindowTitle("Test"); + QCOMPARE(m_platform->activeWindowTitle(), QString("Test")); +} + +QTEST_GUILESS_MAIN(TestAutoType) diff --git a/tests/TestAutoType.h b/tests/TestAutoType.h new file mode 100644 index 000000000..10f29867a --- /dev/null +++ b/tests/TestAutoType.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef KEEPASSX_TESTAUTOTYPE_H +#define KEEPASSX_TESTAUTOTYPE_H + +#include + +class AutoTypePlatformInterface; +class AutoTypeTestInterface; + +class TestAutoType : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void initTestCase(); + void testInternal(); + +private: + AutoTypePlatformInterface* m_platform; + AutoTypeTestInterface* m_test; +}; + +#endif // KEEPASSX_TESTAUTOTYPE_H