GCC Code Coverage Report


Directory: ./
File: autotests/wayland_config.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 199 200 99.5%
Branches: 333 712 46.8%

Line Branch Exec Source
1 /*************************************************************************************
2 * Copyright 2015 by Sebastian K├╝gler <sebas@kde.org> *
3 * *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with this library; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
17 *************************************************************************************/
18 #include <QCoreApplication>
19 #include <QObject>
20 #include <QSignalSpy>
21 #include <QtTest>
22
23 #include "backendmanager_p.h"
24 #include "config.h"
25 #include "configmonitor.h"
26 #include "generator.h"
27 #include "getconfigoperation.h"
28 #include "mode.h"
29 #include "output.h"
30 #include "setconfigoperation.h"
31
32 #include "server.h"
33
34 Q_LOGGING_CATEGORY(DISMAN_WAYLAND, "disman.wayland")
35
36 using namespace Disman;
37
38 class wayland_config : public QObject
39 {
40 Q_OBJECT
41
42 public:
43 explicit wayland_config(QObject* parent = nullptr);
44
45 private Q_SLOTS:
46 void init();
47 void cleanup();
48
49 void changeConfig();
50 void testPositionChange();
51 void testRotationChange();
52 void testRotationChange_data();
53 void testScaleChange();
54 void testModeChange();
55 void test_adaptive_sync_change();
56 void testApplyOnPending();
57
58 private:
59 server* m_server;
60 };
61
62 1 wayland_config::wayland_config(QObject* parent)
63 : QObject(parent)
64 1 , m_server(nullptr)
65 {
66
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 qputenv("DISMAN_IN_PROCESS", "1");
67
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 qputenv("DISMAN_LOGGING", "false");
68
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QStandardPaths::setTestModeEnabled(true);
69 1 }
70
71 10 void wayland_config::init()
72 {
73 10 setenv("DISMAN_BACKEND", "wayland", 1);
74 10 Disman::BackendManager::instance()->shutdown_backend();
75
76 // This is how KWayland will pick up the right socket,
77 // and thus connect to our internal test server.
78 10 setenv("WAYLAND_DISPLAY", s_socketName, 1);
79
80
1/4
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10 m_server = new server(this);
81 10 m_server->start();
82 10 }
83
84 10 void wayland_config::cleanup()
85 {
86
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 Disman::BackendManager::instance()->shutdown_backend();
87
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 delete m_server;
88
89 // Make sure we did not accidentally unset test mode prior and delete our user configuration.
90
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 QStandardPaths::setTestModeEnabled(true);
91
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
92
1/2
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
30 % QStringLiteral("/disman/");
93
4/8
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10 times.
10 QVERIFY(QDir(path).removeRecursively());
94
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 }
95
96 1 void wayland_config::changeConfig()
97 {
98
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
99
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
100
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
101
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
102
103 // Prepare monitor & spy
104
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
105
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
106
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
107
108 // The first output is enabled, let's set a different mode.
109
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto output = config->outputs().begin()->second;
110
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QVERIFY(output->enabled());
111
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 auto mode = output->mode(QSize(1280, 960), 60000);
112
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(mode);
113
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_mode(mode);
114
115
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output2 = config->outputs()[2]; // is this id stable enough?
116
1/2
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 output2->set_position(QPoint(4000, 1080));
117
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output2->set_rotation(Disman::Output::Left);
118
119
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
120
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto sop = new SetConfigOperation(config, this);
121
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sop->exec(); // fire and forget...
122
123
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
124 // check if the server changed
125
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
126
127
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
128
129
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->remove_config(config);
130
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m_server->showOutputs();
131
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 }
132
133 1 void wayland_config::testPositionChange()
134 {
135
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
136
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
137
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
138
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
139
140 // Prepare monitor & spy
141
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
142
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
143
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
144
145
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output = config->outputs()[2]; // is this id stable enough?
146 1 auto new_pos = QPoint(3840, 1080);
147
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 output->set_position(new_pos);
148
149
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
150
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto sop = new SetConfigOperation(config, this);
151
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sop->exec(); // fire and forget...
152
153
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
154 // check if the server changed
155
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
156
157
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
158
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
1 }
159
160 1 void wayland_config::testRotationChange_data()
161 {
162 1 QTest::addColumn<Disman::Output::Rotation>("rotation");
163
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 QTest::newRow("left") << Disman::Output::Left;
164
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 QTest::newRow("inverted") << Disman::Output::Inverted;
165
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 QTest::newRow("right") << Disman::Output::Right;
166
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 QTest::newRow("none") << Disman::Output::None;
167 1 }
168
169 4 void wayland_config::testRotationChange()
170 {
171
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 QFETCH(Disman::Output::Rotation, rotation);
172
173
2/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 auto op = new GetConfigOperation();
174
3/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 QVERIFY(op->exec());
175
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 auto config = op->config();
176
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 QVERIFY(config);
177
178 // Prepare monitor & spy
179
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
180
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 monitor->add_config(config);
181
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
182
183
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 auto output = config->outputs().begin()->second; // is this id stable enough?
184
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 output->set_enabled(true);
185
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 output->set_rotation(rotation);
186
187
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 QSignalSpy serverSpy(m_server, &server::configChanged);
188
2/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 auto sop = new SetConfigOperation(config, this);
189
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 sop->exec(); // fire and forget...
190
191
3/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 QCOMPARE(configSpy.wait(500), rotation != Disman::Output::None);
192
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 QCOMPARE(serverSpy.count(), rotation != Disman::Output::None);
193
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 QCOMPARE(configSpy.count(), 1);
194
195 // Get a new config, then compare the output with the expected new value
196
2/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 auto newop = new GetConfigOperation();
197
3/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 QVERIFY(newop->exec());
198
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 auto newconfig = newop->config();
199
2/4
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 QVERIFY(newconfig);
200
201
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 auto newoutput = newconfig->outputs().begin()->second;
202
3/6
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
4 QCOMPARE(newoutput->rotation(), rotation);
203
6/12
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
4 }
204
205 1 void wayland_config::testScaleChange()
206 {
207
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
208
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
209
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
210
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
211
212
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op2 = new GetConfigOperation();
213
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op2->exec());
214
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config2 = op2->config();
215
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config2);
216
217 // Prepare monitor & spy
218
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
219
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
220
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config2);
221
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
222
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy2(monitor, &Disman::ConfigMonitor::configuration_changed);
223
224
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output2 = config2->outputs()[2]; // is this id stable enough?
225
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output2->scale(), 1.0);
226
227
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output = config->outputs()[2]; // is this id stable enough?
228
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_scale(2);
229
230
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
231
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto sop = new SetConfigOperation(config, this);
232
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sop->exec(); // fire and forget...
233
234
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
235 // check if the server changed
236
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
237
238
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
239
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy2.count(), 1);
240
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output2->scale(), 2.0);
241
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
1 }
242
243 1 void wayland_config::testModeChange()
244 {
245
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
246
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
247
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
248
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
249
250
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
251
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
252
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
253
254
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output = config->outputs()[1]; // is this id stable enough?
255
256
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 auto mode = output->mode(QSize(1400, 1050), 60000);
257
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(mode);
258
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_mode(mode);
259
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_auto_resolution(false);
260
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_auto_refresh_rate(false);
261
262
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
263
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto sop = new SetConfigOperation(config, this);
264
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sop->exec();
265
266
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
267 // check if the server changed
268
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
269
270
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
271
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
1 }
272
273 1 void wayland_config::test_adaptive_sync_change()
274 {
275
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
276
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
277
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
278
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
279
280
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
281
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
282
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
283
284
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output = config->outputs()[1]; // is this id stable enough?
285
286
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto enabled = output->adaptive_sync();
287
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_adaptive_sync(!enabled);
288
289
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
290
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto sop = new SetConfigOperation(config, this);
291
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sop->exec();
292
293
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
294
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
295
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
296
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
1 }
297
298 1 void wayland_config::testApplyOnPending()
299 {
300
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op = new GetConfigOperation();
301
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op->exec());
302
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config = op->config();
303
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config);
304
305
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 auto op2 = new GetConfigOperation();
306
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(op2->exec());
307
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto config2 = op2->config();
308
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QVERIFY(config2);
309
310
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Disman::ConfigMonitor* monitor = Disman::ConfigMonitor::instance();
311
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 monitor->add_config(config);
312
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy configSpy(monitor, &Disman::ConfigMonitor::configuration_changed);
313
314
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output = config->outputs()[1]; // is this id stable enough?
315
316 // Scale value in the beginning is the best scale.
317
5/10
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
1 QVERIFY(std::abs(output->scale() - Disman::Generator(config).best_scale(output)) < 0.01);
318
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output->set_scale(2);
319
320
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverSpy(m_server, &server::configChanged);
321
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 QSignalSpy serverReceivedSpy(m_server, &server::configReceived);
322
323
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m_server->suspendChanges(true);
324
325
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 new SetConfigOperation(config, this);
326
327 /* Apply next config */
328
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
1 auto output2 = config2->outputs()[2]; // is this id stable enough?
329
330
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output2->scale(), 1.0);
331
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 output2->set_scale(3);
332
333
2/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 new SetConfigOperation(config2, this);
334
335
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(serverReceivedSpy.wait());
336
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverReceivedSpy.count(), 1);
337
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m_server->suspendChanges(false);
338
339
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
340 // check if the server changed
341
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 1);
342
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 1);
343
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output->scale(), 2.0);
344
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output2->scale(), 3.0);
345
346
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 QVERIFY(configSpy.wait());
347 // check if the server changed
348
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(serverSpy.count(), 2);
349
350
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 QCOMPARE(configSpy.count(), 2);
351
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 QCOMPARE(output2->scale(), 3.0);
352
7/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
1 }
353
354
5/10
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
1 QTEST_GUILESS_MAIN(wayland_config)
355
356 #include "wayland_config.moc"
357