on xenial help sign in
Revert a lot of mess
8913729Josh Arenson
tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt+1−1
@@ -23,7 +23,7 @@ set(QMLPLUGIN_SRC
23 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
25 MockGreeter.cpp
25 MockGreeter.cpp
26− MockSessionsModel.cpp
26+ MockSessionsModel.h
27 MockUsersModel.cpp
27 MockUsersModel.cpp
28 plugin.cpp
28 plugin.cpp
29 )
29 )
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cppdeleted−38
@@ -1,38 +0,0 @@
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− *
16− */
17−
18−#include "MockSessionsModel.h"
19−#include <QLightDM/SessionsModel>
20−#include <QSortFilterProxyModel>
21−
22−QString MockSessionsModel::testScenario() const
23−{
24− QLightDM::SessionsModel* qSessionsModel =
25− static_cast<QLightDM::SessionsModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
26−
27− return qSessionsModel->testScenario();
28−}
29−
30−void MockSessionsModel::setTestScenario(QString testScenario)
31−{
32− QLightDM::SessionsModel* qSessionsModel =
33− static_cast<QLightDM::SessionsModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
34−
35− if (qSessionsModel->testScenario() != testScenario) {
36− qSessionsModel->setTestScenario(testScenario);
37− }
38−}
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h+4−8
@@ -19,19 +19,15 @@
19#define MOCK_UNITY_SESSIONSMODEL_H
19#define MOCK_UNITY_SESSIONSMODEL_H
20
20
21#include <SessionsModel.h>
21#include <SessionsModel.h>
22+#include <QLightDM/SessionsModel>
22
23
24+// A wrapper class to preserve naming conventions, thus
25+// enhancing code readability
23class MockSessionsModel : public SessionsModel
26class MockSessionsModel : public SessionsModel
24{
27{
25 Q_OBJECT
28 Q_OBJECT
26
29
27− Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario)
30+ using SessionsModel::SessionsModel;
28−
29−public:
30− QString testScenario() const;
31− void setTestScenario(QString testScenario);
32−
33−private:
34− QString m_testScenario;
35};
31};
36
32
37#endif // MOCK_UNITY_SESSIONSMODEL_H
33#endif // MOCK_UNITY_SESSIONSMODEL_H
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp−16
@@ -79,20 +79,4 @@ int SessionsModel::rowCount(const QModelIndex& parent) const
79 }
79 }
80}
80}
81
81
82−QString SessionsModel::testScenario() const
83−{
84− Q_D(const SessionsModel);
85− return d->testScenario;
86−}
87−
88−void SessionsModel::setTestScenario(QString testScenario)
89−{
90− Q_D(SessionsModel);
91−
92− if (d->testScenario != testScenario) {
93− d->testScenario = testScenario;
94− d->resetEntries();
95− }
96−}
97−
98} // namespace QLightDM
82} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h−3
@@ -54,9 +54,6 @@ class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
54 int rowCount(const QModelIndex& parent) const override;
54 int rowCount(const QModelIndex& parent) const override;
55 QVariant data(const QModelIndex& index, int role) const override;
55 QVariant data(const QModelIndex& index, int role) const override;
56
56
57− QString testScenario() const;
58− void setTestScenario(QString testScenario);
59−
60 protected:
57 protected:
61 SessionsModelPrivate* const d_ptr;
58 SessionsModelPrivate* const d_ptr;
62
59
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+8−30
@@ -21,8 +21,7 @@ namespace QLightDM
21{
21{
22
22
23SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
23SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24− : testScenario("multipleSessions")
25− , q_ptr(parent)
24+ : q_ptr(parent)
26{
25{
27 resetEntries();
26 resetEntries();
28}
27}
@@ -32,35 +31,14 @@ void SessionsModelPrivate::resetEntries()
32 Q_Q(SessionsModel);
31 Q_Q(SessionsModel);
33
32
34 q->beginResetModel();
33 q->beginResetModel();
35− if(testScenario == "multipleSessions") {
34+ sessionItems =
36− resetEntries_multipleSessions();
35+ {
37− } else if (testScenario == "singleSessions") {
36+ {"", "", "Ubuntu", ""},
38− resetEntries_singleSession();
37+ {"", "", "GNOME", ""},
39− } else {
38+ {"", "", "Plasma", ""},
40− resetEntries_noSessions();
39+ {"", "", "Unknown?", ""}
41− }
40+ };
42 q->endResetModel();
41 q->endResetModel();
43}
42}
44
43
45−void SessionsModelPrivate::resetEntries_multipleSessions()
46−{
47− sessionItems =
48− {
49− {"", "", "Ubuntu", ""},
50− {"", "", "GNOME", ""},
51− {"", "", "Plasma", ""},
52− {"", "", "Unknown?", ""}
53− };
54−}
55−
56−void SessionsModelPrivate::resetEntries_noSessions()
57−{
58− sessionItems = {};
59−}
60−
61−void SessionsModelPrivate::resetEntries_singleSession()
62−{
63− sessionItems = {{"", "", "Ubuntu", ""}};
64−}
65−
66} // namespace QLightDM
44} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h−1
@@ -41,7 +41,6 @@ public:
41 virtual ~SessionsModelPrivate() = default;
41 virtual ~SessionsModelPrivate() = default;
42
42
43 QList<SessionItem> sessionItems;
43 QList<SessionItem> sessionItems;
44− QString testScenario;
45
44
46 void resetEntries();
45 void resetEntries();
47protected:
46protected: