2 * Copyright (C) 2015-2016 Canonical, Ltd.
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.
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.
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/>.
17#ifndef MOCK_MIR_SURFACE_H
18#define MOCK_MIR_SURFACE_H
26#include <unity/shell/application/MirFocusControllerInterface.h>
27#include <unity/shell/application/MirSurfaceInterface.h>
29#include "MirSurfaceListModel.h"
33class MirFocusController : public unity::shell::application::MirFocusControllerInterface
38 virtual ~MirFocusController();
39 static MirFocusController* instance();
41 void setFocusedSurface(unity::shell::application::MirSurfaceInterface *surface) override;
42 unity::shell::application::MirSurfaceInterface* focusedSurface() const override { return m_focusedSurface; }
43 unity::shell::application::MirSurfaceInterface* previouslyFocusedSurface() { return m_previouslyFocusedSurface; }
46 static MirFocusController *m_instance;
47 unity::shell::application::MirSurfaceInterface* m_previouslyFocusedSurface{nullptr};
48 unity::shell::application::MirSurfaceInterface* m_focusedSurface{nullptr};
51class MirSurface : public unity::shell::application::MirSurfaceInterface
56 // for use in qml tests
57 Q_PROPERTY(int width READ width NOTIFY widthChanged)
58 Q_PROPERTY(int height READ height NOTIFY heightChanged)
59 Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
60 Q_PROPERTY(bool slowToResize READ isSlowToResize WRITE setSlowToResize NOTIFY slowToResizeChanged)
63 MirSurface(const QString& name,
66 const QUrl& screenshot,
67 const QUrl &qmlFilePath = QUrl());
68 virtual ~MirSurface();
71 // unity.shell.application.MirSurface
73 Mir::Type type() const override;
75 QString name() const override;
77 QSize size() const override { return QSize(width(),height()); }
78 void resize(int width, int height) override;
79 void resize(const QSize &size) override { resize(size.width(), size.height()); }
82 Mir::State state() const override;
83 Q_INVOKABLE void setState(Mir::State) override;
85 bool live() const override;
87 bool visible() const override;
89 Mir::OrientationAngle orientationAngle() const override;
90 void setOrientationAngle(Mir::OrientationAngle) override;
92 int minimumWidth() const override { return m_minimumWidth; }
93 int minimumHeight() const override { return m_minimumHeight; }
94 int maximumWidth() const override { return m_maximumWidth; }
95 int maximumHeight() const override { return m_maximumHeight; }
96 int widthIncrement() const override { return m_widthIncrement; }
97 int heightIncrement() const override { return m_heightIncrement; }
99 virtual void setKeymap(const QString &);
100 virtual QString keymap() const;
102 Mir::ShellChrome shellChrome() const override;
104 bool focused() const override;
106 Q_INVOKABLE void requestFocus() override;
108 Q_INVOKABLE void close() override;
110 unity::shell::application::MirSurfaceListInterface* promptSurfaceList() override;
112 Q_INVOKABLE void raise() override;
117 Q_INVOKABLE void setLive(bool live);
118 Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
123 bool isSlowToResize() const;
124 void setSlowToResize(bool value);
126 Q_INVOKABLE void setMinimumWidth(int);
127 Q_INVOKABLE void setMaximumWidth(int);
128 Q_INVOKABLE void setMinimumHeight(int);
129 Q_INVOKABLE void setMaximumHeight(int);
130 Q_INVOKABLE void setWidthIncrement(int);
131 Q_INVOKABLE void setHeightIncrement(int);
133 Q_INVOKABLE void createPromptSurface();
136 // internal mock stuff
138 QUrl qmlFilePath() const;
140 QUrl screenshotUrl() const;
141 void setScreenshotUrl(QUrl);
143 bool activeFocus() const;
144 void setActiveFocus(bool);
146 void registerView(qintptr viewId);
147 void unregisterView(qintptr viewId);
148 void setViewVisibility(qintptr viewId, bool visible);
149 int viewCount() const { return m_views.count(); }
151 void setFocused(bool value);
157 void heightChanged();
158 void slowToResizeChanged();
161 // internal mock stuff
162 void screenshotUrlChanged(QUrl);
163 void activeFocusChanged(bool);
164 void raiseRequested();
165 void closeRequested();
168 void applyDelayedResize();
171 void doResize(int width, int height);
172 void updateVisibility();
174 const QString m_name;
175 const Mir::Type m_type;
177 Mir::OrientationAngle m_orientationAngle;
179 QUrl m_screenshotUrl;
187 int m_minimumWidth{0};
188 int m_minimumHeight{0};
189 int m_maximumWidth{0};
190 int m_maximumHeight{0};
191 int m_widthIncrement{0};
192 int m_heightIncrement{0};
197 QTimer m_delayedResizeTimer;
198 QSize m_delayedResize;
199 QSize m_pendingResize;
201 Mir::ShellChrome m_shellChrome;
202 MirSurfaceListModel m_promptSurfaceList;
207 QHash<qintptr, View> m_views;
209 QTimer m_zombieTimer;
212#endif // MOCK_MIR_SURFACE_H
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list