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"
26class IndicatorsManagerTest : public QObject
33 setenv("UNITY_TEST_ENV", "1", 1);
34 setenv("XDG_DATA_DIRS", (sourceDirectory() + "/tests/data").toLatin1().data(), 1);
37 void cleanupTestCase()
39 unsetenv("UNITY_TEST_ENV");
43 * Test if all plugins is loaded correct
47 IndicatorsManager manager;
49 QVERIFY(!manager.isLoaded());
50 QCOMPARE(manager.indicators().count(), 0);
54 QVERIFY(manager.isLoaded());
55 QCOMPARE(manager.indicators().count(), 4);
59 QVERIFY(!manager.isLoaded());
60 QCOMPARE(manager.indicators().count(), 0);
64 * Test the creation & initialising of the indicator data
66 void testPluginInterface()
68 IndicatorsManager manager;
71 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
72 QVERIFY(indicator ? true : false);
74 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
75 QCOMPARE(indicator->position(), 1);
77 // Check that the initial properties have been set.
78 QVariantMap props = indicator->indicatorProperties().toMap();
79 QCOMPARE(props.count(), 4);
80 QCOMPARE(props["busType"].toInt(), 1);
81 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
82 QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
84 QVariantMap objectPaths = props["menuObjectPaths"].toMap();
85 QCOMPARE(objectPaths["phone"].toString(), QString("/com/canonical/indicator/fake1/phone"));
86 QCOMPARE(objectPaths["desktop"].toString(), QString("/com/canonical/indicator/fake1/desktop"));
90 * Test if a new plugin object is create for each different plugin
92 void testPluginInstance()
94 IndicatorsManager manager;
97 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
98 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
99 QVERIFY(i0?true:false);
100 QVERIFY(i1?true:false);
103 Indicator::Ptr i2 = manager.indicator("indicator-fake2");
104 QVERIFY(i2?true:false);
110 * Test if a new plugin init function is called only once
112 void testPluginInitAndShutdown()
114 IndicatorsManager manager;
117 QWeakPointer<Indicator> wp0;
118 QWeakPointer<Indicator> wp1;
120 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
121 wp0 = i0.toWeakRef();
123 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
124 wp1 = i1.toWeakRef();
127 // still alive while we have the shared pointers.
128 QVERIFY(!wp0.isNull());
129 QVERIFY(!wp1.isNull());
132 // no more smart pointers. should have been released.
133 QVERIFY(wp0.isNull());
134 QVERIFY(wp1.isNull());
138QTEST_GUILESS_MAIN(IndicatorsManagerTest)
139#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