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("XDG_DATA_DIRS", (testDataDir() + "/data").toLatin1().data(), 1);
37 void cleanupTestCase()
42 * Test if all plugins is loaded correct
46 IndicatorsManager manager;
48 QVERIFY(!manager.isLoaded());
49 QCOMPARE(manager.indicators().count(), 0);
51 manager.setProfile("test1");
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 testPluginInterfaceProfile1()
68 IndicatorsManager manager;
69 manager.setProfile("test1");
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/test1"));
88 * Test the creation & initialising of the indicator data
90 void testPluginInterfaceProfile2()
92 IndicatorsManager manager;
93 manager.setProfile("test2");
96 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
97 QVERIFY(indicator ? true : false);
99 QCOMPARE(indicator->identifier(), QString("indicator-fake1"));
100 QCOMPARE(indicator->position(), 1);
102 // Check that the initial properties have been set.
103 QVariantMap props = indicator->indicatorProperties().toMap();
104 QCOMPARE(props.count(), 4);
105 QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1"));
106 QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
108 QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test2"));
112 * Test switching the indicator profile data
114 void testPluginInterfaceProfileSwitch()
116 IndicatorsManager manager;
117 manager.setProfile("test1");
120 Indicator::Ptr indicator = manager.indicator("indicator-fake1");
121 QVERIFY(indicator ? true : false);
123 QVariantMap props = indicator->indicatorProperties().toMap();
124 QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test1"));
126 manager.setProfile("test2");
127 props = indicator->indicatorProperties().toMap();
128 QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test2"));
132 * Test if a new plugin object is create for each different plugin
134 void testPluginInstance()
136 IndicatorsManager manager;
137 manager.setProfile("test2");
140 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
141 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
142 QVERIFY(i0?true:false);
143 QVERIFY(i1?true:false);
146 Indicator::Ptr i2 = manager.indicator("indicator-fake2");
147 QVERIFY(i2?true:false);
153 * Test if a new plugin init function is called only once
155 void testPluginInitAndShutdown()
157 IndicatorsManager manager;
158 manager.setProfile("test1");
161 QWeakPointer<Indicator> wp0;
162 QWeakPointer<Indicator> wp1;
164 Indicator::Ptr i0 = manager.indicator("indicator-fake1");
165 wp0 = i0.toWeakRef();
167 Indicator::Ptr i1 = manager.indicator("indicator-fake1");
168 wp1 = i1.toWeakRef();
171 // still alive while we have the shared pointers.
172 QVERIFY(!wp0.isNull());
173 QVERIFY(!wp1.isNull());
176 // no more smart pointers. should have been released.
177 QVERIFY(wp0.isNull());
178 QVERIFY(wp1.isNull());
182QTEST_GUILESS_MAIN(IndicatorsManagerTest)
183#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