on xenial help sign in
Mock: Only return categories for scopes that have been active
da16614Albert Astals Cid
tests/mocks/Unity/fake_scope.cpp+6−1
@@ -39,6 +39,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
39 , m_searching(false)
39 , m_searching(false)
40 , m_favorite(favorite)
40 , m_favorite(favorite)
41 , m_isActive(false)
41 , m_isActive(false)
42+ , m_hasBeenActive(false)
42 , m_hasNavigation(true)
43 , m_hasNavigation(true)
43 , m_hasPrimaryFilter(true)
44 , m_hasPrimaryFilter(true)
44 , m_currentNavigationId("root")
45 , m_currentNavigationId("root")
@@ -108,7 +109,7 @@ bool Scope::favorite() const
108
109
109unity::shell::scopes::CategoriesInterface* Scope::categories() const
110unity::shell::scopes::CategoriesInterface* Scope::categories() const
110{
111{
111− return m_categories;
112+ return m_hasBeenActive ? m_categories : nullptr;
112}
113}
113
114
114unity::shell::scopes::SettingsModelInterface* Scope::settings() const
115unity::shell::scopes::SettingsModelInterface* Scope::settings() const
@@ -153,6 +154,10 @@ void Scope::setActive(const bool active)
153 m_isActive = active;
154 m_isActive = active;
154 Q_EMIT isActiveChanged();
155 Q_EMIT isActiveChanged();
155 }
156 }
157+ if (active && !m_hasBeenActive) {
158+ m_hasBeenActive = true;
159+ Q_EMIT categoriesChanged();
160+ }
156}
161}
157
162
158void Scope::setFavorite(const bool favorite)
163void Scope::setFavorite(const bool favorite)
tests/mocks/Unity/fake_scope.h+2−1
@@ -109,13 +109,14 @@ protected:
109 bool m_searching;
109 bool m_searching;
110 bool m_favorite;
110 bool m_favorite;
111 bool m_isActive;
111 bool m_isActive;
112+ bool m_hasBeenActive;
112 bool m_hasNavigation;
113 bool m_hasNavigation;
113 bool m_hasPrimaryFilter;
114 bool m_hasPrimaryFilter;
114 QString m_currentNavigationId;
115 QString m_currentNavigationId;
115
116
116 QString m_previewRendererName;
117 QString m_previewRendererName;
117
118
118− unity::shell::scopes::CategoriesInterface* m_categories;
119+ mutable unity::shell::scopes::CategoriesInterface* m_categories;
119 unity::shell::scopes::ScopeInterface* m_openScope;
120 unity::shell::scopes::ScopeInterface* m_openScope;
120 unity::shell::scopes::SettingsModelInterface* m_settings;
121 unity::shell::scopes::SettingsModelInterface* m_settings;
121 Filters* m_filters;
122 Filters* m_filters;