on 42301fa help sign in
unity8/tests/mocks/Unity/fake_scope.h
114 lines 4.3 kB history raw
1/*
2 * Copyright (C) 2013, 2014 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 */
17#ifndef FAKE_SCOPE_H
18#define FAKE_SCOPE_H
20#include <unity/shell/scopes/ScopeInterface.h>
22#include "fake_categories.h"
23#include "fake_previewmodel.h"
25#include <QTimer>
27class Scopes;
29class Scope : public unity::shell::scopes::ScopeInterface
31 Q_OBJECT
33public:
34 Scope(Scopes* parent = 0);
35 Scope(QString const& id, QString const& name, bool favorite, Scopes* parent = 0, int categories = 20, bool returnNullPreview = false);
37 /* getters */
38 QString id() const override;
39 QString name() const override;
40 QString iconHint() const override;
41 QString description() const override;
42 QString searchHint() const override;
43 QString shortcut() const override;
44 bool searchInProgress() const override;
45 bool activationInProgress() const override;
46 bool favorite() const override;
47 unity::shell::scopes::CategoriesInterface* categories() const override;
48 QString searchQuery() const override;
49 QString noResultsHint() const override;
50 QString formFactor() const override;
51 bool isActive() const override;
52 unity::shell::scopes::SettingsModelInterface* settings() const override;
54 /* setters */
55 void setSearchQuery(const QString& search_query) override;
56 void setNoResultsHint(const QString& hint) override;
57 void setFormFactor(const QString& form_factor) override;
58 void setActive(const bool) override;
59 void setFavorite(const bool) override;
60 Q_INVOKABLE void setId(const QString &id); // This is not invokable in the Interface, here for testing benefits
61 Q_INVOKABLE void setName(const QString &name); // This is not invokable in the Interface, here for testing benefits
62 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
64 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
65 Q_INVOKABLE PreviewModel* preview(QVariant const& result, QString const& categoryId) override;
66 Q_INVOKABLE void cancelActivation() override;
67 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
69 QString currentNavigationId() const override;
70 bool hasNavigation() const override;
71 QString currentAltNavigationId() const override;
72 bool hasAltNavigation() const override;
73 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) override;
74 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) override;
75 Q_INVOKABLE void setNavigationState(const QString &navigationId, bool isAltNavigation) override;
76 void performQuery(const QString& query) override;
78 Status status() const override;
79 QVariantMap customizations() const override;
81 Q_INVOKABLE void refresh() override;
83 Q_INVOKABLE virtual void activateAction(QVariant const& result, QString const& categoryId, QString const& actionId) override;
85Q_SIGNALS:
86 // These are not in the Interface, here for testing benefits
87 void refreshed();
88 void queryPerformed(const QString& query);
90protected:
92 QString m_id;
93 QString m_iconHint;
94 QString m_description;
95 QString m_name;
96 QString m_searchQuery;
97 QString m_noResultsHint;
98 QString m_formFactor;
99 bool m_searching;
100 bool m_favorite;
101 bool m_isActive;
102 QString m_currentNavigationId;
103 QString m_currentAltNavigationId;
105 QString m_previewRendererName;
107 unity::shell::scopes::CategoriesInterface* m_categories;
108 unity::shell::scopes::ScopeInterface* m_openScope;
109 unity::shell::scopes::SettingsModelInterface* m_settings;
111 bool m_returnNullPreview;
112};
114#endif // FAKE_SCOPE_H