on 6ca9421 help sign in
113 lines 2.9 kB history raw
1/*
2 * Copyright (C) 2015 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 MOCK_MIR_SURFACE_H
18#define MOCK_MIR_SURFACE_H
20#include <QObject>
21#include <QUrl>
23// unity-api
24#include <unity/shell/application/MirSurfaceInterface.h>
26class MirSurface : public unity::shell::application::MirSurfaceInterface
28 Q_OBJECT
30 ////
31 // for use in qml tests
32 Q_PROPERTY(int width READ width NOTIFY widthChanged)
33 Q_PROPERTY(int height READ height NOTIFY heightChanged)
34 Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
36public:
37 MirSurface(const QString& name,
38 Mir::Type type,
39 Mir::State state,
40 const QUrl& screenshot,
41 const QUrl &qmlFilePath = QUrl());
42 virtual ~MirSurface();
44 ////
45 // unity.shell.application.MirSurface
47 Mir::Type type() const override;
49 QString name() const override;
51 QSize size() const override { return QSize(width(),height()); }
52 void resize(int width, int height) override;
53 void resize(const QSize &size) override { resize(size.width(), size.height()); }
56 Mir::State state() const override;
57 Q_INVOKABLE void setState(Mir::State) override;
59 bool live() const override;
61 Mir::OrientationAngle orientationAngle() const override;
62 void setOrientationAngle(Mir::OrientationAngle) override;
64 ////
65 // API for tests
67 Q_INVOKABLE void setLive(bool live);
69 void incrementViewCount();
70 void decrementViewCount();
71 int viewCount() const;
73 int width() const;
74 int height() const;
76 /////
77 // internal mock stuff
79 QUrl qmlFilePath() const;
81 QUrl screenshotUrl() const;
82 void setScreenshotUrl(QUrl);
84 bool activeFocus() const;
85 void setActiveFocus(bool);
87Q_SIGNALS:
88 void stateChanged(Mir::State);
89 void liveChanged(bool live);
90 void orientationAngleChanged(Mir::OrientationAngle angle);
91 void widthChanged();
92 void heightChanged();
94 ////
95 // internal mock stuff
96 void screenshotUrlChanged(QUrl);
97 void activeFocusChanged(bool);
99private:
100 const QString m_name;
101 const Mir::Type m_type;
102 Mir::State m_state;
103 Mir::OrientationAngle m_orientationAngle;
104 QUrl m_screenshotUrl;
105 QUrl m_qmlFilePath;
106 bool m_live;
107 int m_viewCount;
108 bool m_activeFocus;
109 int m_width;
110 int m_height;
111};
113#endif // MOCK_MIR_SURFACE_H