~laney/ubuntu-system-settings/battery-charge-graph

« back to all changes in this revision

Viewing changes to lib/tests/tst_plugins.cpp

  • Committer: Alberto Mardegan
  • Date: 2013-05-08 08:55:54 UTC
  • Revision ID: alberto.mardegan@canonical.com-20130508085554-jjcanw47dt26e5li
Change directory structure: add libSystemSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2013 Canonical Ltd.
 
5
 *
 
6
 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it
 
9
 * under the terms of the GNU General Public License version 3, as published
 
10
 * by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
 * PURPOSE.  See the GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along
 
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#include "plugin-manager.h"
 
22
#include "plugin.h"
 
23
 
 
24
#include <QDebug>
 
25
#include <QObject>
 
26
#include <QSignalSpy>
 
27
#include <QTest>
 
28
 
 
29
using namespace SystemSettings;
 
30
 
 
31
class PluginsTest: public QObject
 
32
{
 
33
    Q_OBJECT
 
34
 
 
35
public:
 
36
    PluginsTest() {};
 
37
 
 
38
private Q_SLOTS:
 
39
    void testCategory();
 
40
};
 
41
 
 
42
void PluginsTest::testCategory()
 
43
{
 
44
    PluginManager manager;
 
45
 
 
46
    QSet<QString> expectedCategories;
 
47
    expectedCategories << "phone" << "network";
 
48
    QCOMPARE(manager.categories().toSet(), expectedCategories);
 
49
 
 
50
    QList<Plugin *> plugins = manager.plugins("phone");
 
51
    QCOMPARE(plugins.count(), 1);
 
52
    QCOMPARE(plugins[0]->displayName(), QString("Cellular"));
 
53
 
 
54
    plugins = manager.plugins("network");
 
55
    QCOMPARE(plugins.count(), 2);
 
56
    QStringList names;
 
57
    Q_FOREACH(Plugin *plugin, plugins) {
 
58
        names << plugin->displayName();
 
59
    }
 
60
    QSet<QString> expectedNames;
 
61
    expectedNames << "Bluetooth" << "Wireless";
 
62
    QCOMPARE(names.toSet(), expectedNames);
 
63
}
 
64
 
 
65
QTEST_MAIN(PluginsTest);
 
66
#include "tst_plugins.moc"