on xenial help sign in
Allow for tests to decide if they want navigation/primaryFilter
commit4bea1cd8d6f044acdf8ea37a7a7abb35528ab0d7 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 13 Oct 2015, 14:45 (11 years ago) parentb91f49a
2 files changed+18−2
tests/mocks/Unity/fake_scope.cpp+14−2 tests/mocks/Unity/fake_scope.h+4
tests/mocks/Unity/fake_scope.cpp+14−2
@@ -39,6 +39,8 @@ 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_hasNavigation(true)
43+ , m_hasPrimaryFilter(true)
4244 , m_currentNavigationId("root")
4345 , m_previewRendererName("preview-generic")
4446 , m_categories(new Categories(categories, this))
@@ -227,7 +229,12 @@ QString Scope::currentNavigationId() const
227229
228230bool Scope::hasNavigation() const
229231{
230− return true;
232+ return m_hasNavigation;
233+}
234+
235+void Scope::setHasNavigation(bool hasNavigation)
236+{
237+ m_hasNavigation = hasNavigation;
231238}
232239
233240Scope::Status Scope::status() const
@@ -290,7 +297,7 @@ void Scope::setNavigationState(const QString &navigationId)
290297
291298unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
292299{
293− return m_primaryNavigationFilter;
300+ return m_hasPrimaryFilter ? m_primaryNavigationFilter : nullptr;
294301}
295302
296303unity::shell::scopes::FiltersInterface* Scope::filters() const
@@ -319,6 +326,11 @@ void Scope::resetPrimaryNavigationTag()
319326 }
320327}
321328
329+void Scope::setHasPrimaryFilter(bool hasPrimaryFilter)
330+{
331+ m_hasPrimaryFilter = hasPrimaryFilter;
332+}
333+
322334void Scope::performQuery(const QString& query)
323335{
324336 Q_EMIT queryPerformed(query);
tests/mocks/Unity/fake_scope.h+4
@@ -70,12 +70,14 @@ public:
7070 bool hasNavigation() const override;
7171 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) override;
7272 Q_INVOKABLE void setNavigationState(const QString &navigationId) override;
73+ Q_INVOKABLE void setHasNavigation(bool hasNavigation); // This is not invokable in the Interface, here for testing benefits
7374
7475 unity::shell::scopes::FilterBaseInterface* primaryNavigationFilter() const override;
7576 unity::shell::scopes::FiltersInterface* filters() const override;
7677 QString primaryNavigationTag() const override;
7778 int activeFiltersCount() const override;
7879 Q_INVOKABLE void resetPrimaryNavigationTag() override;
80+ Q_INVOKABLE void setHasPrimaryFilter(bool hasPrimaryFilter); // This is not invokable in the Interface, here for testing benefits
7981
8082 void performQuery(const QString& query) override;
8183
@@ -101,6 +103,8 @@ protected:
101103 bool m_searching;
102104 bool m_favorite;
103105 bool m_isActive;
106+ bool m_hasNavigation;
107+ bool m_hasPrimaryFilter;
104108 QString m_currentNavigationId;
105109
106110 QString m_previewRendererName;