diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-10-20 12:22:05 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-10-20 12:22:05 +0200 |
commit | bba640d9c189be19d66c6294873b6ab8ffa4efc3 (patch) | |
tree | 2298bad27c1b3fafbd119b83bd9e85fe18c63b8e /tests | |
parent | 06687a7f140678f26d9394b4f0b5a4a41aaab63c (diff) | |
download | qmenumodel-bba640d9c189be19d66c6294873b6ab8ffa4efc3.tar.gz qmenumodel-bba640d9c189be19d66c6294873b6ab8ffa4efc3.tar.bz2 qmenumodel-bba640d9c189be19d66c6294873b6ab8ffa4efc3.zip |
ActionGroupTest: split tests depending on they need the helper script or not
And cleanup units
Diffstat (limited to 'tests')
-rw-r--r-- | tests/client/actiongrouptest.cpp | 101 |
1 files changed, 54 insertions, 47 deletions
diff --git a/tests/client/actiongrouptest.cpp b/tests/client/actiongrouptest.cpp index d187ea7..cc43245 100644 --- a/tests/client/actiongrouptest.cpp +++ b/tests/client/actiongrouptest.cpp @@ -27,26 +27,15 @@ #include <QtTest> #include <QDebug> -class ActionGroupTest : public QObject +class ActionGroupTestBase : public QObject { Q_OBJECT -private: - DBusMenuScript m_script; +protected: QDBusMenuModel m_model; QDBusActionGroup m_actionGroup; -private Q_SLOTS: - void initTestCase() - { - QVERIFY(m_script.connect()); - } - - void cleanupTestCase() - { - m_script.quit(); - } - - void init() +protected Q_SLOTS: + virtual void init() { m_model.stop(); m_model.setBusType(DBusEnums::SessionBus); @@ -59,11 +48,6 @@ private Q_SLOTS: m_actionGroup.setObjectPath(MENU_OBJECT_PATH); } - void cleanup() - { - m_script.unpublishMenu(); - } - /* * Test if the propety busType handle correct integer values */ @@ -88,27 +72,57 @@ private Q_SLOTS: */ void testServiceAppear() { - m_model.start(); - m_actionGroup.start(); QCOMPARE(m_actionGroup.status(), DBusEnums::Connecting); // Make menu available + DBusMenuScript m_script; + m_script.connect(); m_script.publishMenu(); QCOMPARE(m_actionGroup.status(), DBusEnums::Connected); } +}; - /* - * Test if QDBusActionGroup change to correct state after DBus - * service disappear - */ - void testServiceDisappear() +class ActionGroupTestWithScript : public ActionGroupTestBase +{ + Q_OBJECT +private: + DBusMenuScript m_script; + +private Q_SLOTS: + void initTestCase() + { + QVERIFY(m_script.connect()); + } + + void cleanupTestCase() { + m_script.quit(); + } + + void init() + { + ActionGroupTestBase::init(); + + // start model m_model.start(); m_actionGroup.start(); // Make menu available m_script.publishMenu(); + } + + void cleanup() + { + m_script.unpublishMenu(); + } + + /* + * Test if QDBusActionGroup change to correct state after DBus + * service disappear + */ + void testServiceDisappear() + { QCOMPARE(m_actionGroup.status(), DBusEnums::Connected); // Append menus @@ -127,12 +141,7 @@ private Q_SLOTS: */ void testActiveAction() { - // start model - m_model.start(); - m_actionGroup.start(); - - // Make menu available - m_script.publishMenu(); + // Append 2 menus m_script.walk(2); // Get Action @@ -158,12 +167,7 @@ private Q_SLOTS: */ void testRemoveAction() { - // start model - m_model.start(); - m_actionGroup.start(); - - // Make menu available and append 2 menus - m_script.publishMenu(); + // Append 2 menus m_script.walk(2); // Get Action @@ -183,13 +187,6 @@ private Q_SLOTS: */ void testActionIsValid() { - // start model - m_model.start(); - m_actionGroup.start(); - - // Make menu available and append 2 menus - m_script.publishMenu(); - // Get invalid Action QStateAction *act = m_actionGroup.action(QString("Menu1Act")); QVERIFY(act); @@ -204,6 +201,16 @@ private Q_SLOTS: } }; -QTEST_MAIN(ActionGroupTest) +int main(int argc, char *argv[]) +{ + ActionGroupTestBase baseTests; + ActionGroupTestWithScript scriptTests; + + QApplication a(argc, argv); + int baseTestsResults = QTest::qExec(&baseTests); + int scriptTestsResults = QTest::qExec(&scriptTests); + + return std::max(baseTestsResults, scriptTestsResults); +} #include "actiongrouptest.moc" |