2 * Copyright 2012 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
20#include "indicatorsmanager.h"
27class IndicatorsManagerTest : public QObject
34 setenv("UNITY_TEST_ENV", "1", 1);
35 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
38 void cleanupTestCase()
40 unsetenv("UNITY_TEST_ENV");
44 * Test if all plugins is loaded correct
48 IndicatorsManager manager;
50 QVERIFY(!manager.isLoaded());
51 QCOMPARE(manager.indicators().count(), 0);
55 QVERIFY(manager.isLoaded());
56 QCOMPARE(manager.indicators().count(), 4);
60 QVERIFY(!manager.isLoaded());
61 QCOMPARE(manager.indicators().count(), 0);
65 * Test the creation & initialising of the indicator data
67 void testPluginInterface()
69 IndicatorsManager manager;
72 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
73 QVERIFY(indicator ? true : false);
75 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
76 QCOMPARE(indicator->position(), 1);
78 // Check that the initial properties have been set.
79 QVariantMap props = indicator->indicatorProperties().toMap();
80 QCOMPARE(props.count(), 4);
81 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
82 QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
84 QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/phone"));
88 * Test if a new plugin object is create for each different plugin
90 void testPluginInstance()
92 IndicatorsManager manager;
95 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
96 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
97 QVERIFY(i0?true:false);
98 QVERIFY(i1?true:false);
101 Indicator::Ptr i2 = manager.indicator("indicator-fake2");
102 QVERIFY(i2?true:false);
108 * Test if a new plugin init function is called only once
110 void testPluginInitAndShutdown()
112 IndicatorsManager manager;
115 QWeakPointer<Indicator> wp0;
116 QWeakPointer<Indicator> wp1;
118 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
119 wp0 = i0.toWeakRef();
121 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
122 wp1 = i1.toWeakRef();
125 // still alive while we have the shared pointers.
126 QVERIFY(!wp0.isNull());
127 QVERIFY(!wp1.isNull());
130 // no more smart pointers. should have been released.
131 QVERIFY(wp0.isNull());
132 QVERIFY(wp1.isNull());
136QTEST_GUILESS_MAIN(IndicatorsManagerTest)
137#include "indicatorsmanagertest.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list