~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-2605

« back to all changes in this revision

Viewing changes to tests/mocks/Ubuntu/SystemSettings/Update/plugin.cpp

  • Committer: Bileto Bot
  • Author(s): Ken VanDine
  • Date: 2017-03-17 14:41:33 UTC
  • mfrom: (1764.2.19 no_updates)
  • Revision ID: ci-train-bot@canonical.com-20170317144133-rv0zqeiuhsyhk9nh
Drop everything that needs system-image or click

Approved by: system-apps-ci-bot

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) 2016 Canonical Ltd.
5
 
 *
6
 
 * This program is free software: you can redistribute it and/or modify it
7
 
 * under the terms of the GNU General Public License version 3, as published
8
 
 * by the Free Software Foundation.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful, but
11
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
12
 
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
 
 * PURPOSE.  See the GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License along
16
 
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
#include "plugin.h"
20
 
 
21
 
#include "update.h"
22
 
#include "utils.h"
23
 
 
24
 
#include "MockUpdateManager.h"
25
 
#include "MockUpdateModel.h"
26
 
#include "MockSystemImage.h"
27
 
 
28
 
#include <QtQml>
29
 
 
30
 
static QObject *siSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
31
 
{
32
 
    Q_UNUSED(engine)
33
 
    Q_UNUSED(scriptEngine)
34
 
    return new MockSystemImage;
35
 
}
36
 
 
37
 
static QObject *umSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
38
 
{
39
 
    Q_UNUSED(engine)
40
 
    Q_UNUSED(scriptEngine)
41
 
    return new MockUpdateManager;
42
 
}
43
 
 
44
 
void BackendPlugin::registerTypes(const char *uri)
45
 
{
46
 
    Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Update"));
47
 
    qmlRegisterSingletonType<MockUpdateManager>(uri, 1, 0, "UpdateManager", umSingletonProvider);
48
 
    qmlRegisterUncreatableType<Update>(uri, 1, 0, "Update", "Used for enums only.");
49
 
    qmlRegisterSingletonType<MockSystemImage>(uri, 1, 0, "SystemImage", siSingletonProvider);
50
 
    qRegisterMetaType<MockUpdateModel*>("UpdateModel*");
51
 
    qRegisterMetaType<MockUpdateModelFilter*>("UpdateModelFilter*");
52
 
}
53
 
 
54
 
void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
55
 
{
56
 
    QQmlExtensionPlugin::initializeEngine(engine, uri);
57
 
    QQmlContext* context = engine->rootContext();
58
 
    auto utils = new SystemSettings::Utilities;
59
 
    context->setContextProperty("Utilities", utils);
60
 
    context->setContextProperty("showAllUI", true);
61
 
    context->setContextProperty("pluginOptions", QVariantMap());
62
 
}