~dandrader/unity8/childWindows

« back to all changes in this revision

Viewing changes to tests/mocks/liblightdm/MockController.h

  • Committer: Bileto Bot
  • Author(s): Michael Terry
  • Date: 2017-01-24 07:39:14 UTC
  • mfrom: (2743.4.8 simple-lightdm-mock)
  • Revision ID: ci-train-bot@canonical.com-20170124073914-imw1y4dae2ivqqtb
Simplify the lightdm mock to make future greeter improvements easier to test.

I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.

And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)

Approved by: Albert Astals Cid, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
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 General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#pragma once
 
18
 
 
19
#include <QObject>
 
20
#include <QString>
 
21
 
 
22
 
 
23
namespace QLightDM
 
24
{
 
25
class Q_DECL_EXPORT MockController : public QObject
 
26
{
 
27
    Q_OBJECT
 
28
 
 
29
    Q_PROPERTY(QString selectUserHint READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
 
30
 
 
31
    // single, single-pin, single-passphrase, full
 
32
    Q_PROPERTY(QString userMode READ userMode WRITE setUserMode NOTIFY userModeChanged)
 
33
 
 
34
    // single, none, full
 
35
    Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
 
36
 
 
37
    Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
 
38
    Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
 
39
 
 
40
public:
 
41
    static MockController *instance();
 
42
    virtual ~MockController();
 
43
 
 
44
    QString selectUserHint() const;
 
45
    void setSelectUserHint(const QString &selectUserHint);
 
46
 
 
47
    QString userMode() const;
 
48
    void setUserMode(const QString &userMode);
 
49
 
 
50
    QString sessionMode() const;
 
51
    void setSessionMode(const QString &sessionMode);
 
52
 
 
53
    class SessionItem
 
54
    {
 
55
    public:
 
56
        QString key;
 
57
        QString name;
 
58
    };
 
59
    int numFullSessions() const;
 
60
    const QList<SessionItem> &fullSessionItems() const;
 
61
 
 
62
    int numSessions() const;
 
63
    void setNumSessions(int numSessions);
 
64
 
 
65
Q_SIGNALS:
 
66
    void selectUserHintChanged();
 
67
    void userModeChanged();
 
68
    void sessionModeChanged();
 
69
    void numSessionsChanged();
 
70
 
 
71
private:
 
72
    explicit MockController(QObject* parent=0);
 
73
 
 
74
    QString m_selectUserHint;
 
75
    QString m_userMode;
 
76
    QString m_sessionMode;
 
77
    QList<SessionItem> m_fullSessions;
 
78
    int m_numSessions;
 
79
};
 
80
}