on xenial help sign in
Better fake plugin
6509027Albert Astals
tests/mocks/Unity/fake_scopes.cpp+1−1
@@ -47,7 +47,7 @@ void Scopes::updateScopes()
47 addScope(new Scope("MockScope2", "Music", false, this));
47 addScope(new Scope("MockScope2", "Music", false, this));
48 addScope(new Scope("clickscope", "Apps", true, this));
48 addScope(new Scope("clickscope", "Apps", true, this));
49 addScope(new Scope("MockScope5", "Videos", true, this));
49 addScope(new Scope("MockScope5", "Videos", true, this));
50− addScope(new ScopesOverview());
50+ addScope(new ScopesOverview(this));
51
51
52 if (!m_loaded) {
52 if (!m_loaded) {
53 m_loaded = true;
53 m_loaded = true;
tests/mocks/Unity/fake_scopesoverview.cpp+4−4
@@ -24,11 +24,12 @@ ScopesOverview::ScopesOverview(Scopes* parent)
24 : Scope("scopesOverview", "Scopes Overview", false, parent)
24 : Scope("scopesOverview", "Scopes Overview", false, parent)
25{
25{
26 delete m_categories;
26 delete m_categories;
27− m_categories = new ScopesOverviewCategories(this);
27+ m_categories = new ScopesOverviewCategories(parent, this);
28}
28}
29
29
30−ScopesOverviewCategories::ScopesOverviewCategories(QObject* parent)
30+ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
31 : unity::shell::scopes::CategoriesInterface(parent)
31 : unity::shell::scopes::CategoriesInterface(parent)
32+ , m_scopes(scopes)
32{
33{
33}
34}
34
35
@@ -54,11 +55,10 @@ ScopesOverviewCategories::data(const QModelIndex& index, int role) const
54 return QVariant();
55 return QVariant();
55 }
56 }
56
57
57− return QVariant();
58 unity::shell::scopes::ResultsModelInterface *resultsModel = m_resultsModels[index.row()];
58 unity::shell::scopes::ResultsModelInterface *resultsModel = m_resultsModels[index.row()];
59 if (!resultsModel) {
59 if (!resultsModel) {
60 QObject *that = const_cast<ScopesOverviewCategories*>(this);
60 QObject *that = const_cast<ScopesOverviewCategories*>(this);
61− resultsModel = new ScopesOverviewResultsModel(static_cast<Scopes*>(parent()), index.row() == 0, that);
61+ resultsModel = new ScopesOverviewResultsModel(m_scopes, index.row() == 0, that);
62 m_resultsModels[index.row()] = resultsModel;
62 m_resultsModels[index.row()] = resultsModel;
63 }
63 }
64 switch (role) {
64 switch (role) {
tests/mocks/Unity/fake_scopesoverview.h+3−1
@@ -35,7 +35,7 @@ class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterfac
35 Q_OBJECT
35 Q_OBJECT
36
36
37public:
37public:
38− ScopesOverviewCategories(QObject* parent = 0);
38+ ScopesOverviewCategories(Scopes *scopes, QObject* parent = 0);
39
39
40 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
40 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
41 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
41 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -45,6 +45,8 @@ public:
45
45
46private:
46private:
47 mutable QHash<int, unity::shell::scopes::ResultsModelInterface*> m_resultsModels;
47 mutable QHash<int, unity::shell::scopes::ResultsModelInterface*> m_resultsModels;
48+
49+ Scopes *m_scopes;
48};
50};
49
51
50class ScopesOverviewResultsModel : public unity::shell::scopes::ResultsModelInterface
52class ScopesOverviewResultsModel : public unity::shell::scopes::ResultsModelInterface