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 "indicatorsmodel.h"
21#include "indicators.h"
28class IndicatorsModelTest : public QObject
35 setenv("XDG_DATA_DIRS", (testDataDir() + "/data").toLatin1().data(), 1);
38 void cleanupTestCase()
43 * Testa that all the plugins are loaded / unloaded correctly
47 IndicatorsModel model;
48 model.setProfile("test1");
50 QCOMPARE(model.property("count").toInt(), 0);
54 QCOMPARE(model.property("count").toInt(), 4);
58 QCOMPARE(model.property("count").toInt(), 0);
63 * Testa that the plugin data was loaded correctly ( "test1" )
65 void testDataAndOrderProfile1()
67 // Priority order. (2, 1, 4, 3)
68 IndicatorsModel model;
69 model.setProfile("test1");
72 // should be in order:
73 // fake3, fake4, fake1, fake2
75 QCOMPARE(model.data(0, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake3"));
76 QCOMPARE(model.data(0, IndicatorsModelRole::Position).toInt(), 3);
77 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake3"));
78 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake3"));
79 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake3/test1"));
81 QCOMPARE(model.data(1, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake4"));
82 QCOMPARE(model.data(1, IndicatorsModelRole::Position).toInt(), 2);
83 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake4"));
84 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake4"));
85 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake4/test1"));
87 QCOMPARE(model.data(2, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake1"));
88 QCOMPARE(model.data(2, IndicatorsModelRole::Position).toInt(), 1);
89 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake1"));
90 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
91 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test1"));
93 QCOMPARE(model.data(3, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake2"));
94 QCOMPARE(model.data(3, IndicatorsModelRole::Position).toInt(), 0);
95 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake2"));
96 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake2"));
97 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake2/test1"));
101 * Testa that the plugin data was loaded correctly ( "test2" )
103 void testDataAndOrderProfile2()
105 // Priority order. (2, 1, 4, 3)
106 IndicatorsModel model;
107 model.setProfile("test2");
110 // should be in order:
111 // fake3, fake4, fake1, fake2
113 QCOMPARE(model.data(0, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake3"));
114 QCOMPARE(model.data(0, IndicatorsModelRole::Position).toInt(), 3);
115 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake3"));
116 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake3"));
117 QCOMPARE(model.data(0, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake3/test2"));
119 QCOMPARE(model.data(1, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake4"));
120 QCOMPARE(model.data(1, IndicatorsModelRole::Position).toInt(), 2);
121 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake4"));
122 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake4"));
123 QCOMPARE(model.data(1, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake4/test2"));
125 QCOMPARE(model.data(2, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake1"));
126 QCOMPARE(model.data(2, IndicatorsModelRole::Position).toInt(), 1);
127 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake1"));
128 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1"));
129 QCOMPARE(model.data(2, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test2"));
131 QCOMPARE(model.data(3, IndicatorsModelRole::Identifier).toString(), QString("indicator-fake2"));
132 QCOMPARE(model.data(3, IndicatorsModelRole::Position).toInt(), 0);
133 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["busName"].toString(), QString("com.canonical.indicator.fake2"));
134 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake2"));
135 QCOMPARE(model.data(3, IndicatorsModelRole::IndicatorProperties).toMap()["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake2/test2"));
139QTEST_GUILESS_MAIN(IndicatorsModelTest)
141#include "IndicatorsModelTest.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