Merge lp:~kdub/unity-system-compositor/nochange-rebuild into lp:unity-system-compositor/0.2
- nochange-rebuild
- Merge into 0.2
Status: | Rejected |
---|---|
Rejected by: | Alberto Aguirre |
Proposed branch: | lp:~kdub/unity-system-compositor/nochange-rebuild |
Merge into: | lp:unity-system-compositor/0.2 |
Diff against target: |
2854 lines (+1302/-542) (has conflicts) 45 files modified
CMakeLists.txt (+4/-3) debian/changelog (+62/-3) spinner/eglspinner.cpp (+5/-2) src/CMakeLists.txt (+1/-0) src/dbus_connection_handle.cpp (+2/-2) src/dbus_connection_handle.h (+3/-1) src/dbus_connection_thread.cpp (+5/-11) src/dbus_connection_thread.h (+3/-7) src/dbus_event_loop.cpp (+32/-18) src/dbus_event_loop.h (+4/-2) src/mir_input_configuration.cpp (+129/-14) src/mir_input_configuration.h (+34/-11) src/powerd_mediator.cpp (+6/-6) src/powerd_mediator.h (+1/-1) src/screen_event_handler.cpp (+41/-12) src/screen_event_handler.h (+1/-0) src/server.cpp (+17/-4) src/server.h (+3/-0) src/system_compositor.cpp (+2/-0) src/system_compositor.h (+2/-0) src/unity_input_service.cpp (+11/-13) src/unity_input_service.h (+6/-3) src/unity_screen_service.cpp (+11/-9) src/unity_screen_service.h (+5/-3) tests/CMakeLists.txt (+1/-0) tests/include/usc/test/mock_display.h (+67/-0) tests/include/usc/test/mock_input_configuration.h (+48/-0) tests/include/usc/test/mock_screen.h (+57/-0) tests/include/usc/test/stub_display_configuration.h (+65/-0) tests/integration-tests/CMakeLists.txt (+3/-0) tests/integration-tests/test_dbus_event_loop.cpp (+8/-8) tests/integration-tests/test_deadlock_lp1491566.cpp (+4/-68) tests/integration-tests/test_powerd_mediator.cpp (+7/-6) tests/integration-tests/test_unity_input_service.cpp (+11/-119) tests/integration-tests/test_unity_screen_service.cpp (+12/-147) tests/integration-tests/test_unity_services.cpp (+82/-0) tests/integration-tests/unity_input_dbus_client.cpp (+113/-0) tests/integration-tests/unity_input_dbus_client.h (+52/-0) tests/integration-tests/unity_screen_dbus_client.cpp (+112/-0) tests/integration-tests/unity_screen_dbus_client.h (+54/-0) tests/unit-tests/CMakeLists.txt (+1/-0) tests/unit-tests/test_mir_input_configuration.cpp (+114/-0) tests/unit-tests/test_mir_screen.cpp (+5/-60) tests/unit-tests/test_screen_event_handler.cpp (+93/-7) tools/png2header.py (+3/-2) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~kdub/unity-system-compositor/nochange-rebuild |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity System Compositor Development Team | Pending | ||
Review via email: mp+277588@code.launchpad.net |
This proposal supersedes a proposal from 2015-11-13.
Commit message
do not land: no change rebuild to test a mir corruption fix that breaks abi
Description of the change
do not land: no change rebuild to test a mir corruption fix that breaks abi
- 259. By Andreas Pokorny
-
follow the deprecation warning and use tobytes instead of tostring.
Approved by PS Jenkins bot.
- 260. By Andreas Pokorny
-
do not premultiply RGB images
python would raise an exception if we attempt to access pixel[x,y][3] on a RGB image.
.Approved by PS Jenkins bot.
- 261. By Andrea Cimitan
-
Updated wallpaper for spinner from unity8.
Approved by PS Jenkins bot, Andreas Pokorny.
- 262. By Andreas Pokorny
-
Change keyboard handling to scan codes.
Additionally relevant for ubuntu-pd: use none-phone keys to keep display on. Fixes: https:/
/bugs.launchpad .net/bugs/ 1514059, https:/ /bugs.launchpad .net/bugs/ 1520422. Approved by Alexandros Frantzis, PS Jenkins bot.
- 263. By Andreas Pokorny
-
Catch all devices with pointer or touchpad capabilities and forward input configuration changes to them.
Approved by Alexandros Frantzis, PS Jenkins bot.
- 264. By Andreas Pokorny
-
Use actual image.bytes_
per_pixel to decide about GL format of pixel data. Approved by Alexandros Frantzis, PS Jenkins bot, Kevin DuBois.
- 265. By Andreas Pokorny
-
merge updated change log and version
- 266. By Andreas Pokorny
-
Move Mocks around and integration test utilities to reuse them in further tests.
Approved by Alexandros Frantzis, PS Jenkins bot.
- 267. By Andreas Pokorny
-
Split out the single DBusConnectionH
andle from DBusConnectionT hread This allows having multiple connection names that actually work. As opposed to assigning multiple connection names to a single DBusConnection, in which case the first one wins. Fixes: https:/
/bugs.launchpad .net/bugs/ 1536383. Approved by PS Jenkins bot, Alexandros Frantzis.
- 268. By Michael Terry
-
Properly clamp mouseCursorSpeed and touchpadCursorSpeed settings.
Approved by PS Jenkins bot, Andreas Pokorny.
- 269. By Alexandros Frantzis
-
Unblank the screen when a pointer or key event arrives. Fixes: https:/
/bugs.launchpad .net/bugs/ 1488413. Approved by Andreas Pokorny, PS Jenkins bot.
- 270. By Kevin DuBois
-
bump changelog for no change rebuild
- 271. By Kevin DuBois
-
update changelog after 0.3 landing
Unmerged revisions
- 271. By Kevin DuBois
-
update changelog after 0.3 landing
- 270. By Kevin DuBois
-
bump changelog for no change rebuild
- 269. By Alexandros Frantzis
-
Unblank the screen when a pointer or key event arrives. Fixes: https:/
/bugs.launchpad .net/bugs/ 1488413. Approved by Andreas Pokorny, PS Jenkins bot.
- 268. By Michael Terry
-
Properly clamp mouseCursorSpeed and touchpadCursorSpeed settings.
Approved by PS Jenkins bot, Andreas Pokorny.
- 267. By Andreas Pokorny
-
Split out the single DBusConnectionH
andle from DBusConnectionT hread This allows having multiple connection names that actually work. As opposed to assigning multiple connection names to a single DBusConnection, in which case the first one wins. Fixes: https:/
/bugs.launchpad .net/bugs/ 1536383. Approved by PS Jenkins bot, Alexandros Frantzis.
- 266. By Andreas Pokorny
-
Move Mocks around and integration test utilities to reuse them in further tests.
Approved by Alexandros Frantzis, PS Jenkins bot.
- 265. By Andreas Pokorny
-
merge updated change log and version
- 264. By Andreas Pokorny
-
Use actual image.bytes_
per_pixel to decide about GL format of pixel data. Approved by Alexandros Frantzis, PS Jenkins bot, Kevin DuBois.
- 263. By Andreas Pokorny
-
Catch all devices with pointer or touchpad capabilities and forward input configuration changes to them.
Approved by Alexandros Frantzis, PS Jenkins bot.
- 262. By Andreas Pokorny
-
Change keyboard handling to scan codes.
Additionally relevant for ubuntu-pd: use none-phone keys to keep display on. Fixes: https:/
/bugs.launchpad .net/bugs/ 1514059, https:/ /bugs.launchpad .net/bugs/ 1520422. Approved by Alexandros Frantzis, PS Jenkins bot.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2015-10-08 09:54:02 +0000 |
3 | +++ CMakeLists.txt 2016-01-27 14:14:14 +0000 |
4 | @@ -16,8 +16,8 @@ |
5 | |
6 | project(UnitySystemCompositor) |
7 | set(USC_VERSION_MAJOR 0) |
8 | -set(USC_VERSION_MINOR 2) |
9 | -set(USC_VERSION_PATCH 0) |
10 | +set(USC_VERSION_MINOR 3) |
11 | +set(USC_VERSION_PATCH 1) |
12 | set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}") |
13 | |
14 | cmake_minimum_required(VERSION 2.8) |
15 | @@ -35,7 +35,7 @@ |
16 | |
17 | # Use C++11 and warnings |
18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall") |
19 | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") |
20 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall") |
21 | |
22 | find_package(PkgConfig) |
23 | pkg_check_modules(ANDROIDPROPS libandroid-properties) |
24 | @@ -57,6 +57,7 @@ |
25 | |
26 | if (MIR_ENABLE_TESTS) |
27 | find_package(Gtest REQUIRED) |
28 | + include_directories(${MIRCLIENT_INCLUDE_DIRS} ) |
29 | include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) |
30 | add_subdirectory(tests/) |
31 | endif () |
32 | |
33 | === modified file 'debian/changelog' |
34 | --- debian/changelog 2015-11-16 15:36:56 +0000 |
35 | +++ debian/changelog 2016-01-27 14:14:14 +0000 |
36 | @@ -1,6 +1,65 @@ |
37 | -unity-system-compositor (0.2.0+15.10.20151008.1-0ubuntu1) wily; urgency=medium |
38 | - |
39 | - [ Alexandros Frantzis ] |
40 | +<<<<<<< TREE |
41 | +unity-system-compositor (0.2.0+15.10.20151008.1-0ubuntu1) wily; urgency=medium |
42 | + |
43 | + [ Alexandros Frantzis ] |
44 | +======= |
45 | +unity-system-compositor (0.3.1+16.04.20160121-0ubuntu2) UNRELEASED; urgency=medium |
46 | + |
47 | + * no change rebuild for mir 0.18.2 |
48 | + |
49 | + -- Kevin DuBois <kevin.dubois@canonical.com> Wed, 27 Jan 2016 09:12:35 -0500 |
50 | + |
51 | +unity-system-compositor (0.3.1+16.04.20160121-0ubuntu1) xenial; urgency=medium |
52 | + |
53 | + [ Alexandros Frantzis ] |
54 | + * Unblank the screen when a pointer or key event arrives. (LP: #1488413) |
55 | + |
56 | + [ Andreas Pokorny ] |
57 | + * Implement a DBus interface for setting pointer speed/acceleration. |
58 | + (LP: #1536383) |
59 | + |
60 | + -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Thu, 21 Jan 2016 19:27:33 +0200 |
61 | + |
62 | +unity-system-compositor (0.2.0+16.04.20151222.1-0ubuntu1) xenial; urgency=medium |
63 | + |
64 | + [ Alexandros Frantzis ] |
65 | + * tests: Fix build failure with gcc-4.9 |
66 | + |
67 | + [ Andrea Cimitan ] |
68 | + * Updated wallpaper for spinner from unity8. |
69 | + |
70 | + [ Andreas Pokorny ] |
71 | + * Add clone method to StubdisplayConfigurations |
72 | + * Change keyboard handling to scan codes. (LP: #1514059, #1520422) |
73 | + * do not premultiply RGB images |
74 | + * follow the deprecation warning and use tobytes instead of tostring. |
75 | + |
76 | + [ Kevin DuBois ] |
77 | + * Accommodate RGB images (LP: #1528279) |
78 | + * Accommodate RGB images (LP: #1528279) |
79 | + |
80 | + -- Kevin DuBois <kevin.dubois@canonical.com> Tue, 22 Dec 2015 19:09:40 +0000 |
81 | + |
82 | +unity-system-compositor (0.2.0+16.04.20151216.1-0ubuntu1) xenial; urgency=medium |
83 | + |
84 | + [ Alexandros Frantzis ] |
85 | + * Merge trunk into 0.3.0 |
86 | + |
87 | + [ Andrea Cimitan ] |
88 | + * Merge trunk into 0.3.0 |
89 | + |
90 | + [ Andreas Pokorny ] |
91 | + * Merge trunk into 0.3.0 |
92 | + |
93 | + [ Kevin DuBois ] |
94 | + * Merge trunk into 0.3.0 |
95 | + |
96 | + -- Kevin DuBois <kevin.dubois@canonical.com> Wed, 16 Dec 2015 22:44:38 +0000 |
97 | + |
98 | +unity-system-compositor (0.2.0+15.10.20151008.1-0ubuntu1) wily; urgency=medium |
99 | + |
100 | + [ Alexandros Frantzis ] |
101 | +>>>>>>> MERGE-SOURCE |
102 | * Use new versions of mir::event::make_event() overloads. |
103 | * Rebuild for Mir 0.17. |
104 | |
105 | |
106 | === modified file 'spinner/eglspinner.cpp' |
107 | --- spinner/eglspinner.cpp 2015-06-30 12:04:53 +0000 |
108 | +++ spinner/eglspinner.cpp 2016-01-27 14:14:14 +0000 |
109 | @@ -150,14 +150,17 @@ |
110 | void uploadTexture (GLuint id, Image& image) |
111 | { |
112 | glBindTexture(GL_TEXTURE_2D, id); |
113 | + GLint format = GL_RGBA; |
114 | + if (image.bytes_per_pixel == 3) |
115 | + format = GL_RGB; |
116 | |
117 | glTexImage2D(GL_TEXTURE_2D, |
118 | 0, |
119 | - GL_RGBA, |
120 | + format, |
121 | image.width, |
122 | image.height, |
123 | 0, |
124 | - GL_RGBA, |
125 | + format, |
126 | GL_UNSIGNED_BYTE, |
127 | image.pixel_data); |
128 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
129 | |
130 | === modified file 'spinner/wallpaper.png' |
131 | Binary files spinner/wallpaper.png 2015-07-03 11:43:24 +0000 and spinner/wallpaper.png 2016-01-27 14:14:14 +0000 differ |
132 | === modified file 'src/CMakeLists.txt' |
133 | --- src/CMakeLists.txt 2015-08-29 14:38:35 +0000 |
134 | +++ src/CMakeLists.txt 2016-01-27 14:14:14 +0000 |
135 | @@ -72,6 +72,7 @@ |
136 | ${Boost_INCLUDE_DIRS} |
137 | ${GLESv2_INCLUDE_DIRS} |
138 | ${MIRSERVER_INCLUDE_DIRS} |
139 | + ${MIRCLIENT_INCLUDE_DIRS} |
140 | ${DBUS_INCLUDE_DIRS} |
141 | ) |
142 | add_definitions( |
143 | |
144 | === modified file 'src/dbus_connection_handle.cpp' |
145 | --- src/dbus_connection_handle.cpp 2015-03-18 12:20:58 +0000 |
146 | +++ src/dbus_connection_handle.cpp 2016-01-27 14:14:14 +0000 |
147 | @@ -22,12 +22,12 @@ |
148 | #include <stdexcept> |
149 | #include <boost/throw_exception.hpp> |
150 | |
151 | -usc::DBusConnectionHandle::DBusConnectionHandle(const char* address) |
152 | +usc::DBusConnectionHandle::DBusConnectionHandle(std::string const& address) |
153 | { |
154 | dbus_threads_init_default(); |
155 | ScopedDBusError error; |
156 | |
157 | - connection = dbus_connection_open_private(address, &error); |
158 | + connection = dbus_connection_open_private(address.c_str(), &error); |
159 | if (!connection || error) |
160 | { |
161 | BOOST_THROW_EXCEPTION( |
162 | |
163 | === modified file 'src/dbus_connection_handle.h' |
164 | --- src/dbus_connection_handle.h 2015-03-17 18:17:14 +0000 |
165 | +++ src/dbus_connection_handle.h 2016-01-27 14:14:14 +0000 |
166 | @@ -21,13 +21,15 @@ |
167 | |
168 | #include <dbus/dbus.h> |
169 | |
170 | +#include <string> |
171 | + |
172 | namespace usc |
173 | { |
174 | |
175 | class DBusConnectionHandle |
176 | { |
177 | public: |
178 | - DBusConnectionHandle(char const* address); |
179 | + DBusConnectionHandle(std::string const& address); |
180 | ~DBusConnectionHandle(); |
181 | |
182 | void request_name(char const* name) const; |
183 | |
184 | === modified file 'src/dbus_connection_thread.cpp' |
185 | --- src/dbus_connection_thread.cpp 2015-08-25 14:27:23 +0000 |
186 | +++ src/dbus_connection_thread.cpp 2016-01-27 14:14:14 +0000 |
187 | @@ -17,11 +17,10 @@ |
188 | */ |
189 | |
190 | #include "dbus_connection_thread.h" |
191 | +#include "dbus_event_loop.h" |
192 | #include "thread_name.h" |
193 | |
194 | -usc::DBusConnectionThread::DBusConnectionThread(std::string const& address) |
195 | - : dbus_connection{address.c_str()}, |
196 | - dbus_event_loop{dbus_connection} |
197 | +usc::DBusConnectionThread::DBusConnectionThread(std::shared_ptr<DBusEventLoop> const& loop) : dbus_event_loop(loop) |
198 | { |
199 | std::promise<void> event_loop_started; |
200 | auto event_loop_started_future = event_loop_started.get_future(); |
201 | @@ -30,7 +29,7 @@ |
202 | [this,&event_loop_started] |
203 | { |
204 | usc::set_thread_name("USC/DBus"); |
205 | - dbus_event_loop.run(event_loop_started); |
206 | + dbus_event_loop->run(event_loop_started); |
207 | }); |
208 | |
209 | event_loop_started_future.wait(); |
210 | @@ -38,16 +37,11 @@ |
211 | |
212 | usc::DBusConnectionThread::~DBusConnectionThread() |
213 | { |
214 | - dbus_event_loop.stop(); |
215 | + dbus_event_loop->stop(); |
216 | dbus_loop_thread.join(); |
217 | } |
218 | |
219 | -usc::DBusConnectionHandle const& usc::DBusConnectionThread::connection() const |
220 | -{ |
221 | - return dbus_connection; |
222 | -} |
223 | - |
224 | usc::DBusEventLoop & usc::DBusConnectionThread::loop() |
225 | { |
226 | - return dbus_event_loop; |
227 | + return *dbus_event_loop; |
228 | } |
229 | |
230 | === modified file 'src/dbus_connection_thread.h' |
231 | --- src/dbus_connection_thread.h 2015-08-25 14:27:23 +0000 |
232 | +++ src/dbus_connection_thread.h 2016-01-27 14:14:14 +0000 |
233 | @@ -19,25 +19,21 @@ |
234 | #ifndef USC_DBUS_CONNECTION_THREAD_H_ |
235 | #define USC_DBUS_CONNECTION_THREAD_H_ |
236 | |
237 | -#include "dbus_connection_handle.h" |
238 | -#include "dbus_event_loop.h" |
239 | - |
240 | #include <thread> |
241 | |
242 | namespace usc |
243 | { |
244 | |
245 | +class DBusEventLoop; |
246 | class DBusConnectionThread |
247 | { |
248 | public: |
249 | - DBusConnectionThread(std::string const& address); |
250 | + DBusConnectionThread(std::shared_ptr<DBusEventLoop> const& thread); |
251 | ~DBusConnectionThread(); |
252 | - DBusConnectionHandle const& connection() const; |
253 | DBusEventLoop & loop(); |
254 | |
255 | private: |
256 | - DBusConnectionHandle dbus_connection; |
257 | - DBusEventLoop dbus_event_loop; |
258 | + std::shared_ptr<DBusEventLoop> dbus_event_loop; |
259 | std::thread dbus_loop_thread; |
260 | }; |
261 | |
262 | |
263 | === modified file 'src/dbus_event_loop.cpp' |
264 | --- src/dbus_event_loop.cpp 2015-03-18 12:20:58 +0000 |
265 | +++ src/dbus_event_loop.cpp 2016-01-27 14:14:14 +0000 |
266 | @@ -21,6 +21,7 @@ |
267 | #endif |
268 | |
269 | #include "dbus_event_loop.h" |
270 | +#include "dbus_connection_handle.h" |
271 | |
272 | #include <algorithm> |
273 | |
274 | @@ -78,9 +79,8 @@ |
275 | |
276 | } |
277 | |
278 | -usc::DBusEventLoop::DBusEventLoop(DBusConnection* connection) |
279 | - : connection{connection}, |
280 | - running{false}, |
281 | +usc::DBusEventLoop::DBusEventLoop() |
282 | + : running{false}, |
283 | epoll_fd{epoll_create1(EPOLL_CLOEXEC)} |
284 | { |
285 | if (epoll_fd == -1) |
286 | @@ -109,9 +109,17 @@ |
287 | BOOST_THROW_EXCEPTION( |
288 | std::system_error(errno, std::system_category(), "epoll_ctl")); |
289 | } |
290 | +} |
291 | + |
292 | +void usc::DBusEventLoop::add_connection(std::shared_ptr<DBusConnectionHandle> const& connection) |
293 | +{ |
294 | + if (running) |
295 | + BOOST_THROW_EXCEPTION(std::logic_error("Connection added after dbus event loop started")); |
296 | + |
297 | + connections.push_back(connection); |
298 | |
299 | dbus_connection_set_watch_functions( |
300 | - connection, |
301 | + *connection, |
302 | DBusEventLoop::static_add_watch, |
303 | DBusEventLoop::static_remove_watch, |
304 | DBusEventLoop::static_toggle_watch, |
305 | @@ -119,7 +127,7 @@ |
306 | nullptr); |
307 | |
308 | dbus_connection_set_timeout_functions( |
309 | - connection, |
310 | + *connection, |
311 | DBusEventLoop::static_add_timeout, |
312 | DBusEventLoop::static_remove_timeout, |
313 | DBusEventLoop::static_toggle_timeout, |
314 | @@ -127,7 +135,7 @@ |
315 | nullptr); |
316 | |
317 | dbus_connection_set_wakeup_main_function( |
318 | - connection, |
319 | + *connection, |
320 | DBusEventLoop::static_wake_up_loop, |
321 | this, nullptr); |
322 | } |
323 | @@ -136,14 +144,17 @@ |
324 | { |
325 | stop(); |
326 | |
327 | - dbus_connection_set_watch_functions( |
328 | - connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
329 | - |
330 | - dbus_connection_set_timeout_functions( |
331 | - connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
332 | - |
333 | - dbus_connection_set_wakeup_main_function( |
334 | - connection, nullptr, nullptr, nullptr); |
335 | + for(auto connection : connections) |
336 | + { |
337 | + dbus_connection_set_watch_functions( |
338 | + *connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
339 | + |
340 | + dbus_connection_set_timeout_functions( |
341 | + *connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
342 | + |
343 | + dbus_connection_set_wakeup_main_function( |
344 | + *connection, nullptr, nullptr, nullptr); |
345 | + } |
346 | } |
347 | |
348 | void usc::DBusEventLoop::run(std::promise<void>& started) |
349 | @@ -187,14 +198,17 @@ |
350 | |
351 | dispatch_actions(); |
352 | |
353 | - dbus_connection_flush(connection); |
354 | + for (auto connection : connections) |
355 | + { |
356 | + dbus_connection_flush(*connection); |
357 | |
358 | - while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) |
359 | - continue; |
360 | + while (dbus_connection_dispatch(*connection) == DBUS_DISPATCH_DATA_REMAINS); |
361 | + } |
362 | } |
363 | |
364 | // Flush any remaining outgoing messages |
365 | - dbus_connection_flush(connection); |
366 | + for (auto connection : connections) |
367 | + dbus_connection_flush(*connection); |
368 | } |
369 | |
370 | void usc::DBusEventLoop::stop() |
371 | |
372 | === modified file 'src/dbus_event_loop.h' |
373 | --- src/dbus_event_loop.h 2015-03-18 11:56:28 +0000 |
374 | +++ src/dbus_event_loop.h 2016-01-27 14:14:14 +0000 |
375 | @@ -30,13 +30,15 @@ |
376 | |
377 | namespace usc |
378 | { |
379 | +class DBusConnectionHandle; |
380 | |
381 | class DBusEventLoop |
382 | { |
383 | public: |
384 | - DBusEventLoop(DBusConnection* connection); |
385 | + DBusEventLoop(); |
386 | ~DBusEventLoop(); |
387 | |
388 | + void add_connection(std::shared_ptr<DBusConnectionHandle> const& connection); |
389 | void run(std::promise<void>& started); |
390 | void stop(); |
391 | |
392 | @@ -70,10 +72,10 @@ |
393 | static void static_toggle_timeout(DBusTimeout* timeout, void* data); |
394 | static void static_wake_up_loop(void* data); |
395 | |
396 | - DBusConnection* const connection; |
397 | std::atomic<bool> running; |
398 | |
399 | std::mutex mutex; |
400 | + std::vector<std::shared_ptr<DBusConnectionHandle>> connections; |
401 | std::vector<DBusWatch*> watches; |
402 | std::vector<std::pair<DBusTimeout*,mir::Fd>> timeouts; |
403 | std::vector<std::function<void(void)>> actions; |
404 | |
405 | === modified file 'src/mir_input_configuration.cpp' |
406 | --- src/mir_input_configuration.cpp 2015-08-26 08:26:35 +0000 |
407 | +++ src/mir_input_configuration.cpp 2016-01-27 14:14:14 +0000 |
408 | @@ -15,58 +15,173 @@ |
409 | */ |
410 | |
411 | #include "mir_input_configuration.h" |
412 | - |
413 | -// just a stub at the moment, this implementation will be supposed to |
414 | -// observe available input devices and apply settings to it. |
415 | - |
416 | +#include "mir/input/input_device_observer.h" |
417 | +#include "mir/input/input_device_hub.h" |
418 | +#include "mir/input/pointer_configuration.h" |
419 | +#include "mir/input/touchpad_configuration.h" |
420 | +#include "mir/input/device.h" |
421 | + |
422 | +namespace mi = mir::input; |
423 | + |
424 | +namespace |
425 | +{ |
426 | +struct DeviceObserver : mi::InputDeviceObserver |
427 | +{ |
428 | + usc::MirInputConfiguration* conf; |
429 | + DeviceObserver(usc::MirInputConfiguration* conf) |
430 | + : conf{conf} |
431 | + { |
432 | + } |
433 | + |
434 | + void device_added(std::shared_ptr<mi::Device> const& device) override |
435 | + { |
436 | + conf->device_added(device); |
437 | + } |
438 | + |
439 | + void device_changed(std::shared_ptr<mi::Device> const&) override |
440 | + { |
441 | + } |
442 | + |
443 | + void device_removed(std::shared_ptr<mi::Device> const&device) override |
444 | + { |
445 | + conf->device_removed(device); |
446 | + } |
447 | + |
448 | + void changes_complete() override |
449 | + { |
450 | + } |
451 | +}; |
452 | +} |
453 | + |
454 | + |
455 | +usc::MirInputConfiguration::MirInputConfiguration(std::shared_ptr<mi::InputDeviceHub> const& device_hub) : |
456 | + observer{std::make_shared<DeviceObserver>(this)} |
457 | +{ |
458 | + device_hub->add_observer(observer); |
459 | +} |
460 | + |
461 | +void usc::MirInputConfiguration::device_removed(std::shared_ptr<mi::Device> const& dev) |
462 | +{ |
463 | + std::lock_guard<decltype(devices_lock)> lock(devices_lock); |
464 | + touchpads.erase(dev); |
465 | + mice.erase(dev); |
466 | +} |
467 | + |
468 | +void usc::MirInputConfiguration::configure_mouse(mi::Device& dev) |
469 | +{ |
470 | + dev.apply_pointer_configuration(mouse_pointer_config); |
471 | +} |
472 | + |
473 | +void usc::MirInputConfiguration::configure_touchpad(mi::Device& dev) |
474 | +{ |
475 | + dev.apply_pointer_configuration(touchpad_pointer_config); |
476 | + dev.apply_touchpad_configuration(touchpad_config); |
477 | +} |
478 | + |
479 | +void usc::MirInputConfiguration::device_added(std::shared_ptr<mi::Device> const& dev) |
480 | +{ |
481 | + std::lock_guard<decltype(devices_lock)> lock(devices_lock); |
482 | + |
483 | + if (contains(dev->capabilities(), mi::DeviceCapability::touchpad)) |
484 | + { |
485 | + touchpads.insert(dev); |
486 | + configure_touchpad(*dev); |
487 | + } |
488 | + else if (contains(dev->capabilities(), mi::DeviceCapability::pointer)) |
489 | + { |
490 | + mice.insert(dev); |
491 | + configure_mouse(*dev); |
492 | + } |
493 | +} |
494 | + |
495 | +void usc::MirInputConfiguration::update_touchpads() |
496 | +{ |
497 | + for (auto const& touchpad : touchpads) |
498 | + configure_touchpad(*touchpad); |
499 | +} |
500 | + |
501 | +void usc::MirInputConfiguration::update_mice() |
502 | +{ |
503 | + for (auto const& mouse : mice) |
504 | + configure_mouse(*mouse); |
505 | +} |
506 | |
507 | void usc::MirInputConfiguration::set_mouse_primary_button(int32_t button) |
508 | { |
509 | - mouse_primary_button = button; |
510 | + mouse_pointer_config.handedness = button == 0 ? |
511 | + mir_pointer_handedness_right : |
512 | + mir_pointer_handedness_left; |
513 | + update_mice(); |
514 | } |
515 | |
516 | void usc::MirInputConfiguration::set_mouse_cursor_speed(double speed) |
517 | { |
518 | - mouse_cursor_speed = speed; |
519 | + double clamped = speed; |
520 | + if (clamped < 0.0) |
521 | + clamped = 0.0; |
522 | + if (clamped > 1.0) |
523 | + clamped = 1.0; |
524 | + mouse_pointer_config.cursor_acceleration_bias = clamped * 2.0 - 1.0; |
525 | + update_mice(); |
526 | } |
527 | |
528 | void usc::MirInputConfiguration::set_mouse_scroll_speed(double speed) |
529 | { |
530 | - mouse_scroll_speed = speed; |
531 | + mouse_pointer_config.horizontal_scroll_scale = speed; |
532 | + mouse_pointer_config.vertical_scroll_scale = speed; |
533 | + update_mice(); |
534 | } |
535 | |
536 | void usc::MirInputConfiguration::set_touchpad_primary_button(int32_t button) |
537 | { |
538 | - touchpad_primary_button = button; |
539 | + touchpad_pointer_config.handedness = button == 0?mir_pointer_handedness_right:mir_pointer_handedness_left; |
540 | + update_touchpads(); |
541 | } |
542 | |
543 | void usc::MirInputConfiguration::set_touchpad_cursor_speed(double speed) |
544 | { |
545 | - touchpad_cursor_speed = speed; |
546 | + double clamped = speed; |
547 | + if (clamped < 0.0) |
548 | + clamped = 0.0; |
549 | + if (clamped > 1.0) |
550 | + clamped = 1.0; |
551 | + touchpad_pointer_config.cursor_acceleration_bias = clamped * 2.0 - 1.0; |
552 | + update_touchpads(); |
553 | } |
554 | |
555 | void usc::MirInputConfiguration::set_touchpad_scroll_speed(double speed) |
556 | { |
557 | - touchpad_scroll_speed = speed; |
558 | + touchpad_pointer_config.horizontal_scroll_scale = speed; |
559 | + touchpad_pointer_config.vertical_scroll_scale = speed; |
560 | + update_touchpads(); |
561 | } |
562 | |
563 | void usc::MirInputConfiguration::set_two_finger_scroll(bool enable) |
564 | { |
565 | - two_finger_scroll = enable; |
566 | + MirTouchpadScrollModes current = touchpad_config.scroll_mode; |
567 | + if (enable) |
568 | + current |= mir_touchpad_scroll_mode_two_finger_scroll; |
569 | + else |
570 | + current &= ~mir_touchpad_scroll_mode_two_finger_scroll; |
571 | + touchpad_config.scroll_mode = current; |
572 | + update_touchpads(); |
573 | } |
574 | |
575 | void usc::MirInputConfiguration::set_tap_to_click(bool enable) |
576 | { |
577 | - tap_to_click = enable; |
578 | + touchpad_config.tap_to_click = enable; |
579 | + update_touchpads(); |
580 | } |
581 | |
582 | void usc::MirInputConfiguration::set_disable_touchpad_while_typing(bool enable) |
583 | { |
584 | - disable_while_typing = enable; |
585 | + touchpad_config.disable_while_typing = enable; |
586 | + update_touchpads(); |
587 | } |
588 | |
589 | void usc::MirInputConfiguration::set_disable_touchpad_with_mouse(bool enable) |
590 | { |
591 | - disable_with_mouse = enable; |
592 | + touchpad_config.disable_with_mouse = enable; |
593 | + update_touchpads(); |
594 | } |
595 | |
596 | |
597 | === modified file 'src/mir_input_configuration.h' |
598 | --- src/mir_input_configuration.h 2015-08-26 08:26:35 +0000 |
599 | +++ src/mir_input_configuration.h 2016-01-27 14:14:14 +0000 |
600 | @@ -14,18 +14,36 @@ |
601 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
602 | */ |
603 | |
604 | - |
605 | #ifndef USC_MIR_INPUT_CONFIGRATION_H_ |
606 | #define USC_MIR_INPUT_CONFIGRATION_H_ |
607 | |
608 | #include "input_configuration.h" |
609 | |
610 | +#include "mir/input/touchpad_configuration.h" |
611 | +#include "mir/input/pointer_configuration.h" |
612 | + |
613 | +#include <memory> |
614 | +#include <thread> |
615 | +#include <mutex> |
616 | +#include <unordered_set> |
617 | + |
618 | +namespace mir |
619 | +{ |
620 | +namespace input |
621 | +{ |
622 | +class InputDeviceHub; |
623 | +class Device; |
624 | +class InputDeviceObserver; |
625 | +} |
626 | +} |
627 | + |
628 | namespace usc |
629 | { |
630 | |
631 | struct MirInputConfiguration : InputConfiguration |
632 | { |
633 | public: |
634 | + MirInputConfiguration(std::shared_ptr<mir::input::InputDeviceHub> const& device_hub); |
635 | void set_mouse_primary_button(int32_t button) override; |
636 | void set_mouse_cursor_speed(double speed) override; |
637 | void set_mouse_scroll_speed(double speed) override; |
638 | @@ -36,17 +54,22 @@ |
639 | void set_tap_to_click(bool enable) override; |
640 | void set_disable_touchpad_while_typing(bool enable) override; |
641 | void set_disable_touchpad_with_mouse(bool enable) override; |
642 | + |
643 | + void device_added(std::shared_ptr<mir::input::Device> const& device); |
644 | + void device_removed(std::shared_ptr<mir::input::Device> const& device); |
645 | private: |
646 | - int32_t mouse_primary_button{0}; |
647 | - double mouse_cursor_speed{0.5}; |
648 | - double mouse_scroll_speed{0.5}; |
649 | - int32_t touchpad_primary_button{0}; |
650 | - double touchpad_cursor_speed{0.5}; |
651 | - double touchpad_scroll_speed{0.5}; |
652 | - bool two_finger_scroll{false}; |
653 | - bool tap_to_click{false}; |
654 | - bool disable_while_typing{false}; |
655 | - bool disable_with_mouse{true}; |
656 | + void configure_mouse(mir::input::Device& dev); |
657 | + void configure_touchpad(mir::input::Device& dev); |
658 | + void update_touchpads(); |
659 | + void update_mice(); |
660 | + |
661 | + std::shared_ptr<mir::input::InputDeviceObserver> const observer; |
662 | + std::mutex devices_lock; |
663 | + std::unordered_set<std::shared_ptr<mir::input::Device>> touchpads; |
664 | + std::unordered_set<std::shared_ptr<mir::input::Device>> mice; |
665 | + mir::input::PointerConfiguration mouse_pointer_config; |
666 | + mir::input::PointerConfiguration touchpad_pointer_config; |
667 | + mir::input::TouchpadConfiguration touchpad_config; |
668 | }; |
669 | |
670 | } |
671 | |
672 | === modified file 'src/powerd_mediator.cpp' |
673 | --- src/powerd_mediator.cpp 2015-07-17 12:43:46 +0000 |
674 | +++ src/powerd_mediator.cpp 2016-01-27 14:14:14 +0000 |
675 | @@ -45,8 +45,7 @@ |
676 | } |
677 | |
678 | usc::PowerdMediator::PowerdMediator(std::string const& bus_addr) |
679 | - : connection{bus_addr.c_str()}, |
680 | - dbus_event_loop{connection}, |
681 | + : connection{std::make_shared<DBusConnectionHandle>(bus_addr.c_str())}, |
682 | pending_suspend_block_request{false}, |
683 | dim_brightness_{10}, |
684 | min_brightness_{0}, |
685 | @@ -59,17 +58,18 @@ |
686 | proximity_enabled{false}, |
687 | sys_state{SysState::unknown} |
688 | { |
689 | - connection.add_match( |
690 | + dbus_event_loop.add_connection(connection); |
691 | + connection->add_match( |
692 | "type='signal'," |
693 | "sender='com.canonical.powerd'," |
694 | "interface='com.canonical.powerd'," |
695 | "member='SysPowerStateChange'"); |
696 | - connection.add_match( |
697 | + connection->add_match( |
698 | "type='signal'," |
699 | "sender='org.freedesktop.DBus'," |
700 | "interface='org.freedesktop.DBus'," |
701 | "member='NameOwnerChanged'"); |
702 | - connection.add_filter(handle_dbus_message_thunk, this); |
703 | + connection->add_filter(handle_dbus_message_thunk, this); |
704 | |
705 | std::promise<void> event_loop_started; |
706 | auto event_loop_started_future = event_loop_started.get_future(); |
707 | @@ -477,7 +477,7 @@ |
708 | [this, &msg, &reply_promise] |
709 | { |
710 | auto const reply = dbus_connection_send_with_reply_and_block( |
711 | - connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr); |
712 | + *connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr); |
713 | |
714 | reply_promise.set_value(reply); |
715 | }; |
716 | |
717 | === modified file 'src/powerd_mediator.h' |
718 | --- src/powerd_mediator.h 2015-07-17 12:43:46 +0000 |
719 | +++ src/powerd_mediator.h 2016-01-27 14:14:14 +0000 |
720 | @@ -88,7 +88,7 @@ |
721 | void invoke(char const* method, int first_arg_type, ...); |
722 | usc::DBusMessageHandle invoke_with_reply(char const* method, int first_arg_type, ...); |
723 | |
724 | - usc::DBusConnectionHandle connection; |
725 | + std::shared_ptr<usc::DBusConnectionHandle> connection; |
726 | usc::DBusEventLoop dbus_event_loop; |
727 | std::thread dbus_loop_thread; |
728 | |
729 | |
730 | === modified file 'src/screen_event_handler.cpp' |
731 | --- src/screen_event_handler.cpp 2015-07-13 12:35:41 +0000 |
732 | +++ src/screen_event_handler.cpp 2016-01-27 14:14:14 +0000 |
733 | @@ -21,6 +21,7 @@ |
734 | #include <mir/time/alarm_factory.h> |
735 | #include <mir_toolkit/events/input/input_event.h> |
736 | |
737 | +#include "linux/input.h" |
738 | #include <cstdio> |
739 | |
740 | usc::ScreenEventHandler::ScreenEventHandler( |
741 | @@ -45,8 +46,6 @@ |
742 | |
743 | bool usc::ScreenEventHandler::handle(MirEvent const& event) |
744 | { |
745 | - static const int32_t POWER_KEY_CODE = 26; |
746 | - |
747 | if (mir_event_get_type(&event) != mir_event_type_input) |
748 | return false; |
749 | |
750 | @@ -56,21 +55,36 @@ |
751 | if (input_event_type == mir_input_event_type_key) |
752 | { |
753 | auto const kev = mir_input_event_get_keyboard_event(input_event); |
754 | - if (mir_keyboard_event_key_code(kev) != POWER_KEY_CODE) |
755 | - return false; |
756 | - |
757 | - auto const action = mir_keyboard_event_action(kev); |
758 | - if (action == mir_keyboard_action_down) |
759 | - power_key_down(); |
760 | - else if (action == mir_keyboard_action_up) |
761 | - power_key_up(); |
762 | + if (mir_keyboard_event_scan_code(kev) == KEY_POWER) |
763 | + { |
764 | + auto const action = mir_keyboard_event_action(kev); |
765 | + if (action == mir_keyboard_action_down) |
766 | + power_key_down(); |
767 | + else if (action == mir_keyboard_action_up) |
768 | + power_key_up(); |
769 | + } |
770 | + // we might want to come up with a whole range of media player related keys |
771 | + else if (mir_keyboard_event_scan_code(kev) == KEY_VOLUMEDOWN|| |
772 | + mir_keyboard_event_scan_code(kev) == KEY_VOLUMEUP) |
773 | + { |
774 | + // do not keep display on when interacting with media player |
775 | + } |
776 | + else |
777 | + { |
778 | + keep_or_turn_screen_on(); |
779 | + } |
780 | } |
781 | - else if (input_event_type == mir_input_event_type_touch || |
782 | - input_event_type == mir_input_event_type_pointer) |
783 | + else if (input_event_type == mir_input_event_type_touch) |
784 | { |
785 | std::lock_guard<std::mutex> lock{guard}; |
786 | screen->keep_display_on_temporarily(); |
787 | } |
788 | + else if (input_event_type == mir_input_event_type_pointer) |
789 | + { |
790 | + bool const filter_out_event = screen->get_screen_power_mode() != mir_power_mode_on; |
791 | + keep_or_turn_screen_on(); |
792 | + return filter_out_event; |
793 | + } |
794 | |
795 | return false; |
796 | } |
797 | @@ -128,3 +142,18 @@ |
798 | MirPowerMode::mir_power_mode_on, PowerStateChangeReason::power_key); |
799 | long_press_detected = true; |
800 | } |
801 | + |
802 | +void usc::ScreenEventHandler::keep_or_turn_screen_on() |
803 | +{ |
804 | + std::lock_guard<std::mutex> lock{guard}; |
805 | + |
806 | + if (screen->get_screen_power_mode() == mir_power_mode_off) |
807 | + { |
808 | + screen->set_screen_power_mode( |
809 | + MirPowerMode::mir_power_mode_on, PowerStateChangeReason::unknown); |
810 | + } |
811 | + else |
812 | + { |
813 | + screen->keep_display_on_temporarily(); |
814 | + } |
815 | +} |
816 | |
817 | === modified file 'src/screen_event_handler.h' |
818 | --- src/screen_event_handler.h 2015-04-29 14:39:19 +0000 |
819 | +++ src/screen_event_handler.h 2016-01-27 14:14:14 +0000 |
820 | @@ -56,6 +56,7 @@ |
821 | void power_key_down(); |
822 | void shutdown_alarm_notification(); |
823 | void long_press_notification(); |
824 | + void keep_or_turn_screen_on(); |
825 | |
826 | std::mutex guard; |
827 | std::shared_ptr<Screen> const screen; |
828 | |
829 | === modified file 'src/server.cpp' |
830 | --- src/server.cpp 2015-09-30 10:53:54 +0000 |
831 | +++ src/server.cpp 2016-01-27 14:14:14 +0000 |
832 | @@ -28,6 +28,7 @@ |
833 | #include "unity_screen_service.h" |
834 | #include "unity_input_service.h" |
835 | #include "dbus_connection_thread.h" |
836 | +#include "dbus_event_loop.h" |
837 | #include "display_configuration_policy.h" |
838 | #include "steady_clock.h" |
839 | |
840 | @@ -241,7 +242,7 @@ |
841 | return input_configuration( |
842 | [this] |
843 | { |
844 | - return std::make_shared<MirInputConfiguration>(); |
845 | + return std::make_shared<MirInputConfiguration>(the_input_device_hub()); |
846 | }); |
847 | } |
848 | |
849 | @@ -292,12 +293,22 @@ |
850 | }); |
851 | } |
852 | |
853 | +std::shared_ptr<usc::DBusEventLoop> usc::Server::the_dbus_event_loop() |
854 | +{ |
855 | + return dbus_loop( |
856 | + [this] |
857 | + { |
858 | + return std::make_shared<DBusEventLoop>(); |
859 | + }); |
860 | + |
861 | +} |
862 | + |
863 | std::shared_ptr<usc::DBusConnectionThread> usc::Server::the_dbus_connection_thread() |
864 | { |
865 | return dbus_thread( |
866 | [this] |
867 | { |
868 | - return std::make_shared<DBusConnectionThread>(dbus_bus_address()); |
869 | + return std::make_shared<DBusConnectionThread>(the_dbus_event_loop()); |
870 | }); |
871 | } |
872 | |
873 | @@ -307,7 +318,8 @@ |
874 | [this] |
875 | { |
876 | return std::make_shared<UnityScreenService>( |
877 | - the_dbus_connection_thread(), |
878 | + the_dbus_event_loop(), |
879 | + dbus_bus_address(), |
880 | the_screen()); |
881 | }); |
882 | } |
883 | @@ -318,7 +330,8 @@ |
884 | [this] |
885 | { |
886 | return std::make_shared<UnityInputService>( |
887 | - the_dbus_connection_thread(), |
888 | + the_dbus_event_loop(), |
889 | + dbus_bus_address(), |
890 | the_input_configuration()); |
891 | }); |
892 | } |
893 | |
894 | === modified file 'src/server.h' |
895 | --- src/server.h 2015-09-30 10:53:54 +0000 |
896 | +++ src/server.h 2016-01-27 14:14:14 +0000 |
897 | @@ -45,6 +45,7 @@ |
898 | class InputConfiguration; |
899 | class UnityInputService; |
900 | class DBusConnectionThread; |
901 | +class DBusEventLoop; |
902 | class Clock; |
903 | |
904 | class Server : private mir::Server |
905 | @@ -69,6 +70,7 @@ |
906 | virtual std::shared_ptr<ScreenHardware> the_screen_hardware(); |
907 | virtual std::shared_ptr<UnityScreenService> the_unity_screen_service(); |
908 | virtual std::shared_ptr<UnityInputService> the_unity_input_service(); |
909 | + virtual std::shared_ptr<DBusEventLoop> the_dbus_event_loop(); |
910 | virtual std::shared_ptr<DBusConnectionThread> the_dbus_connection_thread(); |
911 | virtual std::shared_ptr<Clock> the_clock(); |
912 | |
913 | @@ -182,6 +184,7 @@ |
914 | mir::CachedPtr<mir::input::EventFilter> screen_event_handler; |
915 | mir::CachedPtr<ScreenHardware> screen_hardware; |
916 | mir::CachedPtr<DBusConnectionThread> dbus_thread; |
917 | + mir::CachedPtr<DBusEventLoop> dbus_loop; |
918 | mir::CachedPtr<UnityScreenService> unity_screen_service; |
919 | mir::CachedPtr<UnityInputService> unity_input_service; |
920 | mir::CachedPtr<Clock> clock; |
921 | |
922 | === modified file 'src/system_compositor.cpp' |
923 | --- src/system_compositor.cpp 2015-08-26 08:26:35 +0000 |
924 | +++ src/system_compositor.cpp 2016-01-27 14:14:14 +0000 |
925 | @@ -22,6 +22,7 @@ |
926 | #include "dm_connection.h" |
927 | |
928 | #include <mir/input/composite_event_filter.h> |
929 | +#include <mir/input/input_device_hub.h> |
930 | #include <mir/abnormal_exit.h> |
931 | |
932 | #include <cerrno> |
933 | @@ -123,6 +124,7 @@ |
934 | |
935 | unity_screen_service = server->the_unity_screen_service(); |
936 | unity_input_service = server->the_unity_input_service(); |
937 | + dbus_service_thread = server->the_dbus_connection_thread(); |
938 | } |
939 | }); |
940 | |
941 | |
942 | === modified file 'src/system_compositor.h' |
943 | --- src/system_compositor.h 2015-08-26 08:26:35 +0000 |
944 | +++ src/system_compositor.h 2016-01-27 14:14:14 +0000 |
945 | @@ -40,6 +40,7 @@ |
946 | class Screen; |
947 | class UnityScreenService; |
948 | class UnityInputService; |
949 | +class DBusConnectionThread; |
950 | |
951 | class SystemCompositor |
952 | { |
953 | @@ -55,6 +56,7 @@ |
954 | std::shared_ptr<mir::input::EventFilter> screen_event_handler; |
955 | std::shared_ptr<UnityScreenService> unity_screen_service; |
956 | std::shared_ptr<UnityInputService> unity_input_service; |
957 | + std::shared_ptr<DBusConnectionThread> dbus_service_thread; |
958 | }; |
959 | |
960 | } |
961 | |
962 | === modified file 'src/unity_input_service.cpp' |
963 | --- src/unity_input_service.cpp 2015-08-28 15:57:25 +0000 |
964 | +++ src/unity_input_service.cpp 2016-01-27 14:14:14 +0000 |
965 | @@ -19,7 +19,7 @@ |
966 | #include "unity_input_service.h" |
967 | #include "input_configuration.h" |
968 | #include "dbus_message_handle.h" |
969 | -#include "dbus_connection_thread.h" |
970 | +#include "dbus_event_loop.h" |
971 | #include "scoped_dbus_error.h" |
972 | |
973 | #include "unity_input_service_introspection.h" // autogenerated |
974 | @@ -33,15 +33,14 @@ |
975 | |
976 | } |
977 | |
978 | -usc::UnityInputService::UnityInputService( |
979 | - std::shared_ptr<usc::DBusConnectionThread> const& dbus, |
980 | - std::shared_ptr<usc::InputConfiguration> const& input_config) |
981 | - : dbus{dbus}, |
982 | - input_config{input_config} |
983 | +usc::UnityInputService::UnityInputService(std::shared_ptr<usc::DBusEventLoop> const& loop, |
984 | + std::string const& address, |
985 | + std::shared_ptr<usc::InputConfiguration> const& input_config) |
986 | + : loop{loop}, connection{std::make_shared<DBusConnectionHandle>(address.c_str())}, input_config{input_config} |
987 | { |
988 | - auto const& connection = dbus->connection(); |
989 | - connection.request_name(dbus_input_service_name); |
990 | - connection.add_filter(handle_dbus_message_thunk, this); |
991 | + loop->add_connection(connection); |
992 | + connection->request_name(dbus_input_service_name); |
993 | + connection->add_filter(handle_dbus_message_thunk, this); |
994 | } |
995 | |
996 | ::DBusHandlerResult usc::UnityInputService::handle_dbus_message_thunk( |
997 | @@ -63,7 +62,7 @@ |
998 | (input_config.get()->*method)(flag); |
999 | |
1000 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
1001 | - dbus_connection_send(dbus->connection(), reply, nullptr); |
1002 | + dbus_connection_send(*connection, reply, nullptr); |
1003 | } |
1004 | } |
1005 | |
1006 | @@ -79,7 +78,7 @@ |
1007 | (input_config.get()->*method)(value); |
1008 | |
1009 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
1010 | - dbus_connection_send(dbus->connection(), reply, nullptr); |
1011 | + dbus_connection_send(*connection, reply, nullptr); |
1012 | } |
1013 | } |
1014 | |
1015 | @@ -95,7 +94,7 @@ |
1016 | (input_config.get()->*method)(value); |
1017 | |
1018 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
1019 | - dbus_connection_send(dbus->connection(), reply, nullptr); |
1020 | + dbus_connection_send(*connection, reply, nullptr); |
1021 | } |
1022 | } |
1023 | |
1024 | @@ -151,4 +150,3 @@ |
1025 | |
1026 | return DBUS_HANDLER_RESULT_HANDLED; |
1027 | } |
1028 | - |
1029 | |
1030 | === modified file 'src/unity_input_service.h' |
1031 | --- src/unity_input_service.h 2015-08-26 08:00:27 +0000 |
1032 | +++ src/unity_input_service.h 2016-01-27 14:14:14 +0000 |
1033 | @@ -20,18 +20,20 @@ |
1034 | #define USC_UNITY_INPUT_SERVICE_H_ |
1035 | |
1036 | #include <dbus/dbus.h> |
1037 | +#include "dbus_connection_handle.h" |
1038 | #include <memory> |
1039 | |
1040 | namespace usc |
1041 | { |
1042 | -class DBusConnectionThread; |
1043 | +class DBusEventLoop; |
1044 | class InputConfiguration; |
1045 | |
1046 | class UnityInputService |
1047 | { |
1048 | public: |
1049 | UnityInputService( |
1050 | - std::shared_ptr<usc::DBusConnectionThread> const& dbus_thread, |
1051 | + std::shared_ptr<usc::DBusEventLoop> const& loop, |
1052 | + std::string const& address, |
1053 | std::shared_ptr<usc::InputConfiguration> const& input_config); |
1054 | |
1055 | private: |
1056 | @@ -44,7 +46,8 @@ |
1057 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(int32_t)); |
1058 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(double)); |
1059 | |
1060 | - std::shared_ptr<usc::DBusConnectionThread> const dbus; |
1061 | + std::shared_ptr<usc::DBusEventLoop> const loop; |
1062 | + std::shared_ptr<usc::DBusConnectionHandle> connection; |
1063 | std::shared_ptr<usc::InputConfiguration> const input_config; |
1064 | }; |
1065 | |
1066 | |
1067 | === modified file 'src/unity_screen_service.cpp' |
1068 | --- src/unity_screen_service.cpp 2015-08-25 14:35:20 +0000 |
1069 | +++ src/unity_screen_service.cpp 2016-01-27 14:14:14 +0000 |
1070 | @@ -19,7 +19,7 @@ |
1071 | #include "unity_screen_service.h" |
1072 | #include "screen.h" |
1073 | #include "dbus_message_handle.h" |
1074 | -#include "dbus_connection_thread.h" |
1075 | +#include "dbus_event_loop.h" |
1076 | #include "dbus_connection_handle.h" |
1077 | #include "scoped_dbus_error.h" |
1078 | |
1079 | @@ -35,20 +35,22 @@ |
1080 | } |
1081 | |
1082 | usc::UnityScreenService::UnityScreenService( |
1083 | - std::shared_ptr<usc::DBusConnectionThread> const& dbus, |
1084 | + std::shared_ptr<usc::DBusEventLoop> const& loop, |
1085 | + std::string const& address, |
1086 | std::shared_ptr<usc::Screen> const& screen) |
1087 | : screen{screen}, |
1088 | - dbus{dbus}, |
1089 | + loop{loop}, |
1090 | + connection{std::make_shared<DBusConnectionHandle>(address.c_str())}, |
1091 | request_id{0} |
1092 | { |
1093 | - auto const& connection = dbus->connection(); |
1094 | - connection.request_name(dbus_screen_service_name); |
1095 | - connection.add_match( |
1096 | + loop->add_connection(connection); |
1097 | + connection->request_name(dbus_screen_service_name); |
1098 | + connection->add_match( |
1099 | "type='signal'," |
1100 | "sender='org.freedesktop.DBus'," |
1101 | "interface='org.freedesktop.DBus'," |
1102 | "member='NameOwnerChanged'"); |
1103 | - connection.add_filter(handle_dbus_message_thunk, this); |
1104 | + connection->add_filter(handle_dbus_message_thunk, this); |
1105 | |
1106 | screen->register_power_state_change_handler( |
1107 | [this](MirPowerMode mode, PowerStateChangeReason reason) |
1108 | @@ -332,7 +334,7 @@ |
1109 | int32_t const power_state = (power_mode == MirPowerMode::mir_power_mode_off) ? 0 : 1; |
1110 | int32_t const reason_int = static_cast<int32_t>(reason); |
1111 | |
1112 | - dbus->loop().enqueue( |
1113 | + loop->enqueue( |
1114 | [this, power_state, reason_int] |
1115 | { |
1116 | DBusMessageHandle signal{ |
1117 | @@ -344,6 +346,6 @@ |
1118 | DBUS_TYPE_INT32, &reason_int, |
1119 | DBUS_TYPE_INVALID}; |
1120 | |
1121 | - dbus_connection_send(dbus->connection(), signal, nullptr); |
1122 | + dbus_connection_send(*connection, signal, nullptr); |
1123 | }); |
1124 | } |
1125 | |
1126 | === modified file 'src/unity_screen_service.h' |
1127 | --- src/unity_screen_service.h 2015-08-25 14:32:32 +0000 |
1128 | +++ src/unity_screen_service.h 2016-01-27 14:14:14 +0000 |
1129 | @@ -34,13 +34,14 @@ |
1130 | namespace usc |
1131 | { |
1132 | class Screen; |
1133 | -class DBusConnectionThread; |
1134 | +class DBusEventLoop; |
1135 | |
1136 | class UnityScreenService |
1137 | { |
1138 | public: |
1139 | UnityScreenService( |
1140 | - std::shared_ptr<usc::DBusConnectionThread> const& connection, |
1141 | + std::shared_ptr<usc::DBusEventLoop> const& loop, |
1142 | + std::string const& address, |
1143 | std::shared_ptr<usc::Screen> const& screen); |
1144 | |
1145 | private: |
1146 | @@ -64,7 +65,8 @@ |
1147 | MirPowerMode power_mode, PowerStateChangeReason reason); |
1148 | |
1149 | std::shared_ptr<usc::Screen> const screen; |
1150 | - std::shared_ptr<DBusConnectionThread> const dbus; |
1151 | + std::shared_ptr<DBusEventLoop> const loop; |
1152 | + std::shared_ptr<DBusConnectionHandle> connection; |
1153 | |
1154 | std::mutex keep_display_on_mutex; |
1155 | std::unordered_multimap<std::string,int32_t> keep_display_on_ids; |
1156 | |
1157 | === modified file 'tests/CMakeLists.txt' |
1158 | --- tests/CMakeLists.txt 2015-03-17 18:17:14 +0000 |
1159 | +++ tests/CMakeLists.txt 2016-01-27 14:14:14 +0000 |
1160 | @@ -14,5 +14,6 @@ |
1161 | # |
1162 | # Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
1163 | |
1164 | +include_directories(include) |
1165 | add_subdirectory(unit-tests/) |
1166 | add_subdirectory(integration-tests/) |
1167 | |
1168 | === added directory 'tests/include' |
1169 | === added directory 'tests/include/usc' |
1170 | === added directory 'tests/include/usc/test' |
1171 | === added file 'tests/include/usc/test/mock_display.h' |
1172 | --- tests/include/usc/test/mock_display.h 1970-01-01 00:00:00 +0000 |
1173 | +++ tests/include/usc/test/mock_display.h 2016-01-27 14:14:14 +0000 |
1174 | @@ -0,0 +1,67 @@ |
1175 | +/* |
1176 | + * Copyright © 2015 Canonical Ltd. |
1177 | + * |
1178 | + * This program is free software: you can redistribute it and/or modify |
1179 | + * it under the terms of the GNU General Public License version 3 as |
1180 | + * published by the Free Software Foundation. |
1181 | + * |
1182 | + * This program is distributed in the hope that it will be useful, |
1183 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1184 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1185 | + * GNU General Public License for more details. |
1186 | + * |
1187 | + * You should have received a copy of the GNU General Public License |
1188 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1189 | + */ |
1190 | + |
1191 | +#ifndef USC_TEST_MOCK_DISPLAY_H |
1192 | +#define USC_TEST_MOCK_DISPLAY_H |
1193 | + |
1194 | +#include "usc/test/stub_display_configuration.h" |
1195 | + |
1196 | +#include <mir/graphics/display.h> |
1197 | +#include <gmock/gmock.h> |
1198 | + |
1199 | +namespace usc |
1200 | +{ |
1201 | +namespace test |
1202 | +{ |
1203 | +struct MockDisplay : mir::graphics::Display |
1204 | +{ |
1205 | + void for_each_display_sync_group(std::function<void(mir::graphics::DisplaySyncGroup&)> const& f) override |
1206 | + { |
1207 | + } |
1208 | + |
1209 | + std::unique_ptr<mir::graphics::DisplayConfiguration> configuration() const override |
1210 | + { return std::make_unique<usc::test::StubDisplayConfiguration>(); } |
1211 | + |
1212 | + MOCK_METHOD1(configure, void(mir::graphics::DisplayConfiguration const& conf)); |
1213 | + |
1214 | + void register_configuration_change_handler( |
1215 | + mir::graphics::EventHandlerRegister& , |
1216 | + mir::graphics::DisplayConfigurationChangeHandler const& ) override {}; |
1217 | + |
1218 | + void register_pause_resume_handlers( |
1219 | + mir::graphics::EventHandlerRegister&, |
1220 | + mir::graphics::DisplayPauseHandler const&, |
1221 | + mir::graphics::DisplayResumeHandler const&) override |
1222 | + { |
1223 | + } |
1224 | + |
1225 | + void pause() override {}; |
1226 | + |
1227 | + void resume() override {}; |
1228 | + |
1229 | + std::shared_ptr<mir::graphics::Cursor> create_hardware_cursor( |
1230 | + std::shared_ptr<mir::graphics::CursorImage> const&) override |
1231 | + { |
1232 | + return {}; |
1233 | + }; |
1234 | + |
1235 | + std::unique_ptr<mir::graphics::GLContext> create_gl_context() override |
1236 | + { return std::unique_ptr<mir::graphics::GLContext>{};}; |
1237 | +}; |
1238 | +} |
1239 | +} |
1240 | + |
1241 | +#endif |
1242 | |
1243 | === added file 'tests/include/usc/test/mock_input_configuration.h' |
1244 | --- tests/include/usc/test/mock_input_configuration.h 1970-01-01 00:00:00 +0000 |
1245 | +++ tests/include/usc/test/mock_input_configuration.h 2016-01-27 14:14:14 +0000 |
1246 | @@ -0,0 +1,48 @@ |
1247 | +/* |
1248 | + * Copyright © 2015 Canonical Ltd. |
1249 | + * |
1250 | + * This program is free software: you can redistribute it and/or modify |
1251 | + * it under the terms of the GNU General Public License version 3 as |
1252 | + * published by the Free Software Foundation. |
1253 | + * |
1254 | + * This program is distributed in the hope that it will be useful, |
1255 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1256 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1257 | + * GNU General Public License for more details. |
1258 | + * |
1259 | + * You should have received a copy of the GNU General Public License |
1260 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1261 | + * |
1262 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
1263 | + */ |
1264 | + |
1265 | +#ifndef USC_TEST_MOCK_INPUT_CONFIGURATION_H_ |
1266 | +#define USC_TEST_MOCK_INPUT_CONFIGURATION_H_ |
1267 | + |
1268 | +#include "src/input_configuration.h" |
1269 | + |
1270 | +#include <gtest/gtest.h> |
1271 | +#include <gmock/gmock.h> |
1272 | + |
1273 | +namespace usc |
1274 | +{ |
1275 | +namespace test |
1276 | +{ |
1277 | +struct MockInputConfiguration : usc::InputConfiguration |
1278 | +{ |
1279 | +public: |
1280 | + MOCK_METHOD1(set_mouse_primary_button, void(int32_t)); |
1281 | + MOCK_METHOD1(set_mouse_cursor_speed, void(double)); |
1282 | + MOCK_METHOD1(set_mouse_scroll_speed, void(double)); |
1283 | + MOCK_METHOD1(set_touchpad_primary_button, void(int32_t)); |
1284 | + MOCK_METHOD1(set_touchpad_cursor_speed, void(double)); |
1285 | + MOCK_METHOD1(set_touchpad_scroll_speed, void(double)); |
1286 | + MOCK_METHOD1(set_two_finger_scroll, void(bool)); |
1287 | + MOCK_METHOD1(set_tap_to_click, void(bool)); |
1288 | + MOCK_METHOD1(set_disable_touchpad_with_mouse, void(bool)); |
1289 | + MOCK_METHOD1(set_disable_touchpad_while_typing, void(bool)); |
1290 | +}; |
1291 | +} |
1292 | +} |
1293 | + |
1294 | +#endif |
1295 | |
1296 | === added file 'tests/include/usc/test/mock_screen.h' |
1297 | --- tests/include/usc/test/mock_screen.h 1970-01-01 00:00:00 +0000 |
1298 | +++ tests/include/usc/test/mock_screen.h 2016-01-27 14:14:14 +0000 |
1299 | @@ -0,0 +1,57 @@ |
1300 | +/* |
1301 | + * Copyright © 2015 Canonical Ltd. |
1302 | + * |
1303 | + * This program is free software: you can redistribute it and/or modify |
1304 | + * it under the terms of the GNU General Public License version 3 as |
1305 | + * published by the Free Software Foundation. |
1306 | + * |
1307 | + * This program is distributed in the hope that it will be useful, |
1308 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1309 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1310 | + * GNU General Public License for more details. |
1311 | + * |
1312 | + * You should have received a copy of the GNU General Public License |
1313 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1314 | + * |
1315 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
1316 | + */ |
1317 | + |
1318 | +#ifndef USC_TEST_MOCK_SCREEN_H_ |
1319 | +#define USC_TEST_MOCK_SCREEN_H_ |
1320 | + |
1321 | +#include "src/screen.h" |
1322 | + |
1323 | +#include <gtest/gtest.h> |
1324 | +#include <gmock/gmock.h> |
1325 | +namespace usc |
1326 | +{ |
1327 | +namespace test |
1328 | +{ |
1329 | + |
1330 | +struct MockScreen : usc::Screen |
1331 | +{ |
1332 | + MOCK_METHOD1(enable_inactivity_timers, void(bool enable)); |
1333 | + MOCK_METHOD0(keep_display_on_temporarily, void()); |
1334 | + |
1335 | + MOCK_METHOD0(get_screen_power_mode, MirPowerMode()); |
1336 | + MOCK_METHOD2(set_screen_power_mode, void(MirPowerMode mode, PowerStateChangeReason reason)); |
1337 | + MOCK_METHOD1(keep_display_on, void(bool on)); |
1338 | + MOCK_METHOD1(set_brightness, void(int brightness)); |
1339 | + MOCK_METHOD1(enable_auto_brightness, void(bool enable)); |
1340 | + MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout)); |
1341 | + |
1342 | + MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled)); |
1343 | + |
1344 | + void register_power_state_change_handler( |
1345 | + usc::PowerStateChangeHandler const& handler) |
1346 | + { |
1347 | + power_state_change_handler = handler; |
1348 | + } |
1349 | + |
1350 | + usc::PowerStateChangeHandler power_state_change_handler; |
1351 | +}; |
1352 | + |
1353 | +} |
1354 | +} |
1355 | + |
1356 | +#endif |
1357 | |
1358 | === added file 'tests/include/usc/test/stub_display_configuration.h' |
1359 | --- tests/include/usc/test/stub_display_configuration.h 1970-01-01 00:00:00 +0000 |
1360 | +++ tests/include/usc/test/stub_display_configuration.h 2016-01-27 14:14:14 +0000 |
1361 | @@ -0,0 +1,65 @@ |
1362 | +/* |
1363 | + * Copyright © 2015 Canonical Ltd. |
1364 | + * |
1365 | + * This program is free software: you can redistribute it and/or modify |
1366 | + * it under the terms of the GNU General Public License version 3 as |
1367 | + * published by the Free Software Foundation. |
1368 | + * |
1369 | + * This program is distributed in the hope that it will be useful, |
1370 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1371 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1372 | + * GNU General Public License for more details. |
1373 | + * |
1374 | + * You should have received a copy of the GNU General Public License |
1375 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1376 | + */ |
1377 | + |
1378 | +#ifndef USC_TEST_STUB_DISPLAY_CONFIGURATION_H_ |
1379 | +#define USC_TEST_STUB_DISPLAY_CONFIGURATION_H_ |
1380 | + |
1381 | +#include <mir/graphics/display_configuration.h> |
1382 | + |
1383 | +namespace usc |
1384 | +{ |
1385 | +namespace test |
1386 | +{ |
1387 | + |
1388 | +struct StubDisplayConfiguration : mir::graphics::DisplayConfiguration |
1389 | +{ |
1390 | + StubDisplayConfiguration() |
1391 | + { |
1392 | + conf_output.power_mode = MirPowerMode::mir_power_mode_on; |
1393 | + } |
1394 | + |
1395 | + StubDisplayConfiguration(mir::graphics::DisplayConfigurationOutput const& output) |
1396 | + : conf_output(output) |
1397 | + { |
1398 | + } |
1399 | + |
1400 | + void for_each_card(std::function<void(mir::graphics::DisplayConfigurationCard const&)>) const override |
1401 | + { |
1402 | + } |
1403 | + |
1404 | + void for_each_output(std::function<void(mir::graphics::DisplayConfigurationOutput const&)> f) const override |
1405 | + { |
1406 | + f(conf_output); |
1407 | + } |
1408 | + |
1409 | + void for_each_output(std::function<void(mir::graphics::UserDisplayConfigurationOutput&)> f) |
1410 | + { |
1411 | + mir::graphics::UserDisplayConfigurationOutput user{conf_output}; |
1412 | + f(user); |
1413 | + } |
1414 | + |
1415 | + std::unique_ptr<mir::graphics::DisplayConfiguration> clone() const override |
1416 | + { |
1417 | + return std::make_unique<StubDisplayConfiguration>(conf_output); |
1418 | + } |
1419 | + |
1420 | + mir::graphics::DisplayConfigurationOutput conf_output; |
1421 | +}; |
1422 | + |
1423 | +} |
1424 | +} |
1425 | + |
1426 | +#endif |
1427 | |
1428 | === modified file 'tests/integration-tests/CMakeLists.txt' |
1429 | --- tests/integration-tests/CMakeLists.txt 2015-09-22 16:17:40 +0000 |
1430 | +++ tests/integration-tests/CMakeLists.txt 2016-01-27 14:14:14 +0000 |
1431 | @@ -33,9 +33,12 @@ |
1432 | dbus_bus.cpp |
1433 | dbus_client.cpp |
1434 | spin_wait.cpp |
1435 | + unity_screen_dbus_client.cpp |
1436 | + unity_input_dbus_client.cpp |
1437 | test_dbus_event_loop.cpp |
1438 | test_unity_screen_service.cpp |
1439 | test_unity_input_service.cpp |
1440 | + test_unity_services.cpp |
1441 | test_external_spinner.cpp |
1442 | test_powerd_mediator.cpp |
1443 | test_deadlock_lp1491566.cpp |
1444 | |
1445 | === modified file 'tests/integration-tests/test_dbus_event_loop.cpp' |
1446 | --- tests/integration-tests/test_dbus_event_loop.cpp 2015-05-27 09:42:40 +0000 |
1447 | +++ tests/integration-tests/test_dbus_event_loop.cpp 2016-01-27 14:14:14 +0000 |
1448 | @@ -79,8 +79,9 @@ |
1449 | { |
1450 | ADBusEventLoop() |
1451 | { |
1452 | - connection.request_name(test_service_name); |
1453 | - connection.add_filter(handle_dbus_message_thunk, this); |
1454 | + dbus_event_loop.add_connection(connection); |
1455 | + connection->request_name(test_service_name); |
1456 | + connection->add_filter(handle_dbus_message_thunk, this); |
1457 | |
1458 | std::promise<void> event_loop_started; |
1459 | auto event_loop_started_future = event_loop_started.get_future(); |
1460 | @@ -102,8 +103,7 @@ |
1461 | } |
1462 | |
1463 | static ::DBusHandlerResult handle_dbus_message_thunk( |
1464 | - ::DBusConnection* connection, DBusMessage* message, void* user_data) |
1465 | - { |
1466 | + ::DBusConnection* connection, DBusMessage* message, void* user_data) { |
1467 | auto const a_dbus_event_loop = static_cast<ADBusEventLoop*>(user_data); |
1468 | return a_dbus_event_loop->handle_dbus_message(connection, message, user_data); |
1469 | } |
1470 | @@ -142,8 +142,8 @@ |
1471 | |
1472 | ut::DBusBus bus; |
1473 | |
1474 | - usc::DBusConnectionHandle connection{bus.address().c_str()}; |
1475 | - usc::DBusEventLoop dbus_event_loop{connection}; |
1476 | + std::shared_ptr<usc::DBusConnectionHandle> connection{std::make_shared<usc::DBusConnectionHandle>(bus.address())}; |
1477 | + usc::DBusEventLoop dbus_event_loop{}; |
1478 | std::thread dbus_loop_thread; |
1479 | TestDBusClient client{bus.address()}; |
1480 | }; |
1481 | @@ -173,7 +173,7 @@ |
1482 | test_service_interface, |
1483 | "signal")}; |
1484 | |
1485 | - dbus_connection_send(connection, msg, nullptr); |
1486 | + dbus_connection_send(*connection, msg, nullptr); |
1487 | }); |
1488 | |
1489 | auto const reply = client.listen_for_signal(); |
1490 | @@ -214,7 +214,7 @@ |
1491 | |
1492 | DBusPendingCall* pending{nullptr}; |
1493 | dbus_connection_send_with_reply( |
1494 | - connection, msg, &pending, timeout_ms); |
1495 | + *connection, msg, &pending, timeout_ms); |
1496 | dbus_pending_call_set_notify( |
1497 | pending, &pending_complete, &pending_promise, nullptr); |
1498 | }); |
1499 | |
1500 | === modified file 'tests/integration-tests/test_deadlock_lp1491566.cpp' |
1501 | --- tests/integration-tests/test_deadlock_lp1491566.cpp 2015-09-29 13:05:56 +0000 |
1502 | +++ tests/integration-tests/test_deadlock_lp1491566.cpp 2016-01-27 14:14:14 +0000 |
1503 | @@ -21,11 +21,11 @@ |
1504 | #include "src/screen_hardware.h" |
1505 | #include "src/power_state_change_reason.h" |
1506 | #include "spin_wait.h" |
1507 | +#include "usc/test/stub_display_configuration.h" |
1508 | +#include "usc/test/mock_display.h" |
1509 | |
1510 | #include <mir/compositor/compositor.h> |
1511 | #include <mir/main_loop.h> |
1512 | -#include <mir/graphics/display.h> |
1513 | -#include <mir/graphics/display_configuration.h> |
1514 | #include <mir/graphics/gl_context.h> |
1515 | #include <mir/input/touch_visualizer.h> |
1516 | |
1517 | @@ -36,6 +36,7 @@ |
1518 | #include <future> |
1519 | |
1520 | namespace mg = mir::graphics; |
1521 | +namespace ut = usc::test; |
1522 | |
1523 | namespace |
1524 | { |
1525 | @@ -46,71 +47,6 @@ |
1526 | void stop() override {} |
1527 | }; |
1528 | |
1529 | -struct StubDisplayConfiguration : mg::DisplayConfiguration |
1530 | -{ |
1531 | - StubDisplayConfiguration() |
1532 | - { |
1533 | - conf_output.power_mode = MirPowerMode::mir_power_mode_on; |
1534 | - } |
1535 | - |
1536 | - void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const override |
1537 | - { |
1538 | - } |
1539 | - |
1540 | - void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)> f) const override |
1541 | - { |
1542 | - f(conf_output); |
1543 | - } |
1544 | - |
1545 | - void for_each_output(std::function<void(mg::UserDisplayConfigurationOutput&)> f) |
1546 | - { |
1547 | - mg::UserDisplayConfigurationOutput user{conf_output}; |
1548 | - f(user); |
1549 | - } |
1550 | - |
1551 | - mg::DisplayConfigurationOutput conf_output; |
1552 | -}; |
1553 | - |
1554 | -struct StubDisplay : mg::Display |
1555 | -{ |
1556 | - void for_each_display_sync_group(std::function<void(mg::DisplaySyncGroup&)> const& f) override |
1557 | - { |
1558 | - } |
1559 | - |
1560 | - std::unique_ptr<mg::DisplayConfiguration> configuration() const override |
1561 | - { |
1562 | - return std::unique_ptr<mg::DisplayConfiguration>{new StubDisplayConfiguration{}}; |
1563 | - } |
1564 | - |
1565 | - void configure(mg::DisplayConfiguration const&) override {} |
1566 | - |
1567 | - void register_configuration_change_handler( |
1568 | - mg::EventHandlerRegister& , |
1569 | - mg::DisplayConfigurationChangeHandler const& ) override |
1570 | - { |
1571 | - } |
1572 | - |
1573 | - void register_pause_resume_handlers( |
1574 | - mg::EventHandlerRegister&, |
1575 | - mg::DisplayPauseHandler const&, |
1576 | - mg::DisplayResumeHandler const&) override |
1577 | - { |
1578 | - } |
1579 | - |
1580 | - void pause() override {} |
1581 | - void resume() override {} |
1582 | - |
1583 | - std::shared_ptr<mg::Cursor> create_hardware_cursor( |
1584 | - std::shared_ptr<mg::CursorImage> const&) override |
1585 | - { |
1586 | - return{}; |
1587 | - } |
1588 | - |
1589 | - std::unique_ptr<mg::GLContext> create_gl_context() override |
1590 | - { |
1591 | - return std::unique_ptr<mg::GLContext>{}; |
1592 | - } |
1593 | -}; |
1594 | |
1595 | struct StubScreenHardware : usc::ScreenHardware |
1596 | { |
1597 | @@ -219,7 +155,7 @@ |
1598 | TestMirScreen mir_screen{ |
1599 | std::make_shared<StubScreenHardware>(), |
1600 | std::make_shared<NullCompositor>(), |
1601 | - std::make_shared<StubDisplay>(), |
1602 | + std::make_shared<::testing::NiceMock<ut::MockDisplay>>(), |
1603 | std::make_shared<NullTouchVisualizer>(), |
1604 | main_loop, |
1605 | server.the_clock(), |
1606 | |
1607 | === modified file 'tests/integration-tests/test_powerd_mediator.cpp' |
1608 | --- tests/integration-tests/test_powerd_mediator.cpp 2015-07-17 12:43:46 +0000 |
1609 | +++ tests/integration-tests/test_powerd_mediator.cpp 2016-01-27 14:14:14 +0000 |
1610 | @@ -41,9 +41,10 @@ |
1611 | dbus_bool_t auto_brightness_supported, |
1612 | StartNow start_now) |
1613 | : auto_brightness_supported{auto_brightness_supported}, |
1614 | - connection{address.c_str()}, |
1615 | - dbus_event_loop{connection} |
1616 | + connection{std::make_shared<usc::DBusConnectionHandle>(address)}, |
1617 | + dbus_event_loop{} |
1618 | { |
1619 | + dbus_event_loop.add_connection(connection); |
1620 | if (start_now == StartNow::yes) |
1621 | start(); |
1622 | } |
1623 | @@ -60,8 +61,8 @@ |
1624 | ON_CALL(*this, dbus_setUserBrightness(normal_brightness)) |
1625 | .WillByDefault(WakeUp(&initial_setup_done)); |
1626 | |
1627 | - connection.request_name(powerd_service_name); |
1628 | - connection.add_filter(handle_dbus_message_thunk, this); |
1629 | + connection->request_name(powerd_service_name); |
1630 | + connection->add_filter(handle_dbus_message_thunk, this); |
1631 | |
1632 | std::promise<void> event_loop_started; |
1633 | auto event_loop_started_future = event_loop_started.get_future(); |
1634 | @@ -104,7 +105,7 @@ |
1635 | DBUS_TYPE_INT32, &state, |
1636 | DBUS_TYPE_INVALID}; |
1637 | |
1638 | - dbus_connection_send(connection, signal, nullptr); |
1639 | + dbus_connection_send(*connection, signal, nullptr); |
1640 | } |
1641 | |
1642 | private: |
1643 | @@ -230,7 +231,7 @@ |
1644 | |
1645 | ut::WaitCondition initial_setup_done; |
1646 | |
1647 | - usc::DBusConnectionHandle connection; |
1648 | + std::shared_ptr<usc::DBusConnectionHandle> connection; |
1649 | usc::DBusEventLoop dbus_event_loop; |
1650 | std::thread dbus_loop_thread; |
1651 | }; |
1652 | |
1653 | === modified file 'tests/integration-tests/test_unity_input_service.cpp' |
1654 | --- tests/integration-tests/test_unity_input_service.cpp 2015-08-28 15:57:25 +0000 |
1655 | +++ tests/integration-tests/test_unity_input_service.cpp 2016-01-27 14:14:14 +0000 |
1656 | @@ -19,15 +19,16 @@ |
1657 | #include "src/unity_input_service.h" |
1658 | #include "src/dbus_connection_handle.h" |
1659 | #include "src/dbus_connection_thread.h" |
1660 | +#include "src/dbus_event_loop.h" |
1661 | #include "src/dbus_message_handle.h" |
1662 | -#include "src/input_configuration.h" |
1663 | #include "src/unity_input_service_introspection.h" |
1664 | + |
1665 | #include "wait_condition.h" |
1666 | #include "dbus_bus.h" |
1667 | #include "dbus_client.h" |
1668 | +#include "unity_input_dbus_client.h" |
1669 | |
1670 | -#include <gtest/gtest.h> |
1671 | -#include <gmock/gmock.h> |
1672 | +#include "usc/test/mock_input_configuration.h" |
1673 | |
1674 | #include <stdexcept> |
1675 | #include <memory> |
1676 | @@ -37,128 +38,19 @@ |
1677 | namespace |
1678 | { |
1679 | |
1680 | -struct MockInputConfiguration : usc::InputConfiguration |
1681 | -{ |
1682 | -public: |
1683 | - MOCK_METHOD1(set_mouse_primary_button, void(int32_t)); |
1684 | - MOCK_METHOD1(set_mouse_cursor_speed, void(double)); |
1685 | - MOCK_METHOD1(set_mouse_scroll_speed, void(double)); |
1686 | - MOCK_METHOD1(set_touchpad_primary_button, void(int32_t)); |
1687 | - MOCK_METHOD1(set_touchpad_cursor_speed, void(double)); |
1688 | - MOCK_METHOD1(set_touchpad_scroll_speed, void(double)); |
1689 | - MOCK_METHOD1(set_two_finger_scroll, void(bool)); |
1690 | - MOCK_METHOD1(set_tap_to_click, void(bool)); |
1691 | - MOCK_METHOD1(set_disable_touchpad_with_mouse, void(bool)); |
1692 | - MOCK_METHOD1(set_disable_touchpad_while_typing, void(bool)); |
1693 | -}; |
1694 | - |
1695 | -class UnityInputDBusClient : public ut::DBusClient |
1696 | -{ |
1697 | -public: |
1698 | - UnityInputDBusClient(std::string const& address) |
1699 | - : ut::DBusClient{ |
1700 | - address, |
1701 | - "com.canonical.Unity.Input", |
1702 | - "/com/canonical/Unity/Input"} |
1703 | - { |
1704 | - } |
1705 | - |
1706 | - ut::DBusAsyncReplyString request_introspection() |
1707 | - { |
1708 | - return invoke_with_reply<ut::DBusAsyncReplyString>( |
1709 | - "org.freedesktop.DBus.Introspectable", "Introspect", |
1710 | - DBUS_TYPE_INVALID); |
1711 | - } |
1712 | - |
1713 | - ut::DBusAsyncReplyVoid request(char const* requestName, int32_t value) |
1714 | - { |
1715 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1716 | - unity_input_interface, requestName, |
1717 | - DBUS_TYPE_INT32, &value, |
1718 | - DBUS_TYPE_INVALID); |
1719 | - } |
1720 | - |
1721 | - ut::DBusAsyncReplyVoid request_set_mouse_primary_button(int32_t button) |
1722 | - { |
1723 | - return request("setMousePrimaryButton", button); |
1724 | - } |
1725 | - |
1726 | - ut::DBusAsyncReplyVoid request_set_touchpad_primary_button(int32_t button) |
1727 | - { |
1728 | - return request("setTouchpadPrimaryButton", button); |
1729 | - } |
1730 | - |
1731 | - ut::DBusAsyncReplyVoid request(char const* requestName, double value) |
1732 | - { |
1733 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1734 | - unity_input_interface, requestName, |
1735 | - DBUS_TYPE_DOUBLE, &value, |
1736 | - DBUS_TYPE_INVALID); |
1737 | - } |
1738 | - |
1739 | - ut::DBusAsyncReplyVoid request_set_mouse_cursor_speed(double speed) |
1740 | - { |
1741 | - return request("setMouseCursorSpeed", speed); |
1742 | - } |
1743 | - |
1744 | - ut::DBusAsyncReplyVoid request_set_mouse_scroll_speed(double speed) |
1745 | - { |
1746 | - return request("setMouseScrollSpeed", speed); |
1747 | - } |
1748 | - |
1749 | - ut::DBusAsyncReplyVoid request_set_touchpad_cursor_speed(double speed) |
1750 | - { |
1751 | - return request("setTouchpadCursorSpeed", speed); |
1752 | - } |
1753 | - |
1754 | - ut::DBusAsyncReplyVoid request_set_touchpad_scroll_speed(double speed) |
1755 | - { |
1756 | - return request("setTouchpadScrollSpeed", speed); |
1757 | - } |
1758 | - |
1759 | - ut::DBusAsyncReplyVoid request(char const* requestName, bool value) |
1760 | - { |
1761 | - dbus_bool_t copied = value; |
1762 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1763 | - unity_input_interface, requestName, |
1764 | - DBUS_TYPE_BOOLEAN, &copied, |
1765 | - DBUS_TYPE_INVALID); |
1766 | - } |
1767 | - |
1768 | - ut::DBusAsyncReplyVoid request_set_touchpad_two_finger_scroll(bool enabled) |
1769 | - { |
1770 | - return request("setTouchpadTwoFingerScroll", enabled); |
1771 | - } |
1772 | - |
1773 | - ut::DBusAsyncReplyVoid request_set_touchpad_tap_to_click(bool enabled) |
1774 | - { |
1775 | - return request("setTouchpadTapToClick", enabled); |
1776 | - } |
1777 | - |
1778 | - ut::DBusAsyncReplyVoid request_set_touchpad_disable_with_mouse(bool enabled) |
1779 | - { |
1780 | - return request("setTouchpadDisableWithMouse", enabled); |
1781 | - } |
1782 | - |
1783 | - ut::DBusAsyncReplyVoid request_set_touchpad_disable_while_typing(bool enabled) |
1784 | - { |
1785 | - return request("setTouchpadDisableWhileTyping", enabled); |
1786 | - } |
1787 | - |
1788 | - char const* const unity_input_interface = "com.canonical.Unity.Input"; |
1789 | -}; |
1790 | - |
1791 | struct AUnityInputService : testing::Test |
1792 | { |
1793 | std::chrono::seconds const default_timeout{3}; |
1794 | ut::DBusBus bus; |
1795 | |
1796 | - std::shared_ptr<MockInputConfiguration> const mock_input_configuration = |
1797 | - std::make_shared<testing::NiceMock<MockInputConfiguration>>(); |
1798 | - UnityInputDBusClient client{bus.address()}; |
1799 | + std::shared_ptr<ut::MockInputConfiguration> const mock_input_configuration = |
1800 | + std::make_shared<testing::NiceMock<ut::MockInputConfiguration>>(); |
1801 | + ut::UnityInputDBusClient client{bus.address()}; |
1802 | + std::shared_ptr<usc::DBusEventLoop> const dbus_loop= |
1803 | + std::make_shared<usc::DBusEventLoop>(); |
1804 | + usc::UnityInputService service{dbus_loop, bus.address(), mock_input_configuration}; |
1805 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = |
1806 | - std::make_shared<usc::DBusConnectionThread>(bus.address()); |
1807 | - usc::UnityInputService service{dbus_thread, mock_input_configuration}; |
1808 | + std::make_shared<usc::DBusConnectionThread>(dbus_loop); |
1809 | }; |
1810 | |
1811 | } |
1812 | |
1813 | === modified file 'tests/integration-tests/test_unity_screen_service.cpp' |
1814 | --- tests/integration-tests/test_unity_screen_service.cpp 2015-08-25 14:27:23 +0000 |
1815 | +++ tests/integration-tests/test_unity_screen_service.cpp 2016-01-27 14:14:14 +0000 |
1816 | @@ -19,14 +19,16 @@ |
1817 | #include "src/unity_screen_service.h" |
1818 | #include "src/dbus_connection_handle.h" |
1819 | #include "src/dbus_connection_thread.h" |
1820 | +#include "src/dbus_event_loop.h" |
1821 | #include "src/dbus_message_handle.h" |
1822 | #include "src/screen.h" |
1823 | #include "src/power_state_change_reason.h" |
1824 | #include "src/unity_screen_service_introspection.h" |
1825 | #include "wait_condition.h" |
1826 | #include "dbus_bus.h" |
1827 | -#include "dbus_client.h" |
1828 | +#include "unity_screen_dbus_client.h" |
1829 | |
1830 | +#include "usc/test/mock_screen.h" |
1831 | #include <gtest/gtest.h> |
1832 | #include <gmock/gmock.h> |
1833 | |
1834 | @@ -38,157 +40,20 @@ |
1835 | namespace |
1836 | { |
1837 | |
1838 | -struct MockScreen : usc::Screen |
1839 | -{ |
1840 | - MOCK_METHOD1(enable_inactivity_timers, void(bool enable)); |
1841 | - MOCK_METHOD0(keep_display_on_temporarily, void()); |
1842 | - |
1843 | - MOCK_METHOD0(get_screen_power_mode, MirPowerMode()); |
1844 | - MOCK_METHOD2(set_screen_power_mode, void(MirPowerMode mode, PowerStateChangeReason reason)); |
1845 | - MOCK_METHOD1(keep_display_on, void(bool on)); |
1846 | - MOCK_METHOD1(set_brightness, void(int brightness)); |
1847 | - MOCK_METHOD1(enable_auto_brightness, void(bool enable)); |
1848 | - MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout)); |
1849 | - |
1850 | - MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled)); |
1851 | - |
1852 | - void register_power_state_change_handler( |
1853 | - usc::PowerStateChangeHandler const& handler) |
1854 | - { |
1855 | - power_state_change_handler = handler; |
1856 | - } |
1857 | - |
1858 | - usc::PowerStateChangeHandler power_state_change_handler; |
1859 | -}; |
1860 | - |
1861 | -class UnityScreenDBusClient : public ut::DBusClient |
1862 | -{ |
1863 | -public: |
1864 | - UnityScreenDBusClient(std::string const& address) |
1865 | - : ut::DBusClient{ |
1866 | - address, |
1867 | - "com.canonical.Unity.Screen", |
1868 | - "/com/canonical/Unity/Screen"} |
1869 | - { |
1870 | - connection.add_match( |
1871 | - "type='signal'," |
1872 | - "interface='com.canonical.Unity.Screen'," |
1873 | - "member='DisplayPowerStateChange'"); |
1874 | - } |
1875 | - |
1876 | - ut::DBusAsyncReplyString request_introspection() |
1877 | - { |
1878 | - return invoke_with_reply<ut::DBusAsyncReplyString>( |
1879 | - "org.freedesktop.DBus.Introspectable", "Introspect", |
1880 | - DBUS_TYPE_INVALID); |
1881 | - } |
1882 | - |
1883 | - ut::DBusAsyncReplyVoid request_set_user_brightness(int32_t brightness) |
1884 | - { |
1885 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1886 | - unity_screen_interface, "setUserBrightness", |
1887 | - DBUS_TYPE_INT32, &brightness, |
1888 | - DBUS_TYPE_INVALID); |
1889 | - } |
1890 | - |
1891 | - ut::DBusAsyncReplyVoid request_user_auto_brightness_enable(bool enabled) |
1892 | - { |
1893 | - dbus_bool_t const e = enabled ? TRUE : FALSE; |
1894 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1895 | - unity_screen_interface, "userAutobrightnessEnable", |
1896 | - DBUS_TYPE_BOOLEAN, &e, |
1897 | - DBUS_TYPE_INVALID); |
1898 | - } |
1899 | - |
1900 | - ut::DBusAsyncReplyVoid request_set_inactivity_timeouts( |
1901 | - int32_t poweroff_timeout, int32_t dimmer_timeout) |
1902 | - { |
1903 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1904 | - unity_screen_interface, "setInactivityTimeouts", |
1905 | - DBUS_TYPE_INT32, &poweroff_timeout, |
1906 | - DBUS_TYPE_INT32, &dimmer_timeout, |
1907 | - DBUS_TYPE_INVALID); |
1908 | - } |
1909 | - |
1910 | - ut::DBusAsyncReplyVoid request_set_touch_visualization_enabled(bool enabled) |
1911 | - { |
1912 | - dbus_bool_t const e = enabled ? TRUE : FALSE; |
1913 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1914 | - unity_screen_interface, "setTouchVisualizationEnabled", |
1915 | - DBUS_TYPE_BOOLEAN, &e, |
1916 | - DBUS_TYPE_INVALID); |
1917 | - } |
1918 | - |
1919 | - ut::DBusAsyncReplyBool request_set_screen_power_mode( |
1920 | - std::string const& mode, int reason) |
1921 | - { |
1922 | - auto mode_cstr = mode.c_str(); |
1923 | - return invoke_with_reply<ut::DBusAsyncReplyBool>( |
1924 | - unity_screen_interface, "setScreenPowerMode", |
1925 | - DBUS_TYPE_STRING, &mode_cstr, |
1926 | - DBUS_TYPE_INT32, &reason, |
1927 | - DBUS_TYPE_INVALID); |
1928 | - } |
1929 | - |
1930 | - ut::DBusAsyncReplyInt request_keep_display_on() |
1931 | - { |
1932 | - return invoke_with_reply<ut::DBusAsyncReplyInt>( |
1933 | - unity_screen_interface, "keepDisplayOn", |
1934 | - DBUS_TYPE_INVALID); |
1935 | - } |
1936 | - |
1937 | - ut::DBusAsyncReplyVoid request_remove_display_on_request(int id) |
1938 | - { |
1939 | - return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
1940 | - unity_screen_interface, "removeDisplayOnRequest", |
1941 | - DBUS_TYPE_INT32, &id, |
1942 | - DBUS_TYPE_INVALID); |
1943 | - } |
1944 | - |
1945 | - ut::DBusAsyncReply request_invalid_method() |
1946 | - { |
1947 | - return invoke_with_reply<ut::DBusAsyncReply>( |
1948 | - unity_screen_interface, "invalidMethod", |
1949 | - DBUS_TYPE_INVALID); |
1950 | - } |
1951 | - |
1952 | - ut::DBusAsyncReply request_method_with_invalid_arguments() |
1953 | - { |
1954 | - char const* const str = "abcd"; |
1955 | - return invoke_with_reply<ut::DBusAsyncReply>( |
1956 | - unity_screen_interface, "setUserBrightness", |
1957 | - DBUS_TYPE_STRING, &str, |
1958 | - DBUS_TYPE_INVALID); |
1959 | - } |
1960 | - |
1961 | - usc::DBusMessageHandle listen_for_power_state_change_signal() |
1962 | - { |
1963 | - while (true) |
1964 | - { |
1965 | - dbus_connection_read_write(connection, 1); |
1966 | - auto msg = usc::DBusMessageHandle{dbus_connection_pop_message(connection)}; |
1967 | - |
1968 | - if (msg && dbus_message_is_signal(msg, "com.canonical.Unity.Screen", "DisplayPowerStateChange")) |
1969 | - { |
1970 | - return msg; |
1971 | - } |
1972 | - } |
1973 | - } |
1974 | - |
1975 | - char const* const unity_screen_interface = "com.canonical.Unity.Screen"; |
1976 | -}; |
1977 | - |
1978 | struct AUnityScreenService : testing::Test |
1979 | { |
1980 | std::chrono::seconds const default_timeout{3}; |
1981 | ut::DBusBus bus; |
1982 | |
1983 | - std::shared_ptr<MockScreen> const mock_screen = |
1984 | - std::make_shared<testing::NiceMock<MockScreen>>(); |
1985 | - UnityScreenDBusClient client{bus.address()}; |
1986 | + std::shared_ptr<ut::MockScreen> const mock_screen = |
1987 | + std::make_shared<testing::NiceMock<ut::MockScreen>>(); |
1988 | + ut::UnityScreenDBusClient client{bus.address()}; |
1989 | + std::shared_ptr<usc::DBusEventLoop> const dbus_loop= |
1990 | + std::make_shared<usc::DBusEventLoop>(); |
1991 | + usc::UnityScreenService service{dbus_loop, bus.address(), mock_screen}; |
1992 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = |
1993 | - std::make_shared<usc::DBusConnectionThread>(bus.address()); |
1994 | - usc::UnityScreenService service{dbus_thread, mock_screen}; |
1995 | + std::make_shared<usc::DBusConnectionThread>(dbus_loop); |
1996 | + |
1997 | }; |
1998 | |
1999 | } |
2000 | @@ -340,7 +205,7 @@ |
2001 | { |
2002 | using namespace testing; |
2003 | |
2004 | - UnityScreenDBusClient other_client{bus.address()}; |
2005 | + ut::UnityScreenDBusClient other_client{bus.address()}; |
2006 | |
2007 | EXPECT_CALL(*mock_screen, keep_display_on(true)).Times(4); |
2008 | EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0); |
2009 | |
2010 | === added file 'tests/integration-tests/test_unity_services.cpp' |
2011 | --- tests/integration-tests/test_unity_services.cpp 1970-01-01 00:00:00 +0000 |
2012 | +++ tests/integration-tests/test_unity_services.cpp 2016-01-27 14:14:14 +0000 |
2013 | @@ -0,0 +1,82 @@ |
2014 | +/* |
2015 | + * Copyright © 2016 Canonical Ltd. |
2016 | + * |
2017 | + * This program is free software: you can redistribute it and/or modify |
2018 | + * it under the terms of the GNU General Public License version 3 as |
2019 | + * published by the Free Software Foundation. |
2020 | + * |
2021 | + * This program is distributed in the hope that it will be useful, |
2022 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2023 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2024 | + * GNU General Public License for more details. |
2025 | + * |
2026 | + * You should have received a copy of the GNU General Public License |
2027 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2028 | + * |
2029 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2030 | + */ |
2031 | +#include "src/unity_input_service.h" |
2032 | +#include "src/dbus_connection_handle.h" |
2033 | +#include "src/dbus_connection_thread.h" |
2034 | +#include "src/dbus_event_loop.h" |
2035 | +#include "src/dbus_message_handle.h" |
2036 | +#include "src/unity_screen_service.h" |
2037 | +#include "src/unity_input_service_introspection.h" |
2038 | +#include "src/unity_screen_service_introspection.h" |
2039 | + |
2040 | +#include "wait_condition.h" |
2041 | +#include "dbus_bus.h" |
2042 | +#include "dbus_client.h" |
2043 | +#include "unity_input_dbus_client.h" |
2044 | +#include "unity_screen_dbus_client.h" |
2045 | + |
2046 | +#include "usc/test/mock_input_configuration.h" |
2047 | +#include "usc/test/mock_screen.h" |
2048 | + |
2049 | +namespace ut = usc::test; |
2050 | +using namespace testing; |
2051 | + |
2052 | +namespace |
2053 | +{ |
2054 | + |
2055 | +struct UnityServices : testing::Test |
2056 | +{ |
2057 | + std::chrono::seconds const default_timeout{3}; |
2058 | + ut::DBusBus bus; |
2059 | + |
2060 | + ut::UnityScreenDBusClient screen_client{bus.address()}; |
2061 | + ut::UnityInputDBusClient input_client{bus.address()}; |
2062 | + std::shared_ptr<ut::MockScreen> const mock_screen = |
2063 | + std::make_shared<testing::NiceMock<ut::MockScreen>>(); |
2064 | + std::shared_ptr<ut::MockInputConfiguration> const mock_input_configuration = |
2065 | + std::make_shared<testing::NiceMock<ut::MockInputConfiguration>>(); |
2066 | + std::shared_ptr<usc::DBusEventLoop> const dbus_loop= |
2067 | + std::make_shared<usc::DBusEventLoop>(); |
2068 | + usc::UnityScreenService screen_service{dbus_loop, bus.address(), mock_screen}; |
2069 | + usc::UnityInputService input_service{dbus_loop, bus.address(), mock_input_configuration}; |
2070 | + std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = |
2071 | + std::make_shared<usc::DBusConnectionThread>(dbus_loop); |
2072 | +}; |
2073 | + |
2074 | +} |
2075 | + |
2076 | +TEST_F(UnityServices, offer_screen_introspection) |
2077 | +{ |
2078 | + auto reply = screen_client.request_introspection(); |
2079 | + EXPECT_THAT(reply.get(), Eq(unity_screen_service_introspection)); |
2080 | +} |
2081 | + |
2082 | +TEST_F(UnityServices, offer_input_introspection) |
2083 | +{ |
2084 | + auto reply = input_client.request_introspection(); |
2085 | + EXPECT_THAT(reply.get(), Eq(unity_input_service_introspection)); |
2086 | +} |
2087 | + |
2088 | +TEST_F(UnityServices, provides_access_to_input_methods) |
2089 | +{ |
2090 | + double const speed = 8.0; |
2091 | + |
2092 | + EXPECT_CALL(*mock_input_configuration, set_mouse_scroll_speed(speed)); |
2093 | + |
2094 | + input_client.request_set_mouse_scroll_speed(speed); |
2095 | +} |
2096 | |
2097 | === added file 'tests/integration-tests/unity_input_dbus_client.cpp' |
2098 | --- tests/integration-tests/unity_input_dbus_client.cpp 1970-01-01 00:00:00 +0000 |
2099 | +++ tests/integration-tests/unity_input_dbus_client.cpp 2016-01-27 14:14:14 +0000 |
2100 | @@ -0,0 +1,113 @@ |
2101 | +/* |
2102 | + * Copyright © 2015 Canonical Ltd. |
2103 | + * |
2104 | + * This program is free software: you can redistribute it and/or modify |
2105 | + * it under the terms of the GNU General Public License version 3 as |
2106 | + * published by the Free Software Foundation. |
2107 | + * |
2108 | + * This program is distributed in the hope that it will be useful, |
2109 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2110 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2111 | + * GNU General Public License for more details. |
2112 | + * |
2113 | + * You should have received a copy of the GNU General Public License |
2114 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2115 | + * |
2116 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2117 | + */ |
2118 | + |
2119 | +#include "unity_input_dbus_client.h" |
2120 | + |
2121 | +namespace ut = usc::test; |
2122 | + |
2123 | +ut::UnityInputDBusClient::UnityInputDBusClient(std::string const& address) |
2124 | + : ut::DBusClient{ |
2125 | + address, |
2126 | + "com.canonical.Unity.Input", |
2127 | + "/com/canonical/Unity/Input"} |
2128 | +{ |
2129 | +} |
2130 | + |
2131 | +ut::DBusAsyncReplyString ut::UnityInputDBusClient::request_introspection() |
2132 | +{ |
2133 | + return invoke_with_reply<ut::DBusAsyncReplyString>( |
2134 | + "org.freedesktop.DBus.Introspectable", "Introspect", |
2135 | + DBUS_TYPE_INVALID); |
2136 | +} |
2137 | + |
2138 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, int32_t value) |
2139 | +{ |
2140 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
2141 | + unity_input_interface, requestName, |
2142 | + DBUS_TYPE_INT32, &value, |
2143 | + DBUS_TYPE_INVALID); |
2144 | +} |
2145 | + |
2146 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_primary_button(int32_t button) |
2147 | +{ |
2148 | + return request("setMousePrimaryButton", button); |
2149 | +} |
2150 | + |
2151 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_primary_button(int32_t button) |
2152 | +{ |
2153 | + return request("setTouchpadPrimaryButton", button); |
2154 | +} |
2155 | + |
2156 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, double value) |
2157 | +{ |
2158 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
2159 | + unity_input_interface, requestName, |
2160 | + DBUS_TYPE_DOUBLE, &value, |
2161 | + DBUS_TYPE_INVALID); |
2162 | +} |
2163 | + |
2164 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_cursor_speed(double speed) |
2165 | +{ |
2166 | + return request("setMouseCursorSpeed", speed); |
2167 | +} |
2168 | + |
2169 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_scroll_speed(double speed) |
2170 | +{ |
2171 | + return request("setMouseScrollSpeed", speed); |
2172 | +} |
2173 | + |
2174 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_cursor_speed(double speed) |
2175 | +{ |
2176 | + return request("setTouchpadCursorSpeed", speed); |
2177 | +} |
2178 | + |
2179 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_scroll_speed(double speed) |
2180 | +{ |
2181 | + return request("setTouchpadScrollSpeed", speed); |
2182 | +} |
2183 | + |
2184 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, bool value) |
2185 | +{ |
2186 | + dbus_bool_t copied = value; |
2187 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>( |
2188 | + unity_input_interface, requestName, |
2189 | + DBUS_TYPE_BOOLEAN, &copied, |
2190 | + DBUS_TYPE_INVALID); |
2191 | +} |
2192 | + |
2193 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_two_finger_scroll(bool enabled) |
2194 | +{ |
2195 | + return request("setTouchpadTwoFingerScroll", enabled); |
2196 | +} |
2197 | + |
2198 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_tap_to_click(bool enabled) |
2199 | +{ |
2200 | + return request("setTouchpadTapToClick", enabled); |
2201 | +} |
2202 | + |
2203 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_disable_with_mouse(bool enabled) |
2204 | +{ |
2205 | + return request("setTouchpadDisableWithMouse", enabled); |
2206 | +} |
2207 | + |
2208 | +ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_disable_while_typing(bool enabled) |
2209 | +{ |
2210 | + return request("setTouchpadDisableWhileTyping", enabled); |
2211 | +} |
2212 | + |
2213 | + |
2214 | |
2215 | === added file 'tests/integration-tests/unity_input_dbus_client.h' |
2216 | --- tests/integration-tests/unity_input_dbus_client.h 1970-01-01 00:00:00 +0000 |
2217 | +++ tests/integration-tests/unity_input_dbus_client.h 2016-01-27 14:14:14 +0000 |
2218 | @@ -0,0 +1,52 @@ |
2219 | +/* |
2220 | + * Copyright © 2015 Canonical Ltd. |
2221 | + * |
2222 | + * This program is free software: you can redistribute it and/or modify |
2223 | + * it under the terms of the GNU General Public License version 3 as |
2224 | + * published by the Free Software Foundation. |
2225 | + * |
2226 | + * This program is distributed in the hope that it will be useful, |
2227 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2228 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2229 | + * GNU General Public License for more details. |
2230 | + * |
2231 | + * You should have received a copy of the GNU General Public License |
2232 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2233 | + * |
2234 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2235 | + */ |
2236 | + |
2237 | +#ifndef USC_TEST_UNITY_INPUT_DBUS_CLIENT_H_ |
2238 | +#define USC_TEST_UNITY_INPUT_DBUS_CLIENT_H_ |
2239 | + |
2240 | +#include "dbus_client.h" |
2241 | + |
2242 | +namespace usc |
2243 | +{ |
2244 | +namespace test |
2245 | +{ |
2246 | +class UnityInputDBusClient : public DBusClient |
2247 | +{ |
2248 | +public: |
2249 | + UnityInputDBusClient(std::string const& address); |
2250 | + DBusAsyncReplyString request_introspection(); |
2251 | + DBusAsyncReplyVoid request(char const* requestName, int32_t value); |
2252 | + DBusAsyncReplyVoid request_set_mouse_primary_button(int32_t button); |
2253 | + DBusAsyncReplyVoid request_set_touchpad_primary_button(int32_t button); |
2254 | + DBusAsyncReplyVoid request(char const* requestName, double value); |
2255 | + DBusAsyncReplyVoid request_set_mouse_cursor_speed(double speed); |
2256 | + DBusAsyncReplyVoid request_set_mouse_scroll_speed(double speed); |
2257 | + DBusAsyncReplyVoid request_set_touchpad_cursor_speed(double speed); |
2258 | + DBusAsyncReplyVoid request_set_touchpad_scroll_speed(double speed); |
2259 | + DBusAsyncReplyVoid request(char const* requestName, bool value); |
2260 | + DBusAsyncReplyVoid request_set_touchpad_two_finger_scroll(bool enabled); |
2261 | + DBusAsyncReplyVoid request_set_touchpad_tap_to_click(bool enabled); |
2262 | + DBusAsyncReplyVoid request_set_touchpad_disable_with_mouse(bool enabled); |
2263 | + DBusAsyncReplyVoid request_set_touchpad_disable_while_typing(bool enabled); |
2264 | + char const* const unity_input_interface = "com.canonical.Unity.Input"; |
2265 | +}; |
2266 | + |
2267 | +} |
2268 | +} |
2269 | + |
2270 | +#endif |
2271 | |
2272 | === added file 'tests/integration-tests/unity_screen_dbus_client.cpp' |
2273 | --- tests/integration-tests/unity_screen_dbus_client.cpp 1970-01-01 00:00:00 +0000 |
2274 | +++ tests/integration-tests/unity_screen_dbus_client.cpp 2016-01-27 14:14:14 +0000 |
2275 | @@ -0,0 +1,112 @@ |
2276 | +/* |
2277 | + * Copyright © 2015 Canonical Ltd. |
2278 | + * |
2279 | + * This program is free software: you can redistribute it and/or modify |
2280 | + * it under the terms of the GNU General Public License version 3 as |
2281 | + * published by the Free Software Foundation. |
2282 | + * |
2283 | + * This program is distributed in the hope that it will be useful, |
2284 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2285 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2286 | + * GNU General Public License for more details. |
2287 | + * |
2288 | + * You should have received a copy of the GNU General Public License |
2289 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2290 | + * |
2291 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2292 | + */ |
2293 | + |
2294 | +#include "unity_screen_dbus_client.h" |
2295 | +#include "src/dbus_message_handle.h" |
2296 | + |
2297 | +namespace ut = usc::test; |
2298 | + |
2299 | +ut::UnityScreenDBusClient::UnityScreenDBusClient(std::string const& address) |
2300 | + : ut::DBusClient{ |
2301 | + address, |
2302 | + "com.canonical.Unity.Screen", |
2303 | + "/com/canonical/Unity/Screen"} |
2304 | +{ |
2305 | + connection.add_match( |
2306 | + "type='signal'," |
2307 | + "interface='com.canonical.Unity.Screen'," |
2308 | + "member='DisplayPowerStateChange'"); |
2309 | +} |
2310 | + |
2311 | +ut::DBusAsyncReplyString ut::UnityScreenDBusClient::request_introspection() |
2312 | +{ |
2313 | + return invoke_with_reply<ut::DBusAsyncReplyString>("org.freedesktop.DBus.Introspectable", "Introspect", |
2314 | + DBUS_TYPE_INVALID); |
2315 | +} |
2316 | + |
2317 | +ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_user_brightness(int32_t brightness) |
2318 | +{ |
2319 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setUserBrightness", DBUS_TYPE_INT32, |
2320 | + &brightness, DBUS_TYPE_INVALID); |
2321 | +} |
2322 | + |
2323 | +ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_user_auto_brightness_enable(bool enabled) |
2324 | +{ |
2325 | + dbus_bool_t const e = enabled ? TRUE : FALSE; |
2326 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "userAutobrightnessEnable", |
2327 | + DBUS_TYPE_BOOLEAN, &e, DBUS_TYPE_INVALID); |
2328 | +} |
2329 | + |
2330 | +ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_inactivity_timeouts(int32_t poweroff_timeout, |
2331 | + int32_t dimmer_timeout) |
2332 | +{ |
2333 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setInactivityTimeouts", DBUS_TYPE_INT32, |
2334 | + &poweroff_timeout, DBUS_TYPE_INT32, &dimmer_timeout, |
2335 | + DBUS_TYPE_INVALID); |
2336 | +} |
2337 | + |
2338 | +ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_touch_visualization_enabled(bool enabled) |
2339 | +{ |
2340 | + dbus_bool_t const e = enabled ? TRUE : FALSE; |
2341 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setTouchVisualizationEnabled", |
2342 | + DBUS_TYPE_BOOLEAN, &e, DBUS_TYPE_INVALID); |
2343 | +} |
2344 | + |
2345 | +ut::DBusAsyncReplyBool ut::UnityScreenDBusClient::request_set_screen_power_mode(std::string const& mode, int reason) |
2346 | +{ |
2347 | + auto mode_cstr = mode.c_str(); |
2348 | + return invoke_with_reply<ut::DBusAsyncReplyBool>(unity_screen_interface, "setScreenPowerMode", DBUS_TYPE_STRING, |
2349 | + &mode_cstr, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INVALID); |
2350 | +} |
2351 | + |
2352 | +ut::DBusAsyncReplyInt ut::UnityScreenDBusClient::request_keep_display_on() |
2353 | +{ |
2354 | + return invoke_with_reply<ut::DBusAsyncReplyInt>(unity_screen_interface, "keepDisplayOn", DBUS_TYPE_INVALID); |
2355 | +} |
2356 | + |
2357 | +ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_remove_display_on_request(int id) |
2358 | +{ |
2359 | + return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "removeDisplayOnRequest", DBUS_TYPE_INT32, |
2360 | + &id, DBUS_TYPE_INVALID); |
2361 | +} |
2362 | + |
2363 | +ut::DBusAsyncReply ut::UnityScreenDBusClient::request_invalid_method() |
2364 | +{ |
2365 | + return invoke_with_reply<ut::DBusAsyncReply>(unity_screen_interface, "invalidMethod", DBUS_TYPE_INVALID); |
2366 | +} |
2367 | + |
2368 | +ut::DBusAsyncReply ut::UnityScreenDBusClient::request_method_with_invalid_arguments() |
2369 | +{ |
2370 | + char const* const str = "abcd"; |
2371 | + return invoke_with_reply<ut::DBusAsyncReply>(unity_screen_interface, "setUserBrightness", DBUS_TYPE_STRING, &str, |
2372 | + DBUS_TYPE_INVALID); |
2373 | +} |
2374 | + |
2375 | +usc::DBusMessageHandle ut::UnityScreenDBusClient::listen_for_power_state_change_signal() |
2376 | +{ |
2377 | + while (true) |
2378 | + { |
2379 | + dbus_connection_read_write(connection, 1); |
2380 | + auto msg = usc::DBusMessageHandle{dbus_connection_pop_message(connection)}; |
2381 | + |
2382 | + if (msg && dbus_message_is_signal(msg, "com.canonical.Unity.Screen", "DisplayPowerStateChange")) |
2383 | + { |
2384 | + return msg; |
2385 | + } |
2386 | + } |
2387 | +} |
2388 | |
2389 | === added file 'tests/integration-tests/unity_screen_dbus_client.h' |
2390 | --- tests/integration-tests/unity_screen_dbus_client.h 1970-01-01 00:00:00 +0000 |
2391 | +++ tests/integration-tests/unity_screen_dbus_client.h 2016-01-27 14:14:14 +0000 |
2392 | @@ -0,0 +1,54 @@ |
2393 | +/* |
2394 | + * Copyright © 2015 Canonical Ltd. |
2395 | + * |
2396 | + * This program is free software: you can redistribute it and/or modify |
2397 | + * it under the terms of the GNU General Public License version 3 as |
2398 | + * published by the Free Software Foundation. |
2399 | + * |
2400 | + * This program is distributed in the hope that it will be useful, |
2401 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2402 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2403 | + * GNU General Public License for more details. |
2404 | + * |
2405 | + * You should have received a copy of the GNU General Public License |
2406 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2407 | + * |
2408 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2409 | + */ |
2410 | + |
2411 | +#ifndef USC_TEST_UNITY_SCREEN_DBUS_CLIENT_H_ |
2412 | +#define USC_TEST_UNITY_SCREEN_DBUS_CLIENT_H_ |
2413 | + |
2414 | +#include "dbus_client.h" |
2415 | + |
2416 | +namespace usc |
2417 | +{ |
2418 | +namespace test |
2419 | +{ |
2420 | + |
2421 | +class UnityScreenDBusClient : public DBusClient |
2422 | +{ |
2423 | +public: |
2424 | + UnityScreenDBusClient(std::string const& address); |
2425 | + |
2426 | + DBusAsyncReplyString request_introspection(); |
2427 | + DBusAsyncReplyVoid request_set_user_brightness(int32_t brightness); |
2428 | + DBusAsyncReplyVoid request_user_auto_brightness_enable(bool enabled); |
2429 | + DBusAsyncReplyVoid request_set_inactivity_timeouts( |
2430 | + int32_t poweroff_timeout, int32_t dimmer_timeout); |
2431 | + DBusAsyncReplyVoid request_set_touch_visualization_enabled(bool enabled); |
2432 | + DBusAsyncReplyBool request_set_screen_power_mode( |
2433 | + std::string const& mode, int reason); |
2434 | + |
2435 | + DBusAsyncReplyInt request_keep_display_on(); |
2436 | + DBusAsyncReplyVoid request_remove_display_on_request(int id); |
2437 | + DBusAsyncReply request_invalid_method(); |
2438 | + DBusAsyncReply request_method_with_invalid_arguments(); |
2439 | + usc::DBusMessageHandle listen_for_power_state_change_signal(); |
2440 | + char const* const unity_screen_interface = "com.canonical.Unity.Screen"; |
2441 | +}; |
2442 | + |
2443 | +} |
2444 | +} |
2445 | + |
2446 | +#endif |
2447 | |
2448 | === modified file 'tests/unit-tests/CMakeLists.txt' |
2449 | --- tests/unit-tests/CMakeLists.txt 2015-02-18 14:40:29 +0000 |
2450 | +++ tests/unit-tests/CMakeLists.txt 2016-01-27 14:14:14 +0000 |
2451 | @@ -25,6 +25,7 @@ |
2452 | test_session_switcher.cpp |
2453 | test_screen_event_handler.cpp |
2454 | test_mir_screen.cpp |
2455 | + test_mir_input_configuration.cpp |
2456 | |
2457 | advanceable_timer.cpp |
2458 | ) |
2459 | |
2460 | === added file 'tests/unit-tests/test_mir_input_configuration.cpp' |
2461 | --- tests/unit-tests/test_mir_input_configuration.cpp 1970-01-01 00:00:00 +0000 |
2462 | +++ tests/unit-tests/test_mir_input_configuration.cpp 2016-01-27 14:14:14 +0000 |
2463 | @@ -0,0 +1,114 @@ |
2464 | +/* |
2465 | + * Copyright © 2015 Canonical Ltd. |
2466 | + * |
2467 | + * This program is free software: you can redistribute it and/or modify |
2468 | + * it under the terms of the GNU General Public License version 3 as |
2469 | + * published by the Free Software Foundation. |
2470 | + * |
2471 | + * This program is distributed in the hope that it will be useful, |
2472 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2473 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2474 | + * GNU General Public License for more details. |
2475 | + * |
2476 | + * You should have received a copy of the GNU General Public License |
2477 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2478 | + * |
2479 | + * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> |
2480 | + */ |
2481 | + |
2482 | + |
2483 | +#include "src/mir_input_configuration.h" |
2484 | +#include "mir/input/input_device_hub.h" |
2485 | +#include "mir/input/device_capability.h" |
2486 | +#include "mir/input/input_device_observer.h" |
2487 | +#include "mir/input/device.h" |
2488 | + |
2489 | +#include <gtest/gtest.h> |
2490 | +#include <gmock/gmock.h> |
2491 | + |
2492 | +namespace mi = mir::input; |
2493 | + |
2494 | +using namespace ::testing; |
2495 | + |
2496 | +namespace |
2497 | +{ |
2498 | +struct MockDevice : mi::Device |
2499 | +{ |
2500 | + MOCK_CONST_METHOD0(id, MirInputDeviceId()); |
2501 | + MOCK_CONST_METHOD0(capabilities, mi::DeviceCapabilities()); |
2502 | + MOCK_CONST_METHOD0(name, std::string()); |
2503 | + MOCK_CONST_METHOD0(unique_id, std::string()); |
2504 | + MOCK_CONST_METHOD0(pointer_configuration, mir::optional_value<mi::PointerConfiguration>()); |
2505 | + MOCK_METHOD1(apply_pointer_configuration, void(mi::PointerConfiguration const&)); |
2506 | + MOCK_CONST_METHOD0(touchpad_configuration, mir::optional_value<mi::TouchpadConfiguration> ()); |
2507 | + MOCK_METHOD1(apply_touchpad_configuration, void(mi::TouchpadConfiguration const&)); |
2508 | + |
2509 | + MockDevice(mi::DeviceCapabilities caps) |
2510 | + : caps(caps) |
2511 | + { |
2512 | + ON_CALL(*this, capabilities()).WillByDefault(Return(this->caps)); |
2513 | + } |
2514 | + |
2515 | + mi::DeviceCapabilities caps; |
2516 | +}; |
2517 | + |
2518 | +struct MockInputDeviceHub : mi::InputDeviceHub |
2519 | +{ |
2520 | + MOCK_METHOD1(add_observer,void(std::shared_ptr<mi::InputDeviceObserver> const&)); |
2521 | + MOCK_METHOD1(remove_observer,void(std::weak_ptr<mi::InputDeviceObserver> const&)); |
2522 | +}; |
2523 | + |
2524 | +struct MirInputConfiguration : ::testing::Test |
2525 | +{ |
2526 | + template<typename T> |
2527 | + using shared_mock = std::shared_ptr<::testing::NiceMock<T>>; |
2528 | + shared_mock<MockInputDeviceHub> mock_hub{std::make_shared<::testing::NiceMock<MockInputDeviceHub>>()}; |
2529 | + shared_mock<MockDevice> mock_mouse{ |
2530 | + std::make_shared<::testing::NiceMock<MockDevice>>(mi::DeviceCapability::pointer)}; |
2531 | + shared_mock<MockDevice> mock_touchpad{std::make_shared<::testing::NiceMock<MockDevice>>( |
2532 | + mi::DeviceCapability::pointer | mi::DeviceCapability::touchpad)}; |
2533 | + shared_mock<MockDevice> mock_keyboard{std::make_shared<::testing::NiceMock<MockDevice>>( |
2534 | + mi::DeviceCapability::keyboard | mi::DeviceCapability::alpha_numeric)}; |
2535 | + |
2536 | + std::shared_ptr<mi::InputDeviceObserver> obs; |
2537 | + |
2538 | + MirInputConfiguration() |
2539 | + { |
2540 | + ON_CALL(*mock_hub, add_observer(_)).WillByDefault(SaveArg<0>(&obs)); |
2541 | + } |
2542 | +}; |
2543 | +} |
2544 | + |
2545 | +TEST_F(MirInputConfiguration, registers_something_as_device_observer) |
2546 | +{ |
2547 | + EXPECT_CALL(*mock_hub, add_observer(_)); |
2548 | + |
2549 | + usc::MirInputConfiguration config(mock_hub); |
2550 | +} |
2551 | + |
2552 | +TEST_F(MirInputConfiguration, configures_device_on_add) |
2553 | +{ |
2554 | + usc::MirInputConfiguration config(mock_hub); |
2555 | + |
2556 | + EXPECT_CALL(*mock_touchpad, apply_pointer_configuration(_)); |
2557 | + EXPECT_CALL(*mock_touchpad, apply_touchpad_configuration(_)); |
2558 | + obs->device_added(mock_touchpad); |
2559 | +} |
2560 | + |
2561 | +TEST_F(MirInputConfiguration, configures_mouse_on_add) |
2562 | +{ |
2563 | + usc::MirInputConfiguration config(mock_hub); |
2564 | + |
2565 | + EXPECT_CALL(*mock_mouse, apply_pointer_configuration(_)); |
2566 | + obs->device_added(mock_mouse); |
2567 | +} |
2568 | + |
2569 | +TEST_F(MirInputConfiguration, ignores_keyboard_when_added) |
2570 | +{ |
2571 | + usc::MirInputConfiguration config(mock_hub); |
2572 | + |
2573 | + EXPECT_CALL(*mock_keyboard, apply_touchpad_configuration(_)).Times(0); |
2574 | + EXPECT_CALL(*mock_keyboard, apply_pointer_configuration(_)).Times(0); |
2575 | + obs->device_added(mock_keyboard); |
2576 | +} |
2577 | + |
2578 | |
2579 | === modified file 'tests/unit-tests/test_mir_screen.cpp' |
2580 | --- tests/unit-tests/test_mir_screen.cpp 2015-09-29 13:05:56 +0000 |
2581 | +++ tests/unit-tests/test_mir_screen.cpp 2016-01-27 14:14:14 +0000 |
2582 | @@ -21,8 +21,9 @@ |
2583 | #include "src/power_state_change_reason.h" |
2584 | #include "advanceable_timer.h" |
2585 | |
2586 | +#include "usc/test/mock_display.h" |
2587 | + |
2588 | #include <mir/compositor/compositor.h> |
2589 | -#include <mir/graphics/display.h> |
2590 | #include <mir/graphics/display_configuration.h> |
2591 | #include <mir/graphics/gl_context.h> |
2592 | #include <mir/input/touch_visualizer.h> |
2593 | @@ -33,6 +34,7 @@ |
2594 | #include <atomic> |
2595 | |
2596 | namespace mg = mir::graphics; |
2597 | +namespace ut = usc::test; |
2598 | |
2599 | namespace |
2600 | { |
2601 | @@ -43,63 +45,6 @@ |
2602 | MOCK_METHOD0(stop, void()); |
2603 | }; |
2604 | |
2605 | -struct StubDisplayConfiguration : mg::DisplayConfiguration |
2606 | -{ |
2607 | - StubDisplayConfiguration() |
2608 | - { |
2609 | - conf_output.power_mode = MirPowerMode::mir_power_mode_on; |
2610 | - } |
2611 | - |
2612 | - void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const override |
2613 | - { |
2614 | - } |
2615 | - |
2616 | - void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)> f) const override |
2617 | - { |
2618 | - f(conf_output); |
2619 | - } |
2620 | - |
2621 | - void for_each_output(std::function<void(mg::UserDisplayConfigurationOutput&)> f) |
2622 | - { |
2623 | - mg::UserDisplayConfigurationOutput user{conf_output}; |
2624 | - f(user); |
2625 | - } |
2626 | - |
2627 | - mg::DisplayConfigurationOutput conf_output; |
2628 | -}; |
2629 | - |
2630 | -struct MockDisplay : mg::Display |
2631 | -{ |
2632 | - void for_each_display_sync_group(std::function<void(mg::DisplaySyncGroup&)> const& f) override |
2633 | - { |
2634 | - } |
2635 | - |
2636 | - std::unique_ptr<mg::DisplayConfiguration> configuration() const override |
2637 | - { return std::unique_ptr<mg::DisplayConfiguration>{new StubDisplayConfiguration{}}; } |
2638 | - |
2639 | - MOCK_METHOD1(configure, void(mg::DisplayConfiguration const& conf)); |
2640 | - |
2641 | - void register_configuration_change_handler( |
2642 | - mg::EventHandlerRegister& , |
2643 | - mg::DisplayConfigurationChangeHandler const& ) override {}; |
2644 | - |
2645 | - void register_pause_resume_handlers( |
2646 | - mg::EventHandlerRegister&, |
2647 | - mg::DisplayPauseHandler const&, |
2648 | - mg::DisplayResumeHandler const&) override |
2649 | - { |
2650 | - } |
2651 | - |
2652 | - void pause() override {}; |
2653 | - |
2654 | - void resume() override {}; |
2655 | - |
2656 | - std::shared_ptr<mg::Cursor> create_hardware_cursor(std::shared_ptr<mg::CursorImage> const&) override {return{};}; |
2657 | - |
2658 | - std::unique_ptr<mg::GLContext> create_gl_context() override |
2659 | - { return std::unique_ptr<mg::GLContext>{};}; |
2660 | -}; |
2661 | - |
2662 | struct MockScreenHardware : usc::ScreenHardware |
2663 | { |
2664 | MOCK_METHOD0(set_dim_backlight, void()); |
2665 | @@ -333,8 +278,8 @@ |
2666 | std::make_shared<testing::NiceMock<MockScreenHardware>>()}; |
2667 | std::shared_ptr<MockCompositor> compositor{ |
2668 | std::make_shared<testing::NiceMock<MockCompositor>>()}; |
2669 | - std::shared_ptr<MockDisplay> display{ |
2670 | - std::make_shared<testing::NiceMock<MockDisplay>>()}; |
2671 | + std::shared_ptr<ut::MockDisplay> display{ |
2672 | + std::make_shared<testing::NiceMock<ut::MockDisplay>>()}; |
2673 | std::shared_ptr<MockTouchVisualizer> touch_visualizer{ |
2674 | std::make_shared<testing::NiceMock<MockTouchVisualizer>>()}; |
2675 | std::shared_ptr<AdvanceableTimer> timer{ |
2676 | |
2677 | === modified file 'tests/unit-tests/test_screen_event_handler.cpp' |
2678 | --- tests/unit-tests/test_screen_event_handler.cpp 2015-10-08 09:54:02 +0000 |
2679 | +++ tests/unit-tests/test_screen_event_handler.cpp 2016-01-27 14:14:14 +0000 |
2680 | @@ -28,6 +28,7 @@ |
2681 | #include <gtest/gtest.h> |
2682 | #include <gmock/gmock.h> |
2683 | |
2684 | +#include "linux/input.h" |
2685 | #include <atomic> |
2686 | |
2687 | namespace |
2688 | @@ -64,6 +65,19 @@ |
2689 | screen_event_handler.handle(*power_key_up_event); |
2690 | } |
2691 | |
2692 | + void press_a_key() |
2693 | + { |
2694 | + screen_event_handler.handle(*another_key_down_event); |
2695 | + } |
2696 | + |
2697 | + void press_volume_keys() |
2698 | + { |
2699 | + screen_event_handler.handle(*vol_plus_key_down_event); |
2700 | + screen_event_handler.handle(*vol_plus_key_up_event); |
2701 | + screen_event_handler.handle(*vol_minus_key_down_event); |
2702 | + screen_event_handler.handle(*vol_minus_key_up_event); |
2703 | + } |
2704 | + |
2705 | void touch_screen() |
2706 | { |
2707 | screen_event_handler.handle(*touch_event); |
2708 | @@ -74,21 +88,50 @@ |
2709 | screen_event_handler.handle(*pointer_event); |
2710 | } |
2711 | |
2712 | - static const int32_t POWER_KEY_CODE = 26; |
2713 | mir::EventUPtr power_key_down_event = mir::events::make_event( |
2714 | MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2715 | 0, mir_keyboard_action_down, |
2716 | - POWER_KEY_CODE, 0, mir_input_event_modifier_none); |
2717 | + 0, KEY_POWER, mir_input_event_modifier_none); |
2718 | |
2719 | mir::EventUPtr power_key_up_event = mir::events::make_event( |
2720 | MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2721 | 0, mir_keyboard_action_up, |
2722 | - POWER_KEY_CODE, 0, mir_input_event_modifier_none); |
2723 | + 0, KEY_POWER, mir_input_event_modifier_none); |
2724 | + |
2725 | + mir::EventUPtr vol_plus_key_down_event = mir::events::make_event( |
2726 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2727 | + 0, mir_keyboard_action_down, |
2728 | + 0, KEY_VOLUMEUP, mir_input_event_modifier_none); |
2729 | + |
2730 | + mir::EventUPtr vol_plus_key_up_event = mir::events::make_event( |
2731 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2732 | + 0, mir_keyboard_action_up, |
2733 | + 0, KEY_VOLUMEUP, mir_input_event_modifier_none); |
2734 | + |
2735 | + mir::EventUPtr vol_minus_key_down_event = mir::events::make_event( |
2736 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2737 | + 0, mir_keyboard_action_down, |
2738 | + 0, KEY_VOLUMEDOWN, mir_input_event_modifier_none); |
2739 | + |
2740 | + mir::EventUPtr vol_minus_key_up_event = mir::events::make_event( |
2741 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2742 | + 0, mir_keyboard_action_up, |
2743 | + 0, KEY_VOLUMEDOWN, mir_input_event_modifier_none); |
2744 | + |
2745 | + mir::EventUPtr another_key_down_event = mir::events::make_event( |
2746 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2747 | + 0, mir_keyboard_action_down, |
2748 | + 0, KEY_A, mir_input_event_modifier_none); |
2749 | + |
2750 | + mir::EventUPtr another_key_up_event = mir::events::make_event( |
2751 | + MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2752 | + 0, mir_keyboard_action_up, |
2753 | + 0, KEY_A, mir_input_event_modifier_none); |
2754 | |
2755 | mir::EventUPtr touch_event = mir::events::make_event( |
2756 | MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2757 | 0, mir_input_event_modifier_none); |
2758 | - |
2759 | + |
2760 | mir::EventUPtr pointer_event = mir::events::make_event( |
2761 | MirInputDeviceId{1}, std::chrono::nanoseconds(0), |
2762 | 0, mir_input_event_modifier_none, |
2763 | @@ -160,13 +203,54 @@ |
2764 | touch_screen(); |
2765 | } |
2766 | |
2767 | -TEST_F(AScreenEventHandler, keeps_display_on_temporarily_on_pointer_event) |
2768 | -{ |
2769 | +TEST_F(AScreenEventHandler, turns_on_screen_and_filters_first_pointer_event_when_screen_is_off) |
2770 | +{ |
2771 | + mock_screen.mock_mode = MirPowerMode::mir_power_mode_off; |
2772 | + EXPECT_CALL(mock_screen, |
2773 | + set_screen_power_mode(MirPowerMode::mir_power_mode_on, |
2774 | + PowerStateChangeReason::unknown)); |
2775 | + |
2776 | + auto const event_filtered = screen_event_handler.handle(*pointer_event); |
2777 | + EXPECT_TRUE(event_filtered); |
2778 | +} |
2779 | + |
2780 | +TEST_F(AScreenEventHandler, turns_on_screen_and_propagates_keys_when_screen_is_off) |
2781 | +{ |
2782 | + mock_screen.mock_mode = MirPowerMode::mir_power_mode_off; |
2783 | + EXPECT_CALL(mock_screen, |
2784 | + set_screen_power_mode(MirPowerMode::mir_power_mode_on, |
2785 | + PowerStateChangeReason::unknown)); |
2786 | + |
2787 | + auto const event_filtered = screen_event_handler.handle(*another_key_down_event); |
2788 | + EXPECT_FALSE(event_filtered); |
2789 | +} |
2790 | + |
2791 | +TEST_F(AScreenEventHandler, keeps_display_on_temporarily_for_pointer_event_when_screen_is_on) |
2792 | +{ |
2793 | + mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; |
2794 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()); |
2795 | |
2796 | move_pointer(); |
2797 | } |
2798 | |
2799 | +TEST_F(AScreenEventHandler, keeps_display_on_temporarily_key_event_when_screen_is_on) |
2800 | +{ |
2801 | + mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; |
2802 | + EXPECT_CALL(mock_screen, keep_display_on_temporarily()); |
2803 | + |
2804 | + press_a_key(); |
2805 | +} |
2806 | + |
2807 | +TEST_F(AScreenEventHandler, does_not_affect_screen_state_for_volume_keys) |
2808 | +{ |
2809 | + using namespace testing; |
2810 | + |
2811 | + EXPECT_CALL(mock_screen, keep_display_on_temporarily()).Times(0); |
2812 | + EXPECT_CALL(mock_screen, set_screen_power_mode(_,_)).Times(0); |
2813 | + |
2814 | + press_volume_keys(); |
2815 | +} |
2816 | + |
2817 | TEST_F(AScreenEventHandler, sets_screen_mode_off_normal_press_release) |
2818 | { |
2819 | EXPECT_CALL(mock_screen, |
2820 | @@ -198,10 +282,12 @@ |
2821 | release_power_key(); |
2822 | } |
2823 | |
2824 | -TEST_F(AScreenEventHandler, passes_through_all_handled_events) |
2825 | +TEST_F(AScreenEventHandler, passes_through_all_handled_events_when_screen_is_on) |
2826 | { |
2827 | using namespace testing; |
2828 | |
2829 | + mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; |
2830 | + |
2831 | EXPECT_FALSE(screen_event_handler.handle(*power_key_down_event)); |
2832 | EXPECT_FALSE(screen_event_handler.handle(*power_key_up_event)); |
2833 | EXPECT_FALSE(screen_event_handler.handle(*touch_event)); |
2834 | |
2835 | === modified file 'tools/png2header.py' |
2836 | --- tools/png2header.py 2015-06-11 09:15:46 +0000 |
2837 | +++ tools/png2header.py 2016-01-27 14:14:14 +0000 |
2838 | @@ -67,7 +67,7 @@ |
2839 | print " unsigned char pixel_data[%d * %d * %d + 1];" % image_info |
2840 | print "} %s = {" % variable_name |
2841 | print " %d, %d, %d," % image_info |
2842 | - print tocstring(image.tostring()) |
2843 | + print tocstring(image.tobytes()) |
2844 | print "};" |
2845 | |
2846 | def show_usage(): |
2847 | @@ -82,5 +82,6 @@ |
2848 | variable_name = sys.argv[2] |
2849 | |
2850 | image = Image.open(image_filename) |
2851 | -premultiply(image) |
2852 | +if image.mode == 'RGBA': |
2853 | + premultiply(image) |
2854 | export(image, variable_name) |