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/MirSurfaceInterface.h>
28#include "MirSurfaceListModel.h"
32class MirSurface : public unity::shell::application::MirSurfaceInterface
37 // for use in qml tests
38 Q_PROPERTY(int width READ width NOTIFY widthChanged)
39 Q_PROPERTY(int height READ height NOTIFY heightChanged)
40 Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
41 Q_PROPERTY(bool slowToResize READ isSlowToResize WRITE setSlowToResize NOTIFY slowToResizeChanged)
42 Q_PROPERTY(bool exposed READ exposed NOTIFY exposedChanged)
45 MirSurface(const QString& name,
48 const QUrl& screenshot,
49 const QUrl &qmlFilePath = QUrl());
50 virtual ~MirSurface();
53 // unity.shell.application.MirSurface
55 Mir::Type type() const override;
57 QString name() const override;
59 QString persistentId() const override;
61 QPoint position() const override { return m_position; }
63 QSize size() const override { return QSize(width(),height()); }
64 void resize(int width, int height) override;
65 void resize(const QSize &size) override { resize(size.width(), size.height()); }
68 Mir::State state() const override;
70 bool live() const override;
72 bool visible() const override;
74 Mir::OrientationAngle orientationAngle() const override;
75 void setOrientationAngle(Mir::OrientationAngle) override;
77 int minimumWidth() const override { return m_minimumWidth; }
78 int minimumHeight() const override { return m_minimumHeight; }
79 int maximumWidth() const override { return m_maximumWidth; }
80 int maximumHeight() const override { return m_maximumHeight; }
81 int widthIncrement() const override { return m_widthIncrement; }
82 int heightIncrement() const override { return m_heightIncrement; }
84 void setKeymap(const QString &) override;
85 QString keymap() const override;
87 Mir::ShellChrome shellChrome() const override;
89 bool focused() const override;
90 QRect inputBounds() const override;
92 bool confinesMousePointer() const override { return false; }
94 QPoint requestedPosition() const override { return m_requestedPosition; }
95 void setRequestedPosition(const QPoint &) override;
97 Q_INVOKABLE void close() override;
98 Q_INVOKABLE void activate() override;
103 Q_INVOKABLE void requestFocus();
104 Q_INVOKABLE void setLive(bool live);
105 Q_INVOKABLE void setShellChrome(Mir::ShellChrome shellChrome);
110 bool isSlowToResize() const;
111 void setSlowToResize(bool value);
113 bool exposed() const { return m_exposed; }
115 Q_INVOKABLE void setMinimumWidth(int);
116 Q_INVOKABLE void setMaximumWidth(int);
117 Q_INVOKABLE void setMinimumHeight(int);
118 Q_INVOKABLE void setMaximumHeight(int);
119 Q_INVOKABLE void setWidthIncrement(int);
120 Q_INVOKABLE void setHeightIncrement(int);
122 Q_INVOKABLE virtual void setInputBounds(const QRect &boundsRect);
125 // internal mock stuff
127 QUrl qmlFilePath() const;
129 QUrl screenshotUrl() const;
130 void setScreenshotUrl(QUrl);
132 bool activeFocus() const;
133 void setActiveFocus(bool);
135 void registerView(qintptr viewId);
136 void unregisterView(qintptr viewId);
137 void setViewExposure(qintptr viewId, bool visible);
138 int viewCount() const { return m_views.count(); }
140 void setFocused(bool value);
142 void setState(Mir::State state);
144 Mir::State previousState() const { return m_previousState; }
145 void setPreviousState(Mir::State state) { m_previousState = state; }
149 // unity.shell.application.MirSurface
150 void requestState(Mir::State) override;
156 void heightChanged();
157 void slowToResizeChanged();
158 void exposedChanged(bool exposed);
161 // internal mock stuff
162 void screenshotUrlChanged(QUrl);
163 void activeFocusChanged(bool);
164 void closeRequested();
165 void stateRequested(Mir::State);
168 virtual void updateInputBoundsAfterResize();
171 void applyDelayedResize();
174 void doResize(int width, int height);
175 void updateExposure();
177 const QString m_name;
178 const Mir::Type m_type;
180 Mir::State m_previousState{Mir::UnknownState};
181 Mir::OrientationAngle m_orientationAngle;
183 QUrl m_screenshotUrl;
191 int m_minimumWidth{0};
192 int m_minimumHeight{0};
193 int m_maximumWidth{0};
194 int m_maximumHeight{0};
195 int m_widthIncrement{0};
196 int m_heightIncrement{0};
201 QTimer m_delayedResizeTimer;
202 QSize m_delayedResize;
203 QSize m_pendingResize;
205 Mir::ShellChrome m_shellChrome;
210 QHash<qintptr, View> m_views;
211 bool m_exposed{false};
213 QTimer m_zombieTimer;
218 QPoint m_requestedPosition;
221#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