on xenial help sign in
Mock: Only return categories for scopes that have been active

Makes the tests faster, it's also more close to what the real plugin does (the real plugin preloads also the active+1 but we don't really need that)

commitda166144c18f1d7d5d57ebb973e40ce9781aa781 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 6 Jun 2016, 16:45 (10 years ago) parent7fdbae9
2 files changed+8−2
tests/mocks/Unity/fake_scope.cpp+6−1 tests/mocks/Unity/fake_scope.h+2−1
tests/mocks/Unity/fake_scope.cpp+6−1
@@ -39,6 +39,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
3939 , m_searching(false)
4040 , m_favorite(favorite)
4141 , m_isActive(false)
42+ , m_hasBeenActive(false)
4243 , m_hasNavigation(true)
4344 , m_hasPrimaryFilter(true)
4445 , m_currentNavigationId("root")
@@ -108,7 +109,7 @@ bool Scope::favorite() const
108109
109110unity::shell::scopes::CategoriesInterface* Scope::categories() const
110111{
111− return m_categories;
112+ return m_hasBeenActive ? m_categories : nullptr;
112113}
113114
114115unity::shell::scopes::SettingsModelInterface* Scope::settings() const
@@ -153,6 +154,10 @@ void Scope::setActive(const bool active)
153154 m_isActive = active;
154155 Q_EMIT isActiveChanged();
155156 }
157+ if (active && !m_hasBeenActive) {
158+ m_hasBeenActive = true;
159+ Q_EMIT categoriesChanged();
160+ }
156161}
157162
158163void Scope::setFavorite(const bool favorite)
tests/mocks/Unity/fake_scope.h+2−1
@@ -109,13 +109,14 @@ protected:
109109 bool m_searching;
110110 bool m_favorite;
111111 bool m_isActive;
112+ bool m_hasBeenActive;
112113 bool m_hasNavigation;
113114 bool m_hasPrimaryFilter;
114115 QString m_currentNavigationId;
115116
116117 QString m_previewRendererName;
117118
118− unity::shell::scopes::CategoriesInterface* m_categories;
119+ mutable unity::shell::scopes::CategoriesInterface* m_categories;
119120 unity::shell::scopes::ScopeInterface* m_openScope;
120121 unity::shell::scopes::SettingsModelInterface* m_settings;
121122 Filters* m_filters;