on fe71e21 help sign in
unity8/tests/mocks/liblightdm/SessionsModelPrivate.cpp
83 lines 2.5 kB history raw
1/*
2 * Copyright (C) 2015 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 */
17#include "SessionsModel.h"
18#include "SessionsModelPrivate.h"
19#include <QDebug>
20namespace QLightDM
23SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24 : testScenario("singleSession")
25 , q_ptr(parent)
26 , m_availableSessions(
27 {
28 {"ubuntu", "", "Ubuntu", ""},
29 {"ubuntu-2d", "", "Ubuntu 2D", ""},
30 {"gnome", "", "GNOME", ""},
31 {"gnome-classic", "", "GNOME Classic", ""},
32 {"gnome-flashback-compiz", "", "GNOME Flashback (Compiz)", ""},
33 {"gnome-flashback-metacity", "", "GNOME Flashback (Metacity)", ""},
34 {"gnome-wayland", "", "GNOME on Wayland", ""},
35 {"plasma", "", "Plasma", ""},
36 {"kde", "", "KDE" , ""},
37 {"xterm", "", "Recovery Console", ""},
38 {"", "", "Unknown?", ""}
39 })
41 numSessions = numAvailableSessions();
42 resetEntries();
45int SessionsModelPrivate::numAvailableSessions() const
47 return m_availableSessions.length();
50void SessionsModelPrivate::resetEntries()
52 Q_Q(SessionsModel);
54 q->beginResetModel();
55 if (testScenario == "multipleSessions") {
56 resetEntries_multipleSessions(numSessions);
57 } else if (testScenario == "noSessions") {
58 resetEntries_noSessions();
59 } else {
60 resetEntries_singleSession();
61 }
62 q->endResetModel();
65void SessionsModelPrivate::resetEntries_multipleSessions(int numSessions)
67 sessionItems.clear();
68 for (int i = 0; i < numSessions; i++) {
69 sessionItems.append(m_availableSessions.value(i));
70 }
73void SessionsModelPrivate::resetEntries_noSessions()
75 sessionItems = {};
78void SessionsModelPrivate::resetEntries_singleSession()
80 sessionItems = {{"ubuntu", "", "Ubuntu", ""}};
83} // namespace QLightDM