on xenial help sign in
Revert a lot of mess
commit891372964ec421f84d03d299072cb26acc49d19e authorJosh Arenson <joshua.arenson@canonical.com> dateWed 18 Nov 2015, 14:57 (11 years ago) parentfcec91e
7 files changed+13−97
tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt+1−1 tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp−38 tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h+4−8 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp−16 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h−3 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+8−30 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h−1
tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt+1−1
@@ -23,7 +23,7 @@ set(QMLPLUGIN_SRC
2323 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
2424 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
2525 MockGreeter.cpp
26− MockSessionsModel.cpp
26+ MockSessionsModel.h
2727 MockUsersModel.cpp
2828 plugin.cpp
2929 )
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 @@
1919#define MOCK_UNITY_SESSIONSMODEL_H
2020
2121#include <SessionsModel.h>
22+#include <QLightDM/SessionsModel>
2223
24+// A wrapper class to preserve naming conventions, thus
25+// enhancing code readability
2326class MockSessionsModel : public SessionsModel
2427{
2528 Q_OBJECT
2629
27− Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario)
28−
29−public:
30− QString testScenario() const;
31− void setTestScenario(QString testScenario);
32−
33−private:
34− QString m_testScenario;
30+ using SessionsModel::SessionsModel;
3531};
3632
3733#endif // MOCK_UNITY_SESSIONSMODEL_H
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp−16
@@ -79,20 +79,4 @@ int SessionsModel::rowCount(const QModelIndex& parent) const
7979 }
8080}
8181
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−
9882} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h−3
@@ -54,9 +54,6 @@ class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
5454 int rowCount(const QModelIndex& parent) const override;
5555 QVariant data(const QModelIndex& index, int role) const override;
5656
57− QString testScenario() const;
58− void setTestScenario(QString testScenario);
59−
6057 protected:
6158 SessionsModelPrivate* const d_ptr;
6259
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+8−30
@@ -21,8 +21,7 @@ namespace QLightDM
2121{
2222
2323SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24− : testScenario("multipleSessions")
25− , q_ptr(parent)
24+ : q_ptr(parent)
2625{
2726 resetEntries();
2827}
@@ -32,35 +31,14 @@ void SessionsModelPrivate::resetEntries()
3231 Q_Q(SessionsModel);
3332
3433 q->beginResetModel();
35− if(testScenario == "multipleSessions") {
36− resetEntries_multipleSessions();
37− } else if (testScenario == "singleSessions") {
38− resetEntries_singleSession();
39− } else {
40− resetEntries_noSessions();
41− }
34+ sessionItems =
35+ {
36+ {"", "", "Ubuntu", ""},
37+ {"", "", "GNOME", ""},
38+ {"", "", "Plasma", ""},
39+ {"", "", "Unknown?", ""}
40+ };
4241 q->endResetModel();
4342}
4443
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−
6644} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h−1
@@ -41,7 +41,6 @@ public:
4141 virtual ~SessionsModelPrivate() = default;
4242
4343 QList<SessionItem> sessionItems;
44− QString testScenario;
4544
4645 void resetEntries();
4746protected: