on xenial help sign in
removed screen mock
commit53626b89e64350009205aab57b99d0344ae447bd authorNick Dedekind <nick.dedekind@canonical.com> dateFri 17 Feb 2017, 17:33 (10 years ago) parent14f1570
9 files changed−438
tests/mocks/Unity/CMakeLists.txt−1 tests/mocks/Unity/Screens/CMakeLists.txt−15 tests/mocks/Unity/Screens/plugin.cpp−42 tests/mocks/Unity/Screens/plugin.h−25 tests/mocks/Unity/Screens/qmldir−2 tests/mocks/Unity/Screens/screens.cpp−114 tests/mocks/Unity/Screens/screens.h−162 tests/mocks/Unity/Screens/screenwindow.cpp−35 tests/mocks/Unity/Screens/screenwindow.h−42
tests/mocks/Unity/CMakeLists.txt−1
@@ -6,7 +6,6 @@ add_subdirectory(InputInfo)
66add_subdirectory(Launcher)
77add_subdirectory(Notifications)
88add_subdirectory(DashCommunicator)
9−add_subdirectory(Screens)
109add_subdirectory(Platform)
1110
1211pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
tests/mocks/Unity/Screens/CMakeLists.txtdeleted−15
@@ -1,15 +0,0 @@
1−include_directories(
2− ${CMAKE_CURRENT_SOURCE_DIR}
3−)
4−
5−set(MockScreens_SOURCES
6− plugin.cpp
7− screens.cpp
8− screenwindow.cpp
9−)
10−
11−add_library(MockScreensPlugin MODULE ${MockScreens_SOURCES})
12−
13−qt5_use_modules(MockScreensPlugin Gui Qml Quick)
14−
15−add_unity8_mock(Unity.Screens 0.1 Unity/Screens PREFIX mocks TARGETS MockScreensPlugin)
tests/mocks/Unity/Screens/plugin.cppdeleted−42
@@ -1,42 +0,0 @@
1−/*
2− * Copyright (C) 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "plugin.h"
18−#include "screens.h"
19−#include "screenwindow.h"
20−
21−#include <QScreen>
22−
23−namespace {
24−QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25− Q_UNUSED(engine);
26− Q_UNUSED(scriptEngine);
27− return new Screens();
28−}
29−}
30−
31−void UnityScreensPlugin::registerTypes(const char* uri)
32−{
33− Q_ASSERT(QLatin1String(uri) == QLatin1String("Unity.Screens"));
34−
35− qRegisterMetaType<QScreen*>("QScreen*");
36− qRegisterMetaType<ScreenMode*>("ScreenMode*");
37− qmlRegisterUncreatableType<ScreenMode>(uri, 0, 1, "ScreenMode", "ScreenMode is not creatable.");
38−
39− qmlRegisterSingletonType<Screens>(uri, 0, 1, "Screens", screensSingleton);
40− qmlRegisterType<ScreenWindow>(uri, 0, 1, "ScreenWindow");
41− qmlRegisterRevision<QWindow,1>(uri, 0, 1);
42−}
tests/mocks/Unity/Screens/plugin.hdeleted−25
@@ -1,25 +0,0 @@
1−/*
2− * Copyright (C) 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include <QQmlExtensionPlugin>
18−#include <QtQml/qqml.h>
19−
20−class UnityScreensPlugin : public QQmlExtensionPlugin {
21− Q_OBJECT
22− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
23−public:
24− void registerTypes(const char* uri) override;
25−};
tests/mocks/Unity/Screens/qmldirdeleted−2
@@ -1,2 +0,0 @@
1−module Unity.Screens
2−plugin MockScreensPlugin
tests/mocks/Unity/Screens/screens.cppdeleted−114
@@ -1,114 +0,0 @@
1−/*
2− * Copyright (C) 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "screens.h"
18−
19−// Qt
20−#include <QGuiApplication>
21−#include <QDebug>
22−
23−Screens::Screens(QObject *parent) :
24− QAbstractListModel(parent)
25−{
26− bool ok = false;
27− int screenCount = qEnvironmentVariableIntValue("UNITY_MOCK_SCREEN_COUNT", &ok);
28− if (!ok) screenCount = 1;
29− QPoint lastPoint(0,0);
30− for (int i = 0; i < screenCount; ++i) {
31− auto screen = new Screen();
32− screen->m_active = i == 0;
33− screen->m_name = QString("Monitor %1").arg(i);
34− screen->m_position = QPoint(lastPoint.x(), lastPoint.y());
35− screen->m_sizes.append(new ScreenMode(50, QSize(640,480)));
36− screen->m_sizes.append(new ScreenMode(60, QSize(1280,1024)));
37− screen->m_sizes.append(new ScreenMode(60, QSize(1440,900)));
38− screen->m_sizes.append(new ScreenMode(60, QSize(1920,1080)));
39− screen->m_currentModeIndex = 3;
40− screen->m_physicalSize = QSize(300,200);
41− m_screenList.append(screen);
42−
43− lastPoint.rx() += screen->m_sizes[screen->m_currentModeIndex]->size.width();
44− }
45−}
46−
47−Screens::~Screens() noexcept
48−{
49− qDeleteAll(m_screenList);
50− m_screenList.clear();
51−}
52−
53−QHash<int, QByteArray> Screens::roleNames() const
54−{
55− QHash<int, QByteArray> roles;
56− roles[ScreenRole] = "screen";
57− return roles;
58−}
59−
60−QVariant Screens::data(const QModelIndex &index, int role) const
61−{
62− if (!index.isValid() || index.row() >= m_screenList.size()) {
63− return QVariant();
64− }
65−
66− switch(role) {
67− case ScreenRole:
68− return QVariant::fromValue(m_screenList.at(index.row()));
69− }
70−
71− return QVariant();
72−}
73−
74−int Screens::rowCount(const QModelIndex &) const
75−{
76− return count();
77−}
78−
79−int Screens::count() const
80−{
81− return m_screenList.size();
82−}
83−
84−void Screens::activateScreen(int)
85−{
86− qWarning("Not Implemented");
87−}
88−
89−Screen::Screen(QObject* parent)
90− : QObject(parent)
91−{
92−}
93−
94−Screen::~Screen()
95−{
96− qDeleteAll(m_sizes);
97− m_sizes.clear();
98−}
99−
100−QQmlListProperty<ScreenMode> Screen::availableModes()
101−{
102− return QQmlListProperty<ScreenMode>(this, m_sizes);
103−}
104−
105−Screen *Screen::beginConfiguration()
106−{
107− qWarning("Not Implemented");
108− return nullptr;
109−}
110−
111−void Screen::applyConfiguration()
112−{
113− qWarning("Not Implemented");
114−}
tests/mocks/Unity/Screens/screens.hdeleted−162
@@ -1,162 +0,0 @@
1−/*
2− * Copyright (C) 2015 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef SCREENS_H
18−#define SCREENS_H
19−
20−#include <QAbstractListModel>
21−#include <QScreen>
22−#include <QQmlListProperty>
23−
24−class Screen;
25−
26−class Screens : public QAbstractListModel
27−{
28− Q_OBJECT
29−
30− Q_PROPERTY(int count READ count NOTIFY countChanged)
31−
32−public:
33− enum ItemRoles {
34− ScreenRole = Qt::UserRole + 1,
35− OutputTypeRole,
36− EnabledRole,
37− NameRole,
38− ScaleRole,
39− FormFactorRole,
40− GeometryRole,
41− SizesRole
42− };
43−
44− enum OutputTypes {
45− Unknown,
46− VGA,
47− DVII,
48− DVID,
49− DVIA,
50− Composite,
51− SVideo,
52− LVDS,
53− Component,
54− NinePinDIN,
55− DisplayPort,
56− HDMIA,
57− HDMIB,
58− TV,
59− EDP
60− };
61− Q_ENUM(OutputTypes)
62−
63− enum FormFactor {
64− FormFactorUnknown,
65− FormFactorPhone,
66− FormFactorTablet,
67− FormFactorMonitor,
68− FormFactorTV,
69− FormFactorProjector,
70− };
71−
72− explicit Screens(QObject *parent = 0);
73− virtual ~Screens() noexcept;
74−
75− /* QAbstractItemModel */
76− QHash<int, QByteArray> roleNames() const override;
77− QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
78− int rowCount(const QModelIndex &parent = QModelIndex()) const override;
79−
80− int count() const;
81−
82−public Q_SLOTS:
83− void activateScreen(int index);
84−
85−Q_SIGNALS:
86− void countChanged();
87− void screenAdded(QScreen *screen);
88− void screenRemoved(QScreen *screen);
89−
90−private:
91− QList<Screen *> m_screenList;
92−};
93−
94−class ScreenMode : public QObject
95−{
96− Q_OBJECT
97− Q_PROPERTY(qreal refreshRate MEMBER refreshRate CONSTANT)
98− Q_PROPERTY(QSize size MEMBER size CONSTANT)
99−public:
100− ScreenMode() {}
101− ScreenMode(qreal refreshRate, QSize size):refreshRate(refreshRate),size(size) {}
102− ScreenMode(const ScreenMode& other)
103− : QObject(nullptr),
104− refreshRate{other.refreshRate},size{other.size}
105− {}
106−
107− qreal refreshRate;
108− QSize size;
109−};
110−
111−class Screen : public QObject
112−{
113− Q_OBJECT
114−
115− Q_PROPERTY(bool active MEMBER m_active NOTIFY activeChanged)
116−
117− Q_PROPERTY(bool used MEMBER m_used NOTIFY usedChanged)
118− Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged)
119− Q_PROPERTY(Screens::OutputTypes outputType MEMBER m_outputType NOTIFY outputTypeChanged)
120− Q_PROPERTY(float scale MEMBER m_scale NOTIFY scaleChanged)
121− Q_PROPERTY(Screens::FormFactor formFactor MEMBER m_formFactor NOTIFY formFactorChanged)
122− Q_PROPERTY(QPoint position MEMBER m_position NOTIFY positionChanged)
123− Q_PROPERTY(uint currentModeIndex MEMBER m_currentModeIndex NOTIFY currentModeIndexChanged)
124− Q_PROPERTY(QQmlListProperty<ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
125− Q_PROPERTY(QSizeF physicalSize MEMBER m_physicalSize NOTIFY physicalSizeChanged)
126−public:
127− Screen(QObject* parent = 0);
128− ~Screen();
129−
130− QQmlListProperty<ScreenMode> availableModes();
131−
132− Q_INVOKABLE Screen* beginConfiguration();
133− Q_INVOKABLE void applyConfiguration();
134−
135−Q_SIGNALS:
136− void activeChanged();
137− void usedChanged();
138− void nameChanged();
139− void outputTypeChanged();
140− void scaleChanged();
141− void formFactorChanged();
142− void positionChanged();
143− void currentModeIndexChanged();
144− void availableModesChanged();
145− void physicalSizeChanged();
146−
147−public:
148− bool m_active{false};
149− bool m_used{true};
150− QString m_name;
151− Screens::OutputTypes m_outputType{Screens::Unknown};
152− float m_scale{1.0};
153− Screens::FormFactor m_formFactor{Screens::FormFactorMonitor};
154− QPoint m_position;
155− uint m_currentModeIndex{0};
156− QList<ScreenMode*> m_sizes;
157− QSizeF m_physicalSize;
158−};
159−
160−Q_DECLARE_METATYPE(ScreenMode)
161−
162−#endif // SCREENS_H
tests/mocks/Unity/Screens/screenwindow.cppdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "screenwindow.h"
18−
19−ScreenWindow::ScreenWindow(QWindow *parent)
20− : QQuickWindow(parent)
21−{
22−}
23−
24−Screen *ScreenWindow::screenWrapper() const
25−{
26− return m_screen.data();
27−}
28−
29−void ScreenWindow::setScreenWrapper(Screen *screen)
30−{
31− if (m_screen != screen) {
32− m_screen = screen;
33− Q_EMIT screenWrapperChanged();
34− }
35−}
tests/mocks/Unity/Screens/screenwindow.hdeleted−42
@@ -1,42 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software: you can redistribute it and/or modify it under
5− * the terms of the GNU Lesser General Public License version 3, as published by
6− * the Free Software Foundation.
7− *
8− * This program is distributed in the hope that it will be useful, but WITHOUT
9− * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10− * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11− * Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef SCREENWINDOW_H
18−#define SCREENWINDOW_H
19−
20−#include <QQuickWindow>
21−#include <QPointer>
22−
23−#include "screens.h"
24−
25−class ScreenWindow : public QQuickWindow
26−{
27− Q_OBJECT
28− Q_PROPERTY(Screen *screen READ screenWrapper WRITE setScreenWrapper NOTIFY screenWrapperChanged)
29−public:
30− ScreenWindow(QWindow *parent = 0);
31−
32− Screen *screenWrapper() const;
33− void setScreenWrapper(Screen *screen);
34−
35−Q_SIGNALS:
36− void screenWrapperChanged();
37−
38−private:
39− QPointer<Screen> m_screen;
40−};
41−
42−#endif // SCREENWINDOW_H