Merge lp:unity-system-compositor/0.3 into lp:unity-system-compositor/ubuntu
- 0.3
- Merge into ubuntu
Proposed by
Alexandros Frantzis
Status: | Merged |
---|---|
Approved by: | Alexandros Frantzis |
Approved revision: | 268 |
Merged at revision: | 227 |
Proposed branch: | lp:unity-system-compositor/0.3 |
Merge into: | lp:unity-system-compositor/ubuntu |
Diff against target: |
2303 lines (+1048/-398) 39 files modified
CMakeLists.txt (+3/-2) debian/changelog (+31/-0) 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 (+23/-4) 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/include/usc/test/mock_input_configuration.h (+48/-0) tests/include/usc/test/mock_screen.h (+57/-0) tests/integration-tests/CMakeLists.txt (+3/-0) tests/integration-tests/test_dbus_event_loop.cpp (+8/-8) 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_screen_event_handler.cpp (+34/-5) |
To merge this branch: | bzr merge lp:unity-system-compositor/0.3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity System Compositor Development Team | Pending | ||
Review via email: mp+283517@code.launchpad.net |
Commit message
Release 0.3.1
Description of the change
Release 0.3.1
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-12-01 13:53:20 +0000 | |||
3 | +++ CMakeLists.txt 2016-01-21 17:48:37 +0000 | |||
4 | @@ -16,8 +16,8 @@ | |||
5 | 16 | 16 | ||
6 | 17 | project(UnitySystemCompositor) | 17 | project(UnitySystemCompositor) |
7 | 18 | set(USC_VERSION_MAJOR 0) | 18 | set(USC_VERSION_MAJOR 0) |
10 | 19 | set(USC_VERSION_MINOR 2) | 19 | set(USC_VERSION_MINOR 3) |
11 | 20 | set(USC_VERSION_PATCH 0) | 20 | set(USC_VERSION_PATCH 1) |
12 | 21 | set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}") | 21 | set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}") |
13 | 22 | 22 | ||
14 | 23 | cmake_minimum_required(VERSION 2.8) | 23 | cmake_minimum_required(VERSION 2.8) |
15 | @@ -57,6 +57,7 @@ | |||
16 | 57 | 57 | ||
17 | 58 | if (MIR_ENABLE_TESTS) | 58 | if (MIR_ENABLE_TESTS) |
18 | 59 | find_package(Gtest REQUIRED) | 59 | find_package(Gtest REQUIRED) |
19 | 60 | include_directories(${MIRCLIENT_INCLUDE_DIRS} ) | ||
20 | 60 | include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) | 61 | include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) |
21 | 61 | add_subdirectory(tests/) | 62 | add_subdirectory(tests/) |
22 | 62 | endif () | 63 | endif () |
23 | 63 | 64 | ||
24 | === modified file 'debian/changelog' | |||
25 | --- debian/changelog 2015-12-16 22:44:39 +0000 | |||
26 | +++ debian/changelog 2016-01-21 17:48:37 +0000 | |||
27 | @@ -1,3 +1,34 @@ | |||
28 | 1 | unity-system-compositor (0.3.1+16.04.20160121-0ubuntu1) xenial; urgency=medium | ||
29 | 2 | |||
30 | 3 | [ Alexandros Frantzis ] | ||
31 | 4 | * Unblank the screen when a pointer or key event arrives. (LP: #1488413) | ||
32 | 5 | |||
33 | 6 | [ Andreas Pokorny ] | ||
34 | 7 | * Implement a DBus interface for setting pointer speed/acceleration. | ||
35 | 8 | (LP: #1536383) | ||
36 | 9 | |||
37 | 10 | -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Thu, 21 Jan 2016 19:27:33 +0200 | ||
38 | 11 | |||
39 | 12 | unity-system-compositor (0.2.0+16.04.20151222.1-0ubuntu1) xenial; urgency=medium | ||
40 | 13 | |||
41 | 14 | [ Alexandros Frantzis ] | ||
42 | 15 | * tests: Fix build failure with gcc-4.9 | ||
43 | 16 | |||
44 | 17 | [ Andrea Cimitan ] | ||
45 | 18 | * Updated wallpaper for spinner from unity8. | ||
46 | 19 | |||
47 | 20 | [ Andreas Pokorny ] | ||
48 | 21 | * Add clone method to StubdisplayConfigurations | ||
49 | 22 | * Change keyboard handling to scan codes. (LP: #1514059, #1520422) | ||
50 | 23 | * do not premultiply RGB images | ||
51 | 24 | * follow the deprecation warning and use tobytes instead of tostring. | ||
52 | 25 | |||
53 | 26 | [ Kevin DuBois ] | ||
54 | 27 | * Accommodate RGB images (LP: #1528279) | ||
55 | 28 | * Accommodate RGB images (LP: #1528279) | ||
56 | 29 | |||
57 | 30 | -- Kevin DuBois <kevin.dubois@canonical.com> Tue, 22 Dec 2015 19:09:40 +0000 | ||
58 | 31 | |||
59 | 1 | unity-system-compositor (0.2.0+16.04.20151216.1-0ubuntu1) xenial; urgency=medium | 32 | unity-system-compositor (0.2.0+16.04.20151216.1-0ubuntu1) xenial; urgency=medium |
60 | 2 | 33 | ||
61 | 3 | [ Alexandros Frantzis ] | 34 | [ Alexandros Frantzis ] |
62 | 4 | 35 | ||
63 | === modified file 'spinner/eglspinner.cpp' | |||
64 | --- spinner/eglspinner.cpp 2015-06-30 12:04:53 +0000 | |||
65 | +++ spinner/eglspinner.cpp 2016-01-21 17:48:37 +0000 | |||
66 | @@ -150,14 +150,17 @@ | |||
67 | 150 | void uploadTexture (GLuint id, Image& image) | 150 | void uploadTexture (GLuint id, Image& image) |
68 | 151 | { | 151 | { |
69 | 152 | glBindTexture(GL_TEXTURE_2D, id); | 152 | glBindTexture(GL_TEXTURE_2D, id); |
70 | 153 | GLint format = GL_RGBA; | ||
71 | 154 | if (image.bytes_per_pixel == 3) | ||
72 | 155 | format = GL_RGB; | ||
73 | 153 | 156 | ||
74 | 154 | glTexImage2D(GL_TEXTURE_2D, | 157 | glTexImage2D(GL_TEXTURE_2D, |
75 | 155 | 0, | 158 | 0, |
77 | 156 | GL_RGBA, | 159 | format, |
78 | 157 | image.width, | 160 | image.width, |
79 | 158 | image.height, | 161 | image.height, |
80 | 159 | 0, | 162 | 0, |
82 | 160 | GL_RGBA, | 163 | format, |
83 | 161 | GL_UNSIGNED_BYTE, | 164 | GL_UNSIGNED_BYTE, |
84 | 162 | image.pixel_data); | 165 | image.pixel_data); |
85 | 163 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 166 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
86 | 164 | 167 | ||
87 | === modified file 'src/CMakeLists.txt' | |||
88 | --- src/CMakeLists.txt 2015-08-29 14:38:35 +0000 | |||
89 | +++ src/CMakeLists.txt 2016-01-21 17:48:37 +0000 | |||
90 | @@ -72,6 +72,7 @@ | |||
91 | 72 | ${Boost_INCLUDE_DIRS} | 72 | ${Boost_INCLUDE_DIRS} |
92 | 73 | ${GLESv2_INCLUDE_DIRS} | 73 | ${GLESv2_INCLUDE_DIRS} |
93 | 74 | ${MIRSERVER_INCLUDE_DIRS} | 74 | ${MIRSERVER_INCLUDE_DIRS} |
94 | 75 | ${MIRCLIENT_INCLUDE_DIRS} | ||
95 | 75 | ${DBUS_INCLUDE_DIRS} | 76 | ${DBUS_INCLUDE_DIRS} |
96 | 76 | ) | 77 | ) |
97 | 77 | add_definitions( | 78 | add_definitions( |
98 | 78 | 79 | ||
99 | === modified file 'src/dbus_connection_handle.cpp' | |||
100 | --- src/dbus_connection_handle.cpp 2015-03-18 12:20:58 +0000 | |||
101 | +++ src/dbus_connection_handle.cpp 2016-01-21 17:48:37 +0000 | |||
102 | @@ -22,12 +22,12 @@ | |||
103 | 22 | #include <stdexcept> | 22 | #include <stdexcept> |
104 | 23 | #include <boost/throw_exception.hpp> | 23 | #include <boost/throw_exception.hpp> |
105 | 24 | 24 | ||
107 | 25 | usc::DBusConnectionHandle::DBusConnectionHandle(const char* address) | 25 | usc::DBusConnectionHandle::DBusConnectionHandle(std::string const& address) |
108 | 26 | { | 26 | { |
109 | 27 | dbus_threads_init_default(); | 27 | dbus_threads_init_default(); |
110 | 28 | ScopedDBusError error; | 28 | ScopedDBusError error; |
111 | 29 | 29 | ||
113 | 30 | connection = dbus_connection_open_private(address, &error); | 30 | connection = dbus_connection_open_private(address.c_str(), &error); |
114 | 31 | if (!connection || error) | 31 | if (!connection || error) |
115 | 32 | { | 32 | { |
116 | 33 | BOOST_THROW_EXCEPTION( | 33 | BOOST_THROW_EXCEPTION( |
117 | 34 | 34 | ||
118 | === modified file 'src/dbus_connection_handle.h' | |||
119 | --- src/dbus_connection_handle.h 2015-03-17 18:17:14 +0000 | |||
120 | +++ src/dbus_connection_handle.h 2016-01-21 17:48:37 +0000 | |||
121 | @@ -21,13 +21,15 @@ | |||
122 | 21 | 21 | ||
123 | 22 | #include <dbus/dbus.h> | 22 | #include <dbus/dbus.h> |
124 | 23 | 23 | ||
125 | 24 | #include <string> | ||
126 | 25 | |||
127 | 24 | namespace usc | 26 | namespace usc |
128 | 25 | { | 27 | { |
129 | 26 | 28 | ||
130 | 27 | class DBusConnectionHandle | 29 | class DBusConnectionHandle |
131 | 28 | { | 30 | { |
132 | 29 | public: | 31 | public: |
134 | 30 | DBusConnectionHandle(char const* address); | 32 | DBusConnectionHandle(std::string const& address); |
135 | 31 | ~DBusConnectionHandle(); | 33 | ~DBusConnectionHandle(); |
136 | 32 | 34 | ||
137 | 33 | void request_name(char const* name) const; | 35 | void request_name(char const* name) const; |
138 | 34 | 36 | ||
139 | === modified file 'src/dbus_connection_thread.cpp' | |||
140 | --- src/dbus_connection_thread.cpp 2015-08-25 14:27:23 +0000 | |||
141 | +++ src/dbus_connection_thread.cpp 2016-01-21 17:48:37 +0000 | |||
142 | @@ -17,11 +17,10 @@ | |||
143 | 17 | */ | 17 | */ |
144 | 18 | 18 | ||
145 | 19 | #include "dbus_connection_thread.h" | 19 | #include "dbus_connection_thread.h" |
146 | 20 | #include "dbus_event_loop.h" | ||
147 | 20 | #include "thread_name.h" | 21 | #include "thread_name.h" |
148 | 21 | 22 | ||
152 | 22 | usc::DBusConnectionThread::DBusConnectionThread(std::string const& address) | 23 | usc::DBusConnectionThread::DBusConnectionThread(std::shared_ptr<DBusEventLoop> const& loop) : dbus_event_loop(loop) |
150 | 23 | : dbus_connection{address.c_str()}, | ||
151 | 24 | dbus_event_loop{dbus_connection} | ||
153 | 25 | { | 24 | { |
154 | 26 | std::promise<void> event_loop_started; | 25 | std::promise<void> event_loop_started; |
155 | 27 | auto event_loop_started_future = event_loop_started.get_future(); | 26 | auto event_loop_started_future = event_loop_started.get_future(); |
156 | @@ -30,7 +29,7 @@ | |||
157 | 30 | [this,&event_loop_started] | 29 | [this,&event_loop_started] |
158 | 31 | { | 30 | { |
159 | 32 | usc::set_thread_name("USC/DBus"); | 31 | usc::set_thread_name("USC/DBus"); |
161 | 33 | dbus_event_loop.run(event_loop_started); | 32 | dbus_event_loop->run(event_loop_started); |
162 | 34 | }); | 33 | }); |
163 | 35 | 34 | ||
164 | 36 | event_loop_started_future.wait(); | 35 | event_loop_started_future.wait(); |
165 | @@ -38,16 +37,11 @@ | |||
166 | 38 | 37 | ||
167 | 39 | usc::DBusConnectionThread::~DBusConnectionThread() | 38 | usc::DBusConnectionThread::~DBusConnectionThread() |
168 | 40 | { | 39 | { |
170 | 41 | dbus_event_loop.stop(); | 40 | dbus_event_loop->stop(); |
171 | 42 | dbus_loop_thread.join(); | 41 | dbus_loop_thread.join(); |
172 | 43 | } | 42 | } |
173 | 44 | 43 | ||
174 | 45 | usc::DBusConnectionHandle const& usc::DBusConnectionThread::connection() const | ||
175 | 46 | { | ||
176 | 47 | return dbus_connection; | ||
177 | 48 | } | ||
178 | 49 | |||
179 | 50 | usc::DBusEventLoop & usc::DBusConnectionThread::loop() | 44 | usc::DBusEventLoop & usc::DBusConnectionThread::loop() |
180 | 51 | { | 45 | { |
182 | 52 | return dbus_event_loop; | 46 | return *dbus_event_loop; |
183 | 53 | } | 47 | } |
184 | 54 | 48 | ||
185 | === modified file 'src/dbus_connection_thread.h' | |||
186 | --- src/dbus_connection_thread.h 2015-08-25 14:27:23 +0000 | |||
187 | +++ src/dbus_connection_thread.h 2016-01-21 17:48:37 +0000 | |||
188 | @@ -19,25 +19,21 @@ | |||
189 | 19 | #ifndef USC_DBUS_CONNECTION_THREAD_H_ | 19 | #ifndef USC_DBUS_CONNECTION_THREAD_H_ |
190 | 20 | #define USC_DBUS_CONNECTION_THREAD_H_ | 20 | #define USC_DBUS_CONNECTION_THREAD_H_ |
191 | 21 | 21 | ||
192 | 22 | #include "dbus_connection_handle.h" | ||
193 | 23 | #include "dbus_event_loop.h" | ||
194 | 24 | |||
195 | 25 | #include <thread> | 22 | #include <thread> |
196 | 26 | 23 | ||
197 | 27 | namespace usc | 24 | namespace usc |
198 | 28 | { | 25 | { |
199 | 29 | 26 | ||
200 | 27 | class DBusEventLoop; | ||
201 | 30 | class DBusConnectionThread | 28 | class DBusConnectionThread |
202 | 31 | { | 29 | { |
203 | 32 | public: | 30 | public: |
205 | 33 | DBusConnectionThread(std::string const& address); | 31 | DBusConnectionThread(std::shared_ptr<DBusEventLoop> const& thread); |
206 | 34 | ~DBusConnectionThread(); | 32 | ~DBusConnectionThread(); |
207 | 35 | DBusConnectionHandle const& connection() const; | ||
208 | 36 | DBusEventLoop & loop(); | 33 | DBusEventLoop & loop(); |
209 | 37 | 34 | ||
210 | 38 | private: | 35 | private: |
213 | 39 | DBusConnectionHandle dbus_connection; | 36 | std::shared_ptr<DBusEventLoop> dbus_event_loop; |
212 | 40 | DBusEventLoop dbus_event_loop; | ||
214 | 41 | std::thread dbus_loop_thread; | 37 | std::thread dbus_loop_thread; |
215 | 42 | }; | 38 | }; |
216 | 43 | 39 | ||
217 | 44 | 40 | ||
218 | === modified file 'src/dbus_event_loop.cpp' | |||
219 | --- src/dbus_event_loop.cpp 2015-03-18 12:20:58 +0000 | |||
220 | +++ src/dbus_event_loop.cpp 2016-01-21 17:48:37 +0000 | |||
221 | @@ -21,6 +21,7 @@ | |||
222 | 21 | #endif | 21 | #endif |
223 | 22 | 22 | ||
224 | 23 | #include "dbus_event_loop.h" | 23 | #include "dbus_event_loop.h" |
225 | 24 | #include "dbus_connection_handle.h" | ||
226 | 24 | 25 | ||
227 | 25 | #include <algorithm> | 26 | #include <algorithm> |
228 | 26 | 27 | ||
229 | @@ -78,9 +79,8 @@ | |||
230 | 78 | 79 | ||
231 | 79 | } | 80 | } |
232 | 80 | 81 | ||
236 | 81 | usc::DBusEventLoop::DBusEventLoop(DBusConnection* connection) | 82 | usc::DBusEventLoop::DBusEventLoop() |
237 | 82 | : connection{connection}, | 83 | : running{false}, |
235 | 83 | running{false}, | ||
238 | 84 | epoll_fd{epoll_create1(EPOLL_CLOEXEC)} | 84 | epoll_fd{epoll_create1(EPOLL_CLOEXEC)} |
239 | 85 | { | 85 | { |
240 | 86 | if (epoll_fd == -1) | 86 | if (epoll_fd == -1) |
241 | @@ -109,9 +109,17 @@ | |||
242 | 109 | BOOST_THROW_EXCEPTION( | 109 | BOOST_THROW_EXCEPTION( |
243 | 110 | std::system_error(errno, std::system_category(), "epoll_ctl")); | 110 | std::system_error(errno, std::system_category(), "epoll_ctl")); |
244 | 111 | } | 111 | } |
245 | 112 | } | ||
246 | 113 | |||
247 | 114 | void usc::DBusEventLoop::add_connection(std::shared_ptr<DBusConnectionHandle> const& connection) | ||
248 | 115 | { | ||
249 | 116 | if (running) | ||
250 | 117 | BOOST_THROW_EXCEPTION(std::logic_error("Connection added after dbus event loop started")); | ||
251 | 118 | |||
252 | 119 | connections.push_back(connection); | ||
253 | 112 | 120 | ||
254 | 113 | dbus_connection_set_watch_functions( | 121 | dbus_connection_set_watch_functions( |
256 | 114 | connection, | 122 | *connection, |
257 | 115 | DBusEventLoop::static_add_watch, | 123 | DBusEventLoop::static_add_watch, |
258 | 116 | DBusEventLoop::static_remove_watch, | 124 | DBusEventLoop::static_remove_watch, |
259 | 117 | DBusEventLoop::static_toggle_watch, | 125 | DBusEventLoop::static_toggle_watch, |
260 | @@ -119,7 +127,7 @@ | |||
261 | 119 | nullptr); | 127 | nullptr); |
262 | 120 | 128 | ||
263 | 121 | dbus_connection_set_timeout_functions( | 129 | dbus_connection_set_timeout_functions( |
265 | 122 | connection, | 130 | *connection, |
266 | 123 | DBusEventLoop::static_add_timeout, | 131 | DBusEventLoop::static_add_timeout, |
267 | 124 | DBusEventLoop::static_remove_timeout, | 132 | DBusEventLoop::static_remove_timeout, |
268 | 125 | DBusEventLoop::static_toggle_timeout, | 133 | DBusEventLoop::static_toggle_timeout, |
269 | @@ -127,7 +135,7 @@ | |||
270 | 127 | nullptr); | 135 | nullptr); |
271 | 128 | 136 | ||
272 | 129 | dbus_connection_set_wakeup_main_function( | 137 | dbus_connection_set_wakeup_main_function( |
274 | 130 | connection, | 138 | *connection, |
275 | 131 | DBusEventLoop::static_wake_up_loop, | 139 | DBusEventLoop::static_wake_up_loop, |
276 | 132 | this, nullptr); | 140 | this, nullptr); |
277 | 133 | } | 141 | } |
278 | @@ -136,14 +144,17 @@ | |||
279 | 136 | { | 144 | { |
280 | 137 | stop(); | 145 | stop(); |
281 | 138 | 146 | ||
290 | 139 | dbus_connection_set_watch_functions( | 147 | for(auto connection : connections) |
291 | 140 | connection, nullptr, nullptr, nullptr, nullptr, nullptr); | 148 | { |
292 | 141 | 149 | dbus_connection_set_watch_functions( | |
293 | 142 | dbus_connection_set_timeout_functions( | 150 | *connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
294 | 143 | connection, nullptr, nullptr, nullptr, nullptr, nullptr); | 151 | |
295 | 144 | 152 | dbus_connection_set_timeout_functions( | |
296 | 145 | dbus_connection_set_wakeup_main_function( | 153 | *connection, nullptr, nullptr, nullptr, nullptr, nullptr); |
297 | 146 | connection, nullptr, nullptr, nullptr); | 154 | |
298 | 155 | dbus_connection_set_wakeup_main_function( | ||
299 | 156 | *connection, nullptr, nullptr, nullptr); | ||
300 | 157 | } | ||
301 | 147 | } | 158 | } |
302 | 148 | 159 | ||
303 | 149 | void usc::DBusEventLoop::run(std::promise<void>& started) | 160 | void usc::DBusEventLoop::run(std::promise<void>& started) |
304 | @@ -187,14 +198,17 @@ | |||
305 | 187 | 198 | ||
306 | 188 | dispatch_actions(); | 199 | dispatch_actions(); |
307 | 189 | 200 | ||
309 | 190 | dbus_connection_flush(connection); | 201 | for (auto connection : connections) |
310 | 202 | { | ||
311 | 203 | dbus_connection_flush(*connection); | ||
312 | 191 | 204 | ||
315 | 192 | while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) | 205 | while (dbus_connection_dispatch(*connection) == DBUS_DISPATCH_DATA_REMAINS); |
316 | 193 | continue; | 206 | } |
317 | 194 | } | 207 | } |
318 | 195 | 208 | ||
319 | 196 | // Flush any remaining outgoing messages | 209 | // Flush any remaining outgoing messages |
321 | 197 | dbus_connection_flush(connection); | 210 | for (auto connection : connections) |
322 | 211 | dbus_connection_flush(*connection); | ||
323 | 198 | } | 212 | } |
324 | 199 | 213 | ||
325 | 200 | void usc::DBusEventLoop::stop() | 214 | void usc::DBusEventLoop::stop() |
326 | 201 | 215 | ||
327 | === modified file 'src/dbus_event_loop.h' | |||
328 | --- src/dbus_event_loop.h 2015-03-18 11:56:28 +0000 | |||
329 | +++ src/dbus_event_loop.h 2016-01-21 17:48:37 +0000 | |||
330 | @@ -30,13 +30,15 @@ | |||
331 | 30 | 30 | ||
332 | 31 | namespace usc | 31 | namespace usc |
333 | 32 | { | 32 | { |
334 | 33 | class DBusConnectionHandle; | ||
335 | 33 | 34 | ||
336 | 34 | class DBusEventLoop | 35 | class DBusEventLoop |
337 | 35 | { | 36 | { |
338 | 36 | public: | 37 | public: |
340 | 37 | DBusEventLoop(DBusConnection* connection); | 38 | DBusEventLoop(); |
341 | 38 | ~DBusEventLoop(); | 39 | ~DBusEventLoop(); |
342 | 39 | 40 | ||
343 | 41 | void add_connection(std::shared_ptr<DBusConnectionHandle> const& connection); | ||
344 | 40 | void run(std::promise<void>& started); | 42 | void run(std::promise<void>& started); |
345 | 41 | void stop(); | 43 | void stop(); |
346 | 42 | 44 | ||
347 | @@ -70,10 +72,10 @@ | |||
348 | 70 | static void static_toggle_timeout(DBusTimeout* timeout, void* data); | 72 | static void static_toggle_timeout(DBusTimeout* timeout, void* data); |
349 | 71 | static void static_wake_up_loop(void* data); | 73 | static void static_wake_up_loop(void* data); |
350 | 72 | 74 | ||
351 | 73 | DBusConnection* const connection; | ||
352 | 74 | std::atomic<bool> running; | 75 | std::atomic<bool> running; |
353 | 75 | 76 | ||
354 | 76 | std::mutex mutex; | 77 | std::mutex mutex; |
355 | 78 | std::vector<std::shared_ptr<DBusConnectionHandle>> connections; | ||
356 | 77 | std::vector<DBusWatch*> watches; | 79 | std::vector<DBusWatch*> watches; |
357 | 78 | std::vector<std::pair<DBusTimeout*,mir::Fd>> timeouts; | 80 | std::vector<std::pair<DBusTimeout*,mir::Fd>> timeouts; |
358 | 79 | std::vector<std::function<void(void)>> actions; | 81 | std::vector<std::function<void(void)>> actions; |
359 | 80 | 82 | ||
360 | === modified file 'src/mir_input_configuration.cpp' | |||
361 | --- src/mir_input_configuration.cpp 2015-08-26 08:26:35 +0000 | |||
362 | +++ src/mir_input_configuration.cpp 2016-01-21 17:48:37 +0000 | |||
363 | @@ -15,58 +15,173 @@ | |||
364 | 15 | */ | 15 | */ |
365 | 16 | 16 | ||
366 | 17 | #include "mir_input_configuration.h" | 17 | #include "mir_input_configuration.h" |
371 | 18 | 18 | #include "mir/input/input_device_observer.h" | |
372 | 19 | // just a stub at the moment, this implementation will be supposed to | 19 | #include "mir/input/input_device_hub.h" |
373 | 20 | // observe available input devices and apply settings to it. | 20 | #include "mir/input/pointer_configuration.h" |
374 | 21 | 21 | #include "mir/input/touchpad_configuration.h" | |
375 | 22 | #include "mir/input/device.h" | ||
376 | 23 | |||
377 | 24 | namespace mi = mir::input; | ||
378 | 25 | |||
379 | 26 | namespace | ||
380 | 27 | { | ||
381 | 28 | struct DeviceObserver : mi::InputDeviceObserver | ||
382 | 29 | { | ||
383 | 30 | usc::MirInputConfiguration* conf; | ||
384 | 31 | DeviceObserver(usc::MirInputConfiguration* conf) | ||
385 | 32 | : conf{conf} | ||
386 | 33 | { | ||
387 | 34 | } | ||
388 | 35 | |||
389 | 36 | void device_added(std::shared_ptr<mi::Device> const& device) override | ||
390 | 37 | { | ||
391 | 38 | conf->device_added(device); | ||
392 | 39 | } | ||
393 | 40 | |||
394 | 41 | void device_changed(std::shared_ptr<mi::Device> const&) override | ||
395 | 42 | { | ||
396 | 43 | } | ||
397 | 44 | |||
398 | 45 | void device_removed(std::shared_ptr<mi::Device> const&device) override | ||
399 | 46 | { | ||
400 | 47 | conf->device_removed(device); | ||
401 | 48 | } | ||
402 | 49 | |||
403 | 50 | void changes_complete() override | ||
404 | 51 | { | ||
405 | 52 | } | ||
406 | 53 | }; | ||
407 | 54 | } | ||
408 | 55 | |||
409 | 56 | |||
410 | 57 | usc::MirInputConfiguration::MirInputConfiguration(std::shared_ptr<mi::InputDeviceHub> const& device_hub) : | ||
411 | 58 | observer{std::make_shared<DeviceObserver>(this)} | ||
412 | 59 | { | ||
413 | 60 | device_hub->add_observer(observer); | ||
414 | 61 | } | ||
415 | 62 | |||
416 | 63 | void usc::MirInputConfiguration::device_removed(std::shared_ptr<mi::Device> const& dev) | ||
417 | 64 | { | ||
418 | 65 | std::lock_guard<decltype(devices_lock)> lock(devices_lock); | ||
419 | 66 | touchpads.erase(dev); | ||
420 | 67 | mice.erase(dev); | ||
421 | 68 | } | ||
422 | 69 | |||
423 | 70 | void usc::MirInputConfiguration::configure_mouse(mi::Device& dev) | ||
424 | 71 | { | ||
425 | 72 | dev.apply_pointer_configuration(mouse_pointer_config); | ||
426 | 73 | } | ||
427 | 74 | |||
428 | 75 | void usc::MirInputConfiguration::configure_touchpad(mi::Device& dev) | ||
429 | 76 | { | ||
430 | 77 | dev.apply_pointer_configuration(touchpad_pointer_config); | ||
431 | 78 | dev.apply_touchpad_configuration(touchpad_config); | ||
432 | 79 | } | ||
433 | 80 | |||
434 | 81 | void usc::MirInputConfiguration::device_added(std::shared_ptr<mi::Device> const& dev) | ||
435 | 82 | { | ||
436 | 83 | std::lock_guard<decltype(devices_lock)> lock(devices_lock); | ||
437 | 84 | |||
438 | 85 | if (contains(dev->capabilities(), mi::DeviceCapability::touchpad)) | ||
439 | 86 | { | ||
440 | 87 | touchpads.insert(dev); | ||
441 | 88 | configure_touchpad(*dev); | ||
442 | 89 | } | ||
443 | 90 | else if (contains(dev->capabilities(), mi::DeviceCapability::pointer)) | ||
444 | 91 | { | ||
445 | 92 | mice.insert(dev); | ||
446 | 93 | configure_mouse(*dev); | ||
447 | 94 | } | ||
448 | 95 | } | ||
449 | 96 | |||
450 | 97 | void usc::MirInputConfiguration::update_touchpads() | ||
451 | 98 | { | ||
452 | 99 | for (auto const& touchpad : touchpads) | ||
453 | 100 | configure_touchpad(*touchpad); | ||
454 | 101 | } | ||
455 | 102 | |||
456 | 103 | void usc::MirInputConfiguration::update_mice() | ||
457 | 104 | { | ||
458 | 105 | for (auto const& mouse : mice) | ||
459 | 106 | configure_mouse(*mouse); | ||
460 | 107 | } | ||
461 | 22 | 108 | ||
462 | 23 | void usc::MirInputConfiguration::set_mouse_primary_button(int32_t button) | 109 | void usc::MirInputConfiguration::set_mouse_primary_button(int32_t button) |
463 | 24 | { | 110 | { |
465 | 25 | mouse_primary_button = button; | 111 | mouse_pointer_config.handedness = button == 0 ? |
466 | 112 | mir_pointer_handedness_right : | ||
467 | 113 | mir_pointer_handedness_left; | ||
468 | 114 | update_mice(); | ||
469 | 26 | } | 115 | } |
470 | 27 | 116 | ||
471 | 28 | void usc::MirInputConfiguration::set_mouse_cursor_speed(double speed) | 117 | void usc::MirInputConfiguration::set_mouse_cursor_speed(double speed) |
472 | 29 | { | 118 | { |
474 | 30 | mouse_cursor_speed = speed; | 119 | double clamped = speed; |
475 | 120 | if (clamped < 0.0) | ||
476 | 121 | clamped = 0.0; | ||
477 | 122 | if (clamped > 1.0) | ||
478 | 123 | clamped = 1.0; | ||
479 | 124 | mouse_pointer_config.cursor_acceleration_bias = clamped * 2.0 - 1.0; | ||
480 | 125 | update_mice(); | ||
481 | 31 | } | 126 | } |
482 | 32 | 127 | ||
483 | 33 | void usc::MirInputConfiguration::set_mouse_scroll_speed(double speed) | 128 | void usc::MirInputConfiguration::set_mouse_scroll_speed(double speed) |
484 | 34 | { | 129 | { |
486 | 35 | mouse_scroll_speed = speed; | 130 | mouse_pointer_config.horizontal_scroll_scale = speed; |
487 | 131 | mouse_pointer_config.vertical_scroll_scale = speed; | ||
488 | 132 | update_mice(); | ||
489 | 36 | } | 133 | } |
490 | 37 | 134 | ||
491 | 38 | void usc::MirInputConfiguration::set_touchpad_primary_button(int32_t button) | 135 | void usc::MirInputConfiguration::set_touchpad_primary_button(int32_t button) |
492 | 39 | { | 136 | { |
494 | 40 | touchpad_primary_button = button; | 137 | touchpad_pointer_config.handedness = button == 0?mir_pointer_handedness_right:mir_pointer_handedness_left; |
495 | 138 | update_touchpads(); | ||
496 | 41 | } | 139 | } |
497 | 42 | 140 | ||
498 | 43 | void usc::MirInputConfiguration::set_touchpad_cursor_speed(double speed) | 141 | void usc::MirInputConfiguration::set_touchpad_cursor_speed(double speed) |
499 | 44 | { | 142 | { |
501 | 45 | touchpad_cursor_speed = speed; | 143 | double clamped = speed; |
502 | 144 | if (clamped < 0.0) | ||
503 | 145 | clamped = 0.0; | ||
504 | 146 | if (clamped > 1.0) | ||
505 | 147 | clamped = 1.0; | ||
506 | 148 | touchpad_pointer_config.cursor_acceleration_bias = clamped * 2.0 - 1.0; | ||
507 | 149 | update_touchpads(); | ||
508 | 46 | } | 150 | } |
509 | 47 | 151 | ||
510 | 48 | void usc::MirInputConfiguration::set_touchpad_scroll_speed(double speed) | 152 | void usc::MirInputConfiguration::set_touchpad_scroll_speed(double speed) |
511 | 49 | { | 153 | { |
513 | 50 | touchpad_scroll_speed = speed; | 154 | touchpad_pointer_config.horizontal_scroll_scale = speed; |
514 | 155 | touchpad_pointer_config.vertical_scroll_scale = speed; | ||
515 | 156 | update_touchpads(); | ||
516 | 51 | } | 157 | } |
517 | 52 | 158 | ||
518 | 53 | void usc::MirInputConfiguration::set_two_finger_scroll(bool enable) | 159 | void usc::MirInputConfiguration::set_two_finger_scroll(bool enable) |
519 | 54 | { | 160 | { |
521 | 55 | two_finger_scroll = enable; | 161 | MirTouchpadScrollModes current = touchpad_config.scroll_mode; |
522 | 162 | if (enable) | ||
523 | 163 | current |= mir_touchpad_scroll_mode_two_finger_scroll; | ||
524 | 164 | else | ||
525 | 165 | current &= ~mir_touchpad_scroll_mode_two_finger_scroll; | ||
526 | 166 | touchpad_config.scroll_mode = current; | ||
527 | 167 | update_touchpads(); | ||
528 | 56 | } | 168 | } |
529 | 57 | 169 | ||
530 | 58 | void usc::MirInputConfiguration::set_tap_to_click(bool enable) | 170 | void usc::MirInputConfiguration::set_tap_to_click(bool enable) |
531 | 59 | { | 171 | { |
533 | 60 | tap_to_click = enable; | 172 | touchpad_config.tap_to_click = enable; |
534 | 173 | update_touchpads(); | ||
535 | 61 | } | 174 | } |
536 | 62 | 175 | ||
537 | 63 | void usc::MirInputConfiguration::set_disable_touchpad_while_typing(bool enable) | 176 | void usc::MirInputConfiguration::set_disable_touchpad_while_typing(bool enable) |
538 | 64 | { | 177 | { |
540 | 65 | disable_while_typing = enable; | 178 | touchpad_config.disable_while_typing = enable; |
541 | 179 | update_touchpads(); | ||
542 | 66 | } | 180 | } |
543 | 67 | 181 | ||
544 | 68 | void usc::MirInputConfiguration::set_disable_touchpad_with_mouse(bool enable) | 182 | void usc::MirInputConfiguration::set_disable_touchpad_with_mouse(bool enable) |
545 | 69 | { | 183 | { |
547 | 70 | disable_with_mouse = enable; | 184 | touchpad_config.disable_with_mouse = enable; |
548 | 185 | update_touchpads(); | ||
549 | 71 | } | 186 | } |
550 | 72 | 187 | ||
551 | 73 | 188 | ||
552 | === modified file 'src/mir_input_configuration.h' | |||
553 | --- src/mir_input_configuration.h 2015-08-26 08:26:35 +0000 | |||
554 | +++ src/mir_input_configuration.h 2016-01-21 17:48:37 +0000 | |||
555 | @@ -14,18 +14,36 @@ | |||
556 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
557 | 15 | */ | 15 | */ |
558 | 16 | 16 | ||
559 | 17 | |||
560 | 18 | #ifndef USC_MIR_INPUT_CONFIGRATION_H_ | 17 | #ifndef USC_MIR_INPUT_CONFIGRATION_H_ |
561 | 19 | #define USC_MIR_INPUT_CONFIGRATION_H_ | 18 | #define USC_MIR_INPUT_CONFIGRATION_H_ |
562 | 20 | 19 | ||
563 | 21 | #include "input_configuration.h" | 20 | #include "input_configuration.h" |
564 | 22 | 21 | ||
565 | 22 | #include "mir/input/touchpad_configuration.h" | ||
566 | 23 | #include "mir/input/pointer_configuration.h" | ||
567 | 24 | |||
568 | 25 | #include <memory> | ||
569 | 26 | #include <thread> | ||
570 | 27 | #include <mutex> | ||
571 | 28 | #include <unordered_set> | ||
572 | 29 | |||
573 | 30 | namespace mir | ||
574 | 31 | { | ||
575 | 32 | namespace input | ||
576 | 33 | { | ||
577 | 34 | class InputDeviceHub; | ||
578 | 35 | class Device; | ||
579 | 36 | class InputDeviceObserver; | ||
580 | 37 | } | ||
581 | 38 | } | ||
582 | 39 | |||
583 | 23 | namespace usc | 40 | namespace usc |
584 | 24 | { | 41 | { |
585 | 25 | 42 | ||
586 | 26 | struct MirInputConfiguration : InputConfiguration | 43 | struct MirInputConfiguration : InputConfiguration |
587 | 27 | { | 44 | { |
588 | 28 | public: | 45 | public: |
589 | 46 | MirInputConfiguration(std::shared_ptr<mir::input::InputDeviceHub> const& device_hub); | ||
590 | 29 | void set_mouse_primary_button(int32_t button) override; | 47 | void set_mouse_primary_button(int32_t button) override; |
591 | 30 | void set_mouse_cursor_speed(double speed) override; | 48 | void set_mouse_cursor_speed(double speed) override; |
592 | 31 | void set_mouse_scroll_speed(double speed) override; | 49 | void set_mouse_scroll_speed(double speed) override; |
593 | @@ -36,17 +54,22 @@ | |||
594 | 36 | void set_tap_to_click(bool enable) override; | 54 | void set_tap_to_click(bool enable) override; |
595 | 37 | void set_disable_touchpad_while_typing(bool enable) override; | 55 | void set_disable_touchpad_while_typing(bool enable) override; |
596 | 38 | void set_disable_touchpad_with_mouse(bool enable) override; | 56 | void set_disable_touchpad_with_mouse(bool enable) override; |
597 | 57 | |||
598 | 58 | void device_added(std::shared_ptr<mir::input::Device> const& device); | ||
599 | 59 | void device_removed(std::shared_ptr<mir::input::Device> const& device); | ||
600 | 39 | private: | 60 | private: |
611 | 40 | int32_t mouse_primary_button{0}; | 61 | void configure_mouse(mir::input::Device& dev); |
612 | 41 | double mouse_cursor_speed{0.5}; | 62 | void configure_touchpad(mir::input::Device& dev); |
613 | 42 | double mouse_scroll_speed{0.5}; | 63 | void update_touchpads(); |
614 | 43 | int32_t touchpad_primary_button{0}; | 64 | void update_mice(); |
615 | 44 | double touchpad_cursor_speed{0.5}; | 65 | |
616 | 45 | double touchpad_scroll_speed{0.5}; | 66 | std::shared_ptr<mir::input::InputDeviceObserver> const observer; |
617 | 46 | bool two_finger_scroll{false}; | 67 | std::mutex devices_lock; |
618 | 47 | bool tap_to_click{false}; | 68 | std::unordered_set<std::shared_ptr<mir::input::Device>> touchpads; |
619 | 48 | bool disable_while_typing{false}; | 69 | std::unordered_set<std::shared_ptr<mir::input::Device>> mice; |
620 | 49 | bool disable_with_mouse{true}; | 70 | mir::input::PointerConfiguration mouse_pointer_config; |
621 | 71 | mir::input::PointerConfiguration touchpad_pointer_config; | ||
622 | 72 | mir::input::TouchpadConfiguration touchpad_config; | ||
623 | 50 | }; | 73 | }; |
624 | 51 | 74 | ||
625 | 52 | } | 75 | } |
626 | 53 | 76 | ||
627 | === modified file 'src/powerd_mediator.cpp' | |||
628 | --- src/powerd_mediator.cpp 2015-07-17 12:43:46 +0000 | |||
629 | +++ src/powerd_mediator.cpp 2016-01-21 17:48:37 +0000 | |||
630 | @@ -45,8 +45,7 @@ | |||
631 | 45 | } | 45 | } |
632 | 46 | 46 | ||
633 | 47 | usc::PowerdMediator::PowerdMediator(std::string const& bus_addr) | 47 | usc::PowerdMediator::PowerdMediator(std::string const& bus_addr) |
636 | 48 | : connection{bus_addr.c_str()}, | 48 | : connection{std::make_shared<DBusConnectionHandle>(bus_addr.c_str())}, |
635 | 49 | dbus_event_loop{connection}, | ||
637 | 50 | pending_suspend_block_request{false}, | 49 | pending_suspend_block_request{false}, |
638 | 51 | dim_brightness_{10}, | 50 | dim_brightness_{10}, |
639 | 52 | min_brightness_{0}, | 51 | min_brightness_{0}, |
640 | @@ -59,17 +58,18 @@ | |||
641 | 59 | proximity_enabled{false}, | 58 | proximity_enabled{false}, |
642 | 60 | sys_state{SysState::unknown} | 59 | sys_state{SysState::unknown} |
643 | 61 | { | 60 | { |
645 | 62 | connection.add_match( | 61 | dbus_event_loop.add_connection(connection); |
646 | 62 | connection->add_match( | ||
647 | 63 | "type='signal'," | 63 | "type='signal'," |
648 | 64 | "sender='com.canonical.powerd'," | 64 | "sender='com.canonical.powerd'," |
649 | 65 | "interface='com.canonical.powerd'," | 65 | "interface='com.canonical.powerd'," |
650 | 66 | "member='SysPowerStateChange'"); | 66 | "member='SysPowerStateChange'"); |
652 | 67 | connection.add_match( | 67 | connection->add_match( |
653 | 68 | "type='signal'," | 68 | "type='signal'," |
654 | 69 | "sender='org.freedesktop.DBus'," | 69 | "sender='org.freedesktop.DBus'," |
655 | 70 | "interface='org.freedesktop.DBus'," | 70 | "interface='org.freedesktop.DBus'," |
656 | 71 | "member='NameOwnerChanged'"); | 71 | "member='NameOwnerChanged'"); |
658 | 72 | connection.add_filter(handle_dbus_message_thunk, this); | 72 | connection->add_filter(handle_dbus_message_thunk, this); |
659 | 73 | 73 | ||
660 | 74 | std::promise<void> event_loop_started; | 74 | std::promise<void> event_loop_started; |
661 | 75 | auto event_loop_started_future = event_loop_started.get_future(); | 75 | auto event_loop_started_future = event_loop_started.get_future(); |
662 | @@ -477,7 +477,7 @@ | |||
663 | 477 | [this, &msg, &reply_promise] | 477 | [this, &msg, &reply_promise] |
664 | 478 | { | 478 | { |
665 | 479 | auto const reply = dbus_connection_send_with_reply_and_block( | 479 | auto const reply = dbus_connection_send_with_reply_and_block( |
667 | 480 | connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr); | 480 | *connection, msg, DBUS_TIMEOUT_USE_DEFAULT, nullptr); |
668 | 481 | 481 | ||
669 | 482 | reply_promise.set_value(reply); | 482 | reply_promise.set_value(reply); |
670 | 483 | }; | 483 | }; |
671 | 484 | 484 | ||
672 | === modified file 'src/powerd_mediator.h' | |||
673 | --- src/powerd_mediator.h 2015-07-17 12:43:46 +0000 | |||
674 | +++ src/powerd_mediator.h 2016-01-21 17:48:37 +0000 | |||
675 | @@ -88,7 +88,7 @@ | |||
676 | 88 | void invoke(char const* method, int first_arg_type, ...); | 88 | void invoke(char const* method, int first_arg_type, ...); |
677 | 89 | usc::DBusMessageHandle invoke_with_reply(char const* method, int first_arg_type, ...); | 89 | usc::DBusMessageHandle invoke_with_reply(char const* method, int first_arg_type, ...); |
678 | 90 | 90 | ||
680 | 91 | usc::DBusConnectionHandle connection; | 91 | std::shared_ptr<usc::DBusConnectionHandle> connection; |
681 | 92 | usc::DBusEventLoop dbus_event_loop; | 92 | usc::DBusEventLoop dbus_event_loop; |
682 | 93 | std::thread dbus_loop_thread; | 93 | std::thread dbus_loop_thread; |
683 | 94 | 94 | ||
684 | 95 | 95 | ||
685 | === modified file 'src/screen_event_handler.cpp' | |||
686 | --- src/screen_event_handler.cpp 2015-11-07 13:29:29 +0000 | |||
687 | +++ src/screen_event_handler.cpp 2016-01-21 17:48:37 +0000 | |||
688 | @@ -71,16 +71,20 @@ | |||
689 | 71 | } | 71 | } |
690 | 72 | else | 72 | else |
691 | 73 | { | 73 | { |
694 | 74 | std::lock_guard<std::mutex> lock{guard}; | 74 | keep_or_turn_screen_on(); |
693 | 75 | screen->keep_display_on_temporarily(); | ||
695 | 76 | } | 75 | } |
696 | 77 | } | 76 | } |
699 | 78 | else if (input_event_type == mir_input_event_type_touch || | 77 | else if (input_event_type == mir_input_event_type_touch) |
698 | 79 | input_event_type == mir_input_event_type_pointer) | ||
700 | 80 | { | 78 | { |
701 | 81 | std::lock_guard<std::mutex> lock{guard}; | 79 | std::lock_guard<std::mutex> lock{guard}; |
702 | 82 | screen->keep_display_on_temporarily(); | 80 | screen->keep_display_on_temporarily(); |
703 | 83 | } | 81 | } |
704 | 82 | else if (input_event_type == mir_input_event_type_pointer) | ||
705 | 83 | { | ||
706 | 84 | bool const filter_out_event = screen->get_screen_power_mode() != mir_power_mode_on; | ||
707 | 85 | keep_or_turn_screen_on(); | ||
708 | 86 | return filter_out_event; | ||
709 | 87 | } | ||
710 | 84 | 88 | ||
711 | 85 | return false; | 89 | return false; |
712 | 86 | } | 90 | } |
713 | @@ -138,3 +142,18 @@ | |||
714 | 138 | MirPowerMode::mir_power_mode_on, PowerStateChangeReason::power_key); | 142 | MirPowerMode::mir_power_mode_on, PowerStateChangeReason::power_key); |
715 | 139 | long_press_detected = true; | 143 | long_press_detected = true; |
716 | 140 | } | 144 | } |
717 | 145 | |||
718 | 146 | void usc::ScreenEventHandler::keep_or_turn_screen_on() | ||
719 | 147 | { | ||
720 | 148 | std::lock_guard<std::mutex> lock{guard}; | ||
721 | 149 | |||
722 | 150 | if (screen->get_screen_power_mode() == mir_power_mode_off) | ||
723 | 151 | { | ||
724 | 152 | screen->set_screen_power_mode( | ||
725 | 153 | MirPowerMode::mir_power_mode_on, PowerStateChangeReason::unknown); | ||
726 | 154 | } | ||
727 | 155 | else | ||
728 | 156 | { | ||
729 | 157 | screen->keep_display_on_temporarily(); | ||
730 | 158 | } | ||
731 | 159 | } | ||
732 | 141 | 160 | ||
733 | === modified file 'src/screen_event_handler.h' | |||
734 | --- src/screen_event_handler.h 2015-04-29 14:39:19 +0000 | |||
735 | +++ src/screen_event_handler.h 2016-01-21 17:48:37 +0000 | |||
736 | @@ -56,6 +56,7 @@ | |||
737 | 56 | void power_key_down(); | 56 | void power_key_down(); |
738 | 57 | void shutdown_alarm_notification(); | 57 | void shutdown_alarm_notification(); |
739 | 58 | void long_press_notification(); | 58 | void long_press_notification(); |
740 | 59 | void keep_or_turn_screen_on(); | ||
741 | 59 | 60 | ||
742 | 60 | std::mutex guard; | 61 | std::mutex guard; |
743 | 61 | std::shared_ptr<Screen> const screen; | 62 | std::shared_ptr<Screen> const screen; |
744 | 62 | 63 | ||
745 | === modified file 'src/server.cpp' | |||
746 | --- src/server.cpp 2015-09-30 10:53:54 +0000 | |||
747 | +++ src/server.cpp 2016-01-21 17:48:37 +0000 | |||
748 | @@ -28,6 +28,7 @@ | |||
749 | 28 | #include "unity_screen_service.h" | 28 | #include "unity_screen_service.h" |
750 | 29 | #include "unity_input_service.h" | 29 | #include "unity_input_service.h" |
751 | 30 | #include "dbus_connection_thread.h" | 30 | #include "dbus_connection_thread.h" |
752 | 31 | #include "dbus_event_loop.h" | ||
753 | 31 | #include "display_configuration_policy.h" | 32 | #include "display_configuration_policy.h" |
754 | 32 | #include "steady_clock.h" | 33 | #include "steady_clock.h" |
755 | 33 | 34 | ||
756 | @@ -241,7 +242,7 @@ | |||
757 | 241 | return input_configuration( | 242 | return input_configuration( |
758 | 242 | [this] | 243 | [this] |
759 | 243 | { | 244 | { |
761 | 244 | return std::make_shared<MirInputConfiguration>(); | 245 | return std::make_shared<MirInputConfiguration>(the_input_device_hub()); |
762 | 245 | }); | 246 | }); |
763 | 246 | } | 247 | } |
764 | 247 | 248 | ||
765 | @@ -292,12 +293,22 @@ | |||
766 | 292 | }); | 293 | }); |
767 | 293 | } | 294 | } |
768 | 294 | 295 | ||
769 | 296 | std::shared_ptr<usc::DBusEventLoop> usc::Server::the_dbus_event_loop() | ||
770 | 297 | { | ||
771 | 298 | return dbus_loop( | ||
772 | 299 | [this] | ||
773 | 300 | { | ||
774 | 301 | return std::make_shared<DBusEventLoop>(); | ||
775 | 302 | }); | ||
776 | 303 | |||
777 | 304 | } | ||
778 | 305 | |||
779 | 295 | std::shared_ptr<usc::DBusConnectionThread> usc::Server::the_dbus_connection_thread() | 306 | std::shared_ptr<usc::DBusConnectionThread> usc::Server::the_dbus_connection_thread() |
780 | 296 | { | 307 | { |
781 | 297 | return dbus_thread( | 308 | return dbus_thread( |
782 | 298 | [this] | 309 | [this] |
783 | 299 | { | 310 | { |
785 | 300 | return std::make_shared<DBusConnectionThread>(dbus_bus_address()); | 311 | return std::make_shared<DBusConnectionThread>(the_dbus_event_loop()); |
786 | 301 | }); | 312 | }); |
787 | 302 | } | 313 | } |
788 | 303 | 314 | ||
789 | @@ -307,7 +318,8 @@ | |||
790 | 307 | [this] | 318 | [this] |
791 | 308 | { | 319 | { |
792 | 309 | return std::make_shared<UnityScreenService>( | 320 | return std::make_shared<UnityScreenService>( |
794 | 310 | the_dbus_connection_thread(), | 321 | the_dbus_event_loop(), |
795 | 322 | dbus_bus_address(), | ||
796 | 311 | the_screen()); | 323 | the_screen()); |
797 | 312 | }); | 324 | }); |
798 | 313 | } | 325 | } |
799 | @@ -318,7 +330,8 @@ | |||
800 | 318 | [this] | 330 | [this] |
801 | 319 | { | 331 | { |
802 | 320 | return std::make_shared<UnityInputService>( | 332 | return std::make_shared<UnityInputService>( |
804 | 321 | the_dbus_connection_thread(), | 333 | the_dbus_event_loop(), |
805 | 334 | dbus_bus_address(), | ||
806 | 322 | the_input_configuration()); | 335 | the_input_configuration()); |
807 | 323 | }); | 336 | }); |
808 | 324 | } | 337 | } |
809 | 325 | 338 | ||
810 | === modified file 'src/server.h' | |||
811 | --- src/server.h 2015-09-30 10:53:54 +0000 | |||
812 | +++ src/server.h 2016-01-21 17:48:37 +0000 | |||
813 | @@ -45,6 +45,7 @@ | |||
814 | 45 | class InputConfiguration; | 45 | class InputConfiguration; |
815 | 46 | class UnityInputService; | 46 | class UnityInputService; |
816 | 47 | class DBusConnectionThread; | 47 | class DBusConnectionThread; |
817 | 48 | class DBusEventLoop; | ||
818 | 48 | class Clock; | 49 | class Clock; |
819 | 49 | 50 | ||
820 | 50 | class Server : private mir::Server | 51 | class Server : private mir::Server |
821 | @@ -69,6 +70,7 @@ | |||
822 | 69 | virtual std::shared_ptr<ScreenHardware> the_screen_hardware(); | 70 | virtual std::shared_ptr<ScreenHardware> the_screen_hardware(); |
823 | 70 | virtual std::shared_ptr<UnityScreenService> the_unity_screen_service(); | 71 | virtual std::shared_ptr<UnityScreenService> the_unity_screen_service(); |
824 | 71 | virtual std::shared_ptr<UnityInputService> the_unity_input_service(); | 72 | virtual std::shared_ptr<UnityInputService> the_unity_input_service(); |
825 | 73 | virtual std::shared_ptr<DBusEventLoop> the_dbus_event_loop(); | ||
826 | 72 | virtual std::shared_ptr<DBusConnectionThread> the_dbus_connection_thread(); | 74 | virtual std::shared_ptr<DBusConnectionThread> the_dbus_connection_thread(); |
827 | 73 | virtual std::shared_ptr<Clock> the_clock(); | 75 | virtual std::shared_ptr<Clock> the_clock(); |
828 | 74 | 76 | ||
829 | @@ -182,6 +184,7 @@ | |||
830 | 182 | mir::CachedPtr<mir::input::EventFilter> screen_event_handler; | 184 | mir::CachedPtr<mir::input::EventFilter> screen_event_handler; |
831 | 183 | mir::CachedPtr<ScreenHardware> screen_hardware; | 185 | mir::CachedPtr<ScreenHardware> screen_hardware; |
832 | 184 | mir::CachedPtr<DBusConnectionThread> dbus_thread; | 186 | mir::CachedPtr<DBusConnectionThread> dbus_thread; |
833 | 187 | mir::CachedPtr<DBusEventLoop> dbus_loop; | ||
834 | 185 | mir::CachedPtr<UnityScreenService> unity_screen_service; | 188 | mir::CachedPtr<UnityScreenService> unity_screen_service; |
835 | 186 | mir::CachedPtr<UnityInputService> unity_input_service; | 189 | mir::CachedPtr<UnityInputService> unity_input_service; |
836 | 187 | mir::CachedPtr<Clock> clock; | 190 | mir::CachedPtr<Clock> clock; |
837 | 188 | 191 | ||
838 | === modified file 'src/system_compositor.cpp' | |||
839 | --- src/system_compositor.cpp 2015-08-26 08:26:35 +0000 | |||
840 | +++ src/system_compositor.cpp 2016-01-21 17:48:37 +0000 | |||
841 | @@ -22,6 +22,7 @@ | |||
842 | 22 | #include "dm_connection.h" | 22 | #include "dm_connection.h" |
843 | 23 | 23 | ||
844 | 24 | #include <mir/input/composite_event_filter.h> | 24 | #include <mir/input/composite_event_filter.h> |
845 | 25 | #include <mir/input/input_device_hub.h> | ||
846 | 25 | #include <mir/abnormal_exit.h> | 26 | #include <mir/abnormal_exit.h> |
847 | 26 | 27 | ||
848 | 27 | #include <cerrno> | 28 | #include <cerrno> |
849 | @@ -123,6 +124,7 @@ | |||
850 | 123 | 124 | ||
851 | 124 | unity_screen_service = server->the_unity_screen_service(); | 125 | unity_screen_service = server->the_unity_screen_service(); |
852 | 125 | unity_input_service = server->the_unity_input_service(); | 126 | unity_input_service = server->the_unity_input_service(); |
853 | 127 | dbus_service_thread = server->the_dbus_connection_thread(); | ||
854 | 126 | } | 128 | } |
855 | 127 | }); | 129 | }); |
856 | 128 | 130 | ||
857 | 129 | 131 | ||
858 | === modified file 'src/system_compositor.h' | |||
859 | --- src/system_compositor.h 2015-08-26 08:26:35 +0000 | |||
860 | +++ src/system_compositor.h 2016-01-21 17:48:37 +0000 | |||
861 | @@ -40,6 +40,7 @@ | |||
862 | 40 | class Screen; | 40 | class Screen; |
863 | 41 | class UnityScreenService; | 41 | class UnityScreenService; |
864 | 42 | class UnityInputService; | 42 | class UnityInputService; |
865 | 43 | class DBusConnectionThread; | ||
866 | 43 | 44 | ||
867 | 44 | class SystemCompositor | 45 | class SystemCompositor |
868 | 45 | { | 46 | { |
869 | @@ -55,6 +56,7 @@ | |||
870 | 55 | std::shared_ptr<mir::input::EventFilter> screen_event_handler; | 56 | std::shared_ptr<mir::input::EventFilter> screen_event_handler; |
871 | 56 | std::shared_ptr<UnityScreenService> unity_screen_service; | 57 | std::shared_ptr<UnityScreenService> unity_screen_service; |
872 | 57 | std::shared_ptr<UnityInputService> unity_input_service; | 58 | std::shared_ptr<UnityInputService> unity_input_service; |
873 | 59 | std::shared_ptr<DBusConnectionThread> dbus_service_thread; | ||
874 | 58 | }; | 60 | }; |
875 | 59 | 61 | ||
876 | 60 | } | 62 | } |
877 | 61 | 63 | ||
878 | === modified file 'src/unity_input_service.cpp' | |||
879 | --- src/unity_input_service.cpp 2015-08-28 15:57:25 +0000 | |||
880 | +++ src/unity_input_service.cpp 2016-01-21 17:48:37 +0000 | |||
881 | @@ -19,7 +19,7 @@ | |||
882 | 19 | #include "unity_input_service.h" | 19 | #include "unity_input_service.h" |
883 | 20 | #include "input_configuration.h" | 20 | #include "input_configuration.h" |
884 | 21 | #include "dbus_message_handle.h" | 21 | #include "dbus_message_handle.h" |
886 | 22 | #include "dbus_connection_thread.h" | 22 | #include "dbus_event_loop.h" |
887 | 23 | #include "scoped_dbus_error.h" | 23 | #include "scoped_dbus_error.h" |
888 | 24 | 24 | ||
889 | 25 | #include "unity_input_service_introspection.h" // autogenerated | 25 | #include "unity_input_service_introspection.h" // autogenerated |
890 | @@ -33,15 +33,14 @@ | |||
891 | 33 | 33 | ||
892 | 34 | } | 34 | } |
893 | 35 | 35 | ||
899 | 36 | usc::UnityInputService::UnityInputService( | 36 | usc::UnityInputService::UnityInputService(std::shared_ptr<usc::DBusEventLoop> const& loop, |
900 | 37 | std::shared_ptr<usc::DBusConnectionThread> const& dbus, | 37 | std::string const& address, |
901 | 38 | std::shared_ptr<usc::InputConfiguration> const& input_config) | 38 | std::shared_ptr<usc::InputConfiguration> const& input_config) |
902 | 39 | : dbus{dbus}, | 39 | : loop{loop}, connection{std::make_shared<DBusConnectionHandle>(address.c_str())}, input_config{input_config} |
898 | 40 | input_config{input_config} | ||
903 | 41 | { | 40 | { |
907 | 42 | auto const& connection = dbus->connection(); | 41 | loop->add_connection(connection); |
908 | 43 | connection.request_name(dbus_input_service_name); | 42 | connection->request_name(dbus_input_service_name); |
909 | 44 | connection.add_filter(handle_dbus_message_thunk, this); | 43 | connection->add_filter(handle_dbus_message_thunk, this); |
910 | 45 | } | 44 | } |
911 | 46 | 45 | ||
912 | 47 | ::DBusHandlerResult usc::UnityInputService::handle_dbus_message_thunk( | 46 | ::DBusHandlerResult usc::UnityInputService::handle_dbus_message_thunk( |
913 | @@ -63,7 +62,7 @@ | |||
914 | 63 | (input_config.get()->*method)(flag); | 62 | (input_config.get()->*method)(flag); |
915 | 64 | 63 | ||
916 | 65 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; | 64 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
918 | 66 | dbus_connection_send(dbus->connection(), reply, nullptr); | 65 | dbus_connection_send(*connection, reply, nullptr); |
919 | 67 | } | 66 | } |
920 | 68 | } | 67 | } |
921 | 69 | 68 | ||
922 | @@ -79,7 +78,7 @@ | |||
923 | 79 | (input_config.get()->*method)(value); | 78 | (input_config.get()->*method)(value); |
924 | 80 | 79 | ||
925 | 81 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; | 80 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
927 | 82 | dbus_connection_send(dbus->connection(), reply, nullptr); | 81 | dbus_connection_send(*connection, reply, nullptr); |
928 | 83 | } | 82 | } |
929 | 84 | } | 83 | } |
930 | 85 | 84 | ||
931 | @@ -95,7 +94,7 @@ | |||
932 | 95 | (input_config.get()->*method)(value); | 94 | (input_config.get()->*method)(value); |
933 | 96 | 95 | ||
934 | 97 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; | 96 | DBusMessageHandle reply{dbus_message_new_method_return(message)}; |
936 | 98 | dbus_connection_send(dbus->connection(), reply, nullptr); | 97 | dbus_connection_send(*connection, reply, nullptr); |
937 | 99 | } | 98 | } |
938 | 100 | } | 99 | } |
939 | 101 | 100 | ||
940 | @@ -151,4 +150,3 @@ | |||
941 | 151 | 150 | ||
942 | 152 | return DBUS_HANDLER_RESULT_HANDLED; | 151 | return DBUS_HANDLER_RESULT_HANDLED; |
943 | 153 | } | 152 | } |
944 | 154 | |||
945 | 155 | 153 | ||
946 | === modified file 'src/unity_input_service.h' | |||
947 | --- src/unity_input_service.h 2015-08-26 08:00:27 +0000 | |||
948 | +++ src/unity_input_service.h 2016-01-21 17:48:37 +0000 | |||
949 | @@ -20,18 +20,20 @@ | |||
950 | 20 | #define USC_UNITY_INPUT_SERVICE_H_ | 20 | #define USC_UNITY_INPUT_SERVICE_H_ |
951 | 21 | 21 | ||
952 | 22 | #include <dbus/dbus.h> | 22 | #include <dbus/dbus.h> |
953 | 23 | #include "dbus_connection_handle.h" | ||
954 | 23 | #include <memory> | 24 | #include <memory> |
955 | 24 | 25 | ||
956 | 25 | namespace usc | 26 | namespace usc |
957 | 26 | { | 27 | { |
959 | 27 | class DBusConnectionThread; | 28 | class DBusEventLoop; |
960 | 28 | class InputConfiguration; | 29 | class InputConfiguration; |
961 | 29 | 30 | ||
962 | 30 | class UnityInputService | 31 | class UnityInputService |
963 | 31 | { | 32 | { |
964 | 32 | public: | 33 | public: |
965 | 33 | UnityInputService( | 34 | UnityInputService( |
967 | 34 | std::shared_ptr<usc::DBusConnectionThread> const& dbus_thread, | 35 | std::shared_ptr<usc::DBusEventLoop> const& loop, |
968 | 36 | std::string const& address, | ||
969 | 35 | std::shared_ptr<usc::InputConfiguration> const& input_config); | 37 | std::shared_ptr<usc::InputConfiguration> const& input_config); |
970 | 36 | 38 | ||
971 | 37 | private: | 39 | private: |
972 | @@ -44,7 +46,8 @@ | |||
973 | 44 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(int32_t)); | 46 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(int32_t)); |
974 | 45 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(double)); | 47 | void handle_message(DBusMessage* message, void (usc::InputConfiguration::* method)(double)); |
975 | 46 | 48 | ||
977 | 47 | std::shared_ptr<usc::DBusConnectionThread> const dbus; | 49 | std::shared_ptr<usc::DBusEventLoop> const loop; |
978 | 50 | std::shared_ptr<usc::DBusConnectionHandle> connection; | ||
979 | 48 | std::shared_ptr<usc::InputConfiguration> const input_config; | 51 | std::shared_ptr<usc::InputConfiguration> const input_config; |
980 | 49 | }; | 52 | }; |
981 | 50 | 53 | ||
982 | 51 | 54 | ||
983 | === modified file 'src/unity_screen_service.cpp' | |||
984 | --- src/unity_screen_service.cpp 2015-08-25 14:35:20 +0000 | |||
985 | +++ src/unity_screen_service.cpp 2016-01-21 17:48:37 +0000 | |||
986 | @@ -19,7 +19,7 @@ | |||
987 | 19 | #include "unity_screen_service.h" | 19 | #include "unity_screen_service.h" |
988 | 20 | #include "screen.h" | 20 | #include "screen.h" |
989 | 21 | #include "dbus_message_handle.h" | 21 | #include "dbus_message_handle.h" |
991 | 22 | #include "dbus_connection_thread.h" | 22 | #include "dbus_event_loop.h" |
992 | 23 | #include "dbus_connection_handle.h" | 23 | #include "dbus_connection_handle.h" |
993 | 24 | #include "scoped_dbus_error.h" | 24 | #include "scoped_dbus_error.h" |
994 | 25 | 25 | ||
995 | @@ -35,20 +35,22 @@ | |||
996 | 35 | } | 35 | } |
997 | 36 | 36 | ||
998 | 37 | usc::UnityScreenService::UnityScreenService( | 37 | usc::UnityScreenService::UnityScreenService( |
1000 | 38 | std::shared_ptr<usc::DBusConnectionThread> const& dbus, | 38 | std::shared_ptr<usc::DBusEventLoop> const& loop, |
1001 | 39 | std::string const& address, | ||
1002 | 39 | std::shared_ptr<usc::Screen> const& screen) | 40 | std::shared_ptr<usc::Screen> const& screen) |
1003 | 40 | : screen{screen}, | 41 | : screen{screen}, |
1005 | 41 | dbus{dbus}, | 42 | loop{loop}, |
1006 | 43 | connection{std::make_shared<DBusConnectionHandle>(address.c_str())}, | ||
1007 | 42 | request_id{0} | 44 | request_id{0} |
1008 | 43 | { | 45 | { |
1012 | 44 | auto const& connection = dbus->connection(); | 46 | loop->add_connection(connection); |
1013 | 45 | connection.request_name(dbus_screen_service_name); | 47 | connection->request_name(dbus_screen_service_name); |
1014 | 46 | connection.add_match( | 48 | connection->add_match( |
1015 | 47 | "type='signal'," | 49 | "type='signal'," |
1016 | 48 | "sender='org.freedesktop.DBus'," | 50 | "sender='org.freedesktop.DBus'," |
1017 | 49 | "interface='org.freedesktop.DBus'," | 51 | "interface='org.freedesktop.DBus'," |
1018 | 50 | "member='NameOwnerChanged'"); | 52 | "member='NameOwnerChanged'"); |
1020 | 51 | connection.add_filter(handle_dbus_message_thunk, this); | 53 | connection->add_filter(handle_dbus_message_thunk, this); |
1021 | 52 | 54 | ||
1022 | 53 | screen->register_power_state_change_handler( | 55 | screen->register_power_state_change_handler( |
1023 | 54 | [this](MirPowerMode mode, PowerStateChangeReason reason) | 56 | [this](MirPowerMode mode, PowerStateChangeReason reason) |
1024 | @@ -332,7 +334,7 @@ | |||
1025 | 332 | int32_t const power_state = (power_mode == MirPowerMode::mir_power_mode_off) ? 0 : 1; | 334 | int32_t const power_state = (power_mode == MirPowerMode::mir_power_mode_off) ? 0 : 1; |
1026 | 333 | int32_t const reason_int = static_cast<int32_t>(reason); | 335 | int32_t const reason_int = static_cast<int32_t>(reason); |
1027 | 334 | 336 | ||
1029 | 335 | dbus->loop().enqueue( | 337 | loop->enqueue( |
1030 | 336 | [this, power_state, reason_int] | 338 | [this, power_state, reason_int] |
1031 | 337 | { | 339 | { |
1032 | 338 | DBusMessageHandle signal{ | 340 | DBusMessageHandle signal{ |
1033 | @@ -344,6 +346,6 @@ | |||
1034 | 344 | DBUS_TYPE_INT32, &reason_int, | 346 | DBUS_TYPE_INT32, &reason_int, |
1035 | 345 | DBUS_TYPE_INVALID}; | 347 | DBUS_TYPE_INVALID}; |
1036 | 346 | 348 | ||
1038 | 347 | dbus_connection_send(dbus->connection(), signal, nullptr); | 349 | dbus_connection_send(*connection, signal, nullptr); |
1039 | 348 | }); | 350 | }); |
1040 | 349 | } | 351 | } |
1041 | 350 | 352 | ||
1042 | === modified file 'src/unity_screen_service.h' | |||
1043 | --- src/unity_screen_service.h 2015-08-25 14:32:32 +0000 | |||
1044 | +++ src/unity_screen_service.h 2016-01-21 17:48:37 +0000 | |||
1045 | @@ -34,13 +34,14 @@ | |||
1046 | 34 | namespace usc | 34 | namespace usc |
1047 | 35 | { | 35 | { |
1048 | 36 | class Screen; | 36 | class Screen; |
1050 | 37 | class DBusConnectionThread; | 37 | class DBusEventLoop; |
1051 | 38 | 38 | ||
1052 | 39 | class UnityScreenService | 39 | class UnityScreenService |
1053 | 40 | { | 40 | { |
1054 | 41 | public: | 41 | public: |
1055 | 42 | UnityScreenService( | 42 | UnityScreenService( |
1057 | 43 | std::shared_ptr<usc::DBusConnectionThread> const& connection, | 43 | std::shared_ptr<usc::DBusEventLoop> const& loop, |
1058 | 44 | std::string const& address, | ||
1059 | 44 | std::shared_ptr<usc::Screen> const& screen); | 45 | std::shared_ptr<usc::Screen> const& screen); |
1060 | 45 | 46 | ||
1061 | 46 | private: | 47 | private: |
1062 | @@ -64,7 +65,8 @@ | |||
1063 | 64 | MirPowerMode power_mode, PowerStateChangeReason reason); | 65 | MirPowerMode power_mode, PowerStateChangeReason reason); |
1064 | 65 | 66 | ||
1065 | 66 | std::shared_ptr<usc::Screen> const screen; | 67 | std::shared_ptr<usc::Screen> const screen; |
1067 | 67 | std::shared_ptr<DBusConnectionThread> const dbus; | 68 | std::shared_ptr<DBusEventLoop> const loop; |
1068 | 69 | std::shared_ptr<DBusConnectionHandle> connection; | ||
1069 | 68 | 70 | ||
1070 | 69 | std::mutex keep_display_on_mutex; | 71 | std::mutex keep_display_on_mutex; |
1071 | 70 | std::unordered_multimap<std::string,int32_t> keep_display_on_ids; | 72 | std::unordered_multimap<std::string,int32_t> keep_display_on_ids; |
1072 | 71 | 73 | ||
1073 | === added file 'tests/include/usc/test/mock_input_configuration.h' | |||
1074 | --- tests/include/usc/test/mock_input_configuration.h 1970-01-01 00:00:00 +0000 | |||
1075 | +++ tests/include/usc/test/mock_input_configuration.h 2016-01-21 17:48:37 +0000 | |||
1076 | @@ -0,0 +1,48 @@ | |||
1077 | 1 | /* | ||
1078 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1079 | 3 | * | ||
1080 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1081 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1082 | 6 | * published by the Free Software Foundation. | ||
1083 | 7 | * | ||
1084 | 8 | * This program is distributed in the hope that it will be useful, | ||
1085 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1086 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1087 | 11 | * GNU General Public License for more details. | ||
1088 | 12 | * | ||
1089 | 13 | * You should have received a copy of the GNU General Public License | ||
1090 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1091 | 15 | * | ||
1092 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1093 | 17 | */ | ||
1094 | 18 | |||
1095 | 19 | #ifndef USC_TEST_MOCK_INPUT_CONFIGURATION_H_ | ||
1096 | 20 | #define USC_TEST_MOCK_INPUT_CONFIGURATION_H_ | ||
1097 | 21 | |||
1098 | 22 | #include "src/input_configuration.h" | ||
1099 | 23 | |||
1100 | 24 | #include <gtest/gtest.h> | ||
1101 | 25 | #include <gmock/gmock.h> | ||
1102 | 26 | |||
1103 | 27 | namespace usc | ||
1104 | 28 | { | ||
1105 | 29 | namespace test | ||
1106 | 30 | { | ||
1107 | 31 | struct MockInputConfiguration : usc::InputConfiguration | ||
1108 | 32 | { | ||
1109 | 33 | public: | ||
1110 | 34 | MOCK_METHOD1(set_mouse_primary_button, void(int32_t)); | ||
1111 | 35 | MOCK_METHOD1(set_mouse_cursor_speed, void(double)); | ||
1112 | 36 | MOCK_METHOD1(set_mouse_scroll_speed, void(double)); | ||
1113 | 37 | MOCK_METHOD1(set_touchpad_primary_button, void(int32_t)); | ||
1114 | 38 | MOCK_METHOD1(set_touchpad_cursor_speed, void(double)); | ||
1115 | 39 | MOCK_METHOD1(set_touchpad_scroll_speed, void(double)); | ||
1116 | 40 | MOCK_METHOD1(set_two_finger_scroll, void(bool)); | ||
1117 | 41 | MOCK_METHOD1(set_tap_to_click, void(bool)); | ||
1118 | 42 | MOCK_METHOD1(set_disable_touchpad_with_mouse, void(bool)); | ||
1119 | 43 | MOCK_METHOD1(set_disable_touchpad_while_typing, void(bool)); | ||
1120 | 44 | }; | ||
1121 | 45 | } | ||
1122 | 46 | } | ||
1123 | 47 | |||
1124 | 48 | #endif | ||
1125 | 0 | 49 | ||
1126 | === added file 'tests/include/usc/test/mock_screen.h' | |||
1127 | --- tests/include/usc/test/mock_screen.h 1970-01-01 00:00:00 +0000 | |||
1128 | +++ tests/include/usc/test/mock_screen.h 2016-01-21 17:48:37 +0000 | |||
1129 | @@ -0,0 +1,57 @@ | |||
1130 | 1 | /* | ||
1131 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1132 | 3 | * | ||
1133 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1134 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1135 | 6 | * published by the Free Software Foundation. | ||
1136 | 7 | * | ||
1137 | 8 | * This program is distributed in the hope that it will be useful, | ||
1138 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1139 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1140 | 11 | * GNU General Public License for more details. | ||
1141 | 12 | * | ||
1142 | 13 | * You should have received a copy of the GNU General Public License | ||
1143 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1144 | 15 | * | ||
1145 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1146 | 17 | */ | ||
1147 | 18 | |||
1148 | 19 | #ifndef USC_TEST_MOCK_SCREEN_H_ | ||
1149 | 20 | #define USC_TEST_MOCK_SCREEN_H_ | ||
1150 | 21 | |||
1151 | 22 | #include "src/screen.h" | ||
1152 | 23 | |||
1153 | 24 | #include <gtest/gtest.h> | ||
1154 | 25 | #include <gmock/gmock.h> | ||
1155 | 26 | namespace usc | ||
1156 | 27 | { | ||
1157 | 28 | namespace test | ||
1158 | 29 | { | ||
1159 | 30 | |||
1160 | 31 | struct MockScreen : usc::Screen | ||
1161 | 32 | { | ||
1162 | 33 | MOCK_METHOD1(enable_inactivity_timers, void(bool enable)); | ||
1163 | 34 | MOCK_METHOD0(keep_display_on_temporarily, void()); | ||
1164 | 35 | |||
1165 | 36 | MOCK_METHOD0(get_screen_power_mode, MirPowerMode()); | ||
1166 | 37 | MOCK_METHOD2(set_screen_power_mode, void(MirPowerMode mode, PowerStateChangeReason reason)); | ||
1167 | 38 | MOCK_METHOD1(keep_display_on, void(bool on)); | ||
1168 | 39 | MOCK_METHOD1(set_brightness, void(int brightness)); | ||
1169 | 40 | MOCK_METHOD1(enable_auto_brightness, void(bool enable)); | ||
1170 | 41 | MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout)); | ||
1171 | 42 | |||
1172 | 43 | MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled)); | ||
1173 | 44 | |||
1174 | 45 | void register_power_state_change_handler( | ||
1175 | 46 | usc::PowerStateChangeHandler const& handler) | ||
1176 | 47 | { | ||
1177 | 48 | power_state_change_handler = handler; | ||
1178 | 49 | } | ||
1179 | 50 | |||
1180 | 51 | usc::PowerStateChangeHandler power_state_change_handler; | ||
1181 | 52 | }; | ||
1182 | 53 | |||
1183 | 54 | } | ||
1184 | 55 | } | ||
1185 | 56 | |||
1186 | 57 | #endif | ||
1187 | 0 | 58 | ||
1188 | === modified file 'tests/integration-tests/CMakeLists.txt' | |||
1189 | --- tests/integration-tests/CMakeLists.txt 2015-09-22 16:17:40 +0000 | |||
1190 | +++ tests/integration-tests/CMakeLists.txt 2016-01-21 17:48:37 +0000 | |||
1191 | @@ -33,9 +33,12 @@ | |||
1192 | 33 | dbus_bus.cpp | 33 | dbus_bus.cpp |
1193 | 34 | dbus_client.cpp | 34 | dbus_client.cpp |
1194 | 35 | spin_wait.cpp | 35 | spin_wait.cpp |
1195 | 36 | unity_screen_dbus_client.cpp | ||
1196 | 37 | unity_input_dbus_client.cpp | ||
1197 | 36 | test_dbus_event_loop.cpp | 38 | test_dbus_event_loop.cpp |
1198 | 37 | test_unity_screen_service.cpp | 39 | test_unity_screen_service.cpp |
1199 | 38 | test_unity_input_service.cpp | 40 | test_unity_input_service.cpp |
1200 | 41 | test_unity_services.cpp | ||
1201 | 39 | test_external_spinner.cpp | 42 | test_external_spinner.cpp |
1202 | 40 | test_powerd_mediator.cpp | 43 | test_powerd_mediator.cpp |
1203 | 41 | test_deadlock_lp1491566.cpp | 44 | test_deadlock_lp1491566.cpp |
1204 | 42 | 45 | ||
1205 | === modified file 'tests/integration-tests/test_dbus_event_loop.cpp' | |||
1206 | --- tests/integration-tests/test_dbus_event_loop.cpp 2015-05-27 09:42:40 +0000 | |||
1207 | +++ tests/integration-tests/test_dbus_event_loop.cpp 2016-01-21 17:48:37 +0000 | |||
1208 | @@ -79,8 +79,9 @@ | |||
1209 | 79 | { | 79 | { |
1210 | 80 | ADBusEventLoop() | 80 | ADBusEventLoop() |
1211 | 81 | { | 81 | { |
1214 | 82 | connection.request_name(test_service_name); | 82 | dbus_event_loop.add_connection(connection); |
1215 | 83 | connection.add_filter(handle_dbus_message_thunk, this); | 83 | connection->request_name(test_service_name); |
1216 | 84 | connection->add_filter(handle_dbus_message_thunk, this); | ||
1217 | 84 | 85 | ||
1218 | 85 | std::promise<void> event_loop_started; | 86 | std::promise<void> event_loop_started; |
1219 | 86 | auto event_loop_started_future = event_loop_started.get_future(); | 87 | auto event_loop_started_future = event_loop_started.get_future(); |
1220 | @@ -102,8 +103,7 @@ | |||
1221 | 102 | } | 103 | } |
1222 | 103 | 104 | ||
1223 | 104 | static ::DBusHandlerResult handle_dbus_message_thunk( | 105 | static ::DBusHandlerResult handle_dbus_message_thunk( |
1226 | 105 | ::DBusConnection* connection, DBusMessage* message, void* user_data) | 106 | ::DBusConnection* connection, DBusMessage* message, void* user_data) { |
1225 | 106 | { | ||
1227 | 107 | auto const a_dbus_event_loop = static_cast<ADBusEventLoop*>(user_data); | 107 | auto const a_dbus_event_loop = static_cast<ADBusEventLoop*>(user_data); |
1228 | 108 | return a_dbus_event_loop->handle_dbus_message(connection, message, user_data); | 108 | return a_dbus_event_loop->handle_dbus_message(connection, message, user_data); |
1229 | 109 | } | 109 | } |
1230 | @@ -142,8 +142,8 @@ | |||
1231 | 142 | 142 | ||
1232 | 143 | ut::DBusBus bus; | 143 | ut::DBusBus bus; |
1233 | 144 | 144 | ||
1236 | 145 | usc::DBusConnectionHandle connection{bus.address().c_str()}; | 145 | std::shared_ptr<usc::DBusConnectionHandle> connection{std::make_shared<usc::DBusConnectionHandle>(bus.address())}; |
1237 | 146 | usc::DBusEventLoop dbus_event_loop{connection}; | 146 | usc::DBusEventLoop dbus_event_loop{}; |
1238 | 147 | std::thread dbus_loop_thread; | 147 | std::thread dbus_loop_thread; |
1239 | 148 | TestDBusClient client{bus.address()}; | 148 | TestDBusClient client{bus.address()}; |
1240 | 149 | }; | 149 | }; |
1241 | @@ -173,7 +173,7 @@ | |||
1242 | 173 | test_service_interface, | 173 | test_service_interface, |
1243 | 174 | "signal")}; | 174 | "signal")}; |
1244 | 175 | 175 | ||
1246 | 176 | dbus_connection_send(connection, msg, nullptr); | 176 | dbus_connection_send(*connection, msg, nullptr); |
1247 | 177 | }); | 177 | }); |
1248 | 178 | 178 | ||
1249 | 179 | auto const reply = client.listen_for_signal(); | 179 | auto const reply = client.listen_for_signal(); |
1250 | @@ -214,7 +214,7 @@ | |||
1251 | 214 | 214 | ||
1252 | 215 | DBusPendingCall* pending{nullptr}; | 215 | DBusPendingCall* pending{nullptr}; |
1253 | 216 | dbus_connection_send_with_reply( | 216 | dbus_connection_send_with_reply( |
1255 | 217 | connection, msg, &pending, timeout_ms); | 217 | *connection, msg, &pending, timeout_ms); |
1256 | 218 | dbus_pending_call_set_notify( | 218 | dbus_pending_call_set_notify( |
1257 | 219 | pending, &pending_complete, &pending_promise, nullptr); | 219 | pending, &pending_complete, &pending_promise, nullptr); |
1258 | 220 | }); | 220 | }); |
1259 | 221 | 221 | ||
1260 | === modified file 'tests/integration-tests/test_powerd_mediator.cpp' | |||
1261 | --- tests/integration-tests/test_powerd_mediator.cpp 2015-07-17 12:43:46 +0000 | |||
1262 | +++ tests/integration-tests/test_powerd_mediator.cpp 2016-01-21 17:48:37 +0000 | |||
1263 | @@ -41,9 +41,10 @@ | |||
1264 | 41 | dbus_bool_t auto_brightness_supported, | 41 | dbus_bool_t auto_brightness_supported, |
1265 | 42 | StartNow start_now) | 42 | StartNow start_now) |
1266 | 43 | : auto_brightness_supported{auto_brightness_supported}, | 43 | : auto_brightness_supported{auto_brightness_supported}, |
1269 | 44 | connection{address.c_str()}, | 44 | connection{std::make_shared<usc::DBusConnectionHandle>(address)}, |
1270 | 45 | dbus_event_loop{connection} | 45 | dbus_event_loop{} |
1271 | 46 | { | 46 | { |
1272 | 47 | dbus_event_loop.add_connection(connection); | ||
1273 | 47 | if (start_now == StartNow::yes) | 48 | if (start_now == StartNow::yes) |
1274 | 48 | start(); | 49 | start(); |
1275 | 49 | } | 50 | } |
1276 | @@ -60,8 +61,8 @@ | |||
1277 | 60 | ON_CALL(*this, dbus_setUserBrightness(normal_brightness)) | 61 | ON_CALL(*this, dbus_setUserBrightness(normal_brightness)) |
1278 | 61 | .WillByDefault(WakeUp(&initial_setup_done)); | 62 | .WillByDefault(WakeUp(&initial_setup_done)); |
1279 | 62 | 63 | ||
1282 | 63 | connection.request_name(powerd_service_name); | 64 | connection->request_name(powerd_service_name); |
1283 | 64 | connection.add_filter(handle_dbus_message_thunk, this); | 65 | connection->add_filter(handle_dbus_message_thunk, this); |
1284 | 65 | 66 | ||
1285 | 66 | std::promise<void> event_loop_started; | 67 | std::promise<void> event_loop_started; |
1286 | 67 | auto event_loop_started_future = event_loop_started.get_future(); | 68 | auto event_loop_started_future = event_loop_started.get_future(); |
1287 | @@ -104,7 +105,7 @@ | |||
1288 | 104 | DBUS_TYPE_INT32, &state, | 105 | DBUS_TYPE_INT32, &state, |
1289 | 105 | DBUS_TYPE_INVALID}; | 106 | DBUS_TYPE_INVALID}; |
1290 | 106 | 107 | ||
1292 | 107 | dbus_connection_send(connection, signal, nullptr); | 108 | dbus_connection_send(*connection, signal, nullptr); |
1293 | 108 | } | 109 | } |
1294 | 109 | 110 | ||
1295 | 110 | private: | 111 | private: |
1296 | @@ -230,7 +231,7 @@ | |||
1297 | 230 | 231 | ||
1298 | 231 | ut::WaitCondition initial_setup_done; | 232 | ut::WaitCondition initial_setup_done; |
1299 | 232 | 233 | ||
1301 | 233 | usc::DBusConnectionHandle connection; | 234 | std::shared_ptr<usc::DBusConnectionHandle> connection; |
1302 | 234 | usc::DBusEventLoop dbus_event_loop; | 235 | usc::DBusEventLoop dbus_event_loop; |
1303 | 235 | std::thread dbus_loop_thread; | 236 | std::thread dbus_loop_thread; |
1304 | 236 | }; | 237 | }; |
1305 | 237 | 238 | ||
1306 | === modified file 'tests/integration-tests/test_unity_input_service.cpp' | |||
1307 | --- tests/integration-tests/test_unity_input_service.cpp 2015-08-28 15:57:25 +0000 | |||
1308 | +++ tests/integration-tests/test_unity_input_service.cpp 2016-01-21 17:48:37 +0000 | |||
1309 | @@ -19,15 +19,16 @@ | |||
1310 | 19 | #include "src/unity_input_service.h" | 19 | #include "src/unity_input_service.h" |
1311 | 20 | #include "src/dbus_connection_handle.h" | 20 | #include "src/dbus_connection_handle.h" |
1312 | 21 | #include "src/dbus_connection_thread.h" | 21 | #include "src/dbus_connection_thread.h" |
1313 | 22 | #include "src/dbus_event_loop.h" | ||
1314 | 22 | #include "src/dbus_message_handle.h" | 23 | #include "src/dbus_message_handle.h" |
1315 | 23 | #include "src/input_configuration.h" | ||
1316 | 24 | #include "src/unity_input_service_introspection.h" | 24 | #include "src/unity_input_service_introspection.h" |
1317 | 25 | |||
1318 | 25 | #include "wait_condition.h" | 26 | #include "wait_condition.h" |
1319 | 26 | #include "dbus_bus.h" | 27 | #include "dbus_bus.h" |
1320 | 27 | #include "dbus_client.h" | 28 | #include "dbus_client.h" |
1321 | 29 | #include "unity_input_dbus_client.h" | ||
1322 | 28 | 30 | ||
1325 | 29 | #include <gtest/gtest.h> | 31 | #include "usc/test/mock_input_configuration.h" |
1324 | 30 | #include <gmock/gmock.h> | ||
1326 | 31 | 32 | ||
1327 | 32 | #include <stdexcept> | 33 | #include <stdexcept> |
1328 | 33 | #include <memory> | 34 | #include <memory> |
1329 | @@ -37,128 +38,19 @@ | |||
1330 | 37 | namespace | 38 | namespace |
1331 | 38 | { | 39 | { |
1332 | 39 | 40 | ||
1333 | 40 | struct MockInputConfiguration : usc::InputConfiguration | ||
1334 | 41 | { | ||
1335 | 42 | public: | ||
1336 | 43 | MOCK_METHOD1(set_mouse_primary_button, void(int32_t)); | ||
1337 | 44 | MOCK_METHOD1(set_mouse_cursor_speed, void(double)); | ||
1338 | 45 | MOCK_METHOD1(set_mouse_scroll_speed, void(double)); | ||
1339 | 46 | MOCK_METHOD1(set_touchpad_primary_button, void(int32_t)); | ||
1340 | 47 | MOCK_METHOD1(set_touchpad_cursor_speed, void(double)); | ||
1341 | 48 | MOCK_METHOD1(set_touchpad_scroll_speed, void(double)); | ||
1342 | 49 | MOCK_METHOD1(set_two_finger_scroll, void(bool)); | ||
1343 | 50 | MOCK_METHOD1(set_tap_to_click, void(bool)); | ||
1344 | 51 | MOCK_METHOD1(set_disable_touchpad_with_mouse, void(bool)); | ||
1345 | 52 | MOCK_METHOD1(set_disable_touchpad_while_typing, void(bool)); | ||
1346 | 53 | }; | ||
1347 | 54 | |||
1348 | 55 | class UnityInputDBusClient : public ut::DBusClient | ||
1349 | 56 | { | ||
1350 | 57 | public: | ||
1351 | 58 | UnityInputDBusClient(std::string const& address) | ||
1352 | 59 | : ut::DBusClient{ | ||
1353 | 60 | address, | ||
1354 | 61 | "com.canonical.Unity.Input", | ||
1355 | 62 | "/com/canonical/Unity/Input"} | ||
1356 | 63 | { | ||
1357 | 64 | } | ||
1358 | 65 | |||
1359 | 66 | ut::DBusAsyncReplyString request_introspection() | ||
1360 | 67 | { | ||
1361 | 68 | return invoke_with_reply<ut::DBusAsyncReplyString>( | ||
1362 | 69 | "org.freedesktop.DBus.Introspectable", "Introspect", | ||
1363 | 70 | DBUS_TYPE_INVALID); | ||
1364 | 71 | } | ||
1365 | 72 | |||
1366 | 73 | ut::DBusAsyncReplyVoid request(char const* requestName, int32_t value) | ||
1367 | 74 | { | ||
1368 | 75 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1369 | 76 | unity_input_interface, requestName, | ||
1370 | 77 | DBUS_TYPE_INT32, &value, | ||
1371 | 78 | DBUS_TYPE_INVALID); | ||
1372 | 79 | } | ||
1373 | 80 | |||
1374 | 81 | ut::DBusAsyncReplyVoid request_set_mouse_primary_button(int32_t button) | ||
1375 | 82 | { | ||
1376 | 83 | return request("setMousePrimaryButton", button); | ||
1377 | 84 | } | ||
1378 | 85 | |||
1379 | 86 | ut::DBusAsyncReplyVoid request_set_touchpad_primary_button(int32_t button) | ||
1380 | 87 | { | ||
1381 | 88 | return request("setTouchpadPrimaryButton", button); | ||
1382 | 89 | } | ||
1383 | 90 | |||
1384 | 91 | ut::DBusAsyncReplyVoid request(char const* requestName, double value) | ||
1385 | 92 | { | ||
1386 | 93 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1387 | 94 | unity_input_interface, requestName, | ||
1388 | 95 | DBUS_TYPE_DOUBLE, &value, | ||
1389 | 96 | DBUS_TYPE_INVALID); | ||
1390 | 97 | } | ||
1391 | 98 | |||
1392 | 99 | ut::DBusAsyncReplyVoid request_set_mouse_cursor_speed(double speed) | ||
1393 | 100 | { | ||
1394 | 101 | return request("setMouseCursorSpeed", speed); | ||
1395 | 102 | } | ||
1396 | 103 | |||
1397 | 104 | ut::DBusAsyncReplyVoid request_set_mouse_scroll_speed(double speed) | ||
1398 | 105 | { | ||
1399 | 106 | return request("setMouseScrollSpeed", speed); | ||
1400 | 107 | } | ||
1401 | 108 | |||
1402 | 109 | ut::DBusAsyncReplyVoid request_set_touchpad_cursor_speed(double speed) | ||
1403 | 110 | { | ||
1404 | 111 | return request("setTouchpadCursorSpeed", speed); | ||
1405 | 112 | } | ||
1406 | 113 | |||
1407 | 114 | ut::DBusAsyncReplyVoid request_set_touchpad_scroll_speed(double speed) | ||
1408 | 115 | { | ||
1409 | 116 | return request("setTouchpadScrollSpeed", speed); | ||
1410 | 117 | } | ||
1411 | 118 | |||
1412 | 119 | ut::DBusAsyncReplyVoid request(char const* requestName, bool value) | ||
1413 | 120 | { | ||
1414 | 121 | dbus_bool_t copied = value; | ||
1415 | 122 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1416 | 123 | unity_input_interface, requestName, | ||
1417 | 124 | DBUS_TYPE_BOOLEAN, &copied, | ||
1418 | 125 | DBUS_TYPE_INVALID); | ||
1419 | 126 | } | ||
1420 | 127 | |||
1421 | 128 | ut::DBusAsyncReplyVoid request_set_touchpad_two_finger_scroll(bool enabled) | ||
1422 | 129 | { | ||
1423 | 130 | return request("setTouchpadTwoFingerScroll", enabled); | ||
1424 | 131 | } | ||
1425 | 132 | |||
1426 | 133 | ut::DBusAsyncReplyVoid request_set_touchpad_tap_to_click(bool enabled) | ||
1427 | 134 | { | ||
1428 | 135 | return request("setTouchpadTapToClick", enabled); | ||
1429 | 136 | } | ||
1430 | 137 | |||
1431 | 138 | ut::DBusAsyncReplyVoid request_set_touchpad_disable_with_mouse(bool enabled) | ||
1432 | 139 | { | ||
1433 | 140 | return request("setTouchpadDisableWithMouse", enabled); | ||
1434 | 141 | } | ||
1435 | 142 | |||
1436 | 143 | ut::DBusAsyncReplyVoid request_set_touchpad_disable_while_typing(bool enabled) | ||
1437 | 144 | { | ||
1438 | 145 | return request("setTouchpadDisableWhileTyping", enabled); | ||
1439 | 146 | } | ||
1440 | 147 | |||
1441 | 148 | char const* const unity_input_interface = "com.canonical.Unity.Input"; | ||
1442 | 149 | }; | ||
1443 | 150 | |||
1444 | 151 | struct AUnityInputService : testing::Test | 41 | struct AUnityInputService : testing::Test |
1445 | 152 | { | 42 | { |
1446 | 153 | std::chrono::seconds const default_timeout{3}; | 43 | std::chrono::seconds const default_timeout{3}; |
1447 | 154 | ut::DBusBus bus; | 44 | ut::DBusBus bus; |
1448 | 155 | 45 | ||
1452 | 156 | std::shared_ptr<MockInputConfiguration> const mock_input_configuration = | 46 | std::shared_ptr<ut::MockInputConfiguration> const mock_input_configuration = |
1453 | 157 | std::make_shared<testing::NiceMock<MockInputConfiguration>>(); | 47 | std::make_shared<testing::NiceMock<ut::MockInputConfiguration>>(); |
1454 | 158 | UnityInputDBusClient client{bus.address()}; | 48 | ut::UnityInputDBusClient client{bus.address()}; |
1455 | 49 | std::shared_ptr<usc::DBusEventLoop> const dbus_loop= | ||
1456 | 50 | std::make_shared<usc::DBusEventLoop>(); | ||
1457 | 51 | usc::UnityInputService service{dbus_loop, bus.address(), mock_input_configuration}; | ||
1458 | 159 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = | 52 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = |
1461 | 160 | std::make_shared<usc::DBusConnectionThread>(bus.address()); | 53 | std::make_shared<usc::DBusConnectionThread>(dbus_loop); |
1460 | 161 | usc::UnityInputService service{dbus_thread, mock_input_configuration}; | ||
1462 | 162 | }; | 54 | }; |
1463 | 163 | 55 | ||
1464 | 164 | } | 56 | } |
1465 | 165 | 57 | ||
1466 | === modified file 'tests/integration-tests/test_unity_screen_service.cpp' | |||
1467 | --- tests/integration-tests/test_unity_screen_service.cpp 2015-08-25 14:27:23 +0000 | |||
1468 | +++ tests/integration-tests/test_unity_screen_service.cpp 2016-01-21 17:48:37 +0000 | |||
1469 | @@ -19,14 +19,16 @@ | |||
1470 | 19 | #include "src/unity_screen_service.h" | 19 | #include "src/unity_screen_service.h" |
1471 | 20 | #include "src/dbus_connection_handle.h" | 20 | #include "src/dbus_connection_handle.h" |
1472 | 21 | #include "src/dbus_connection_thread.h" | 21 | #include "src/dbus_connection_thread.h" |
1473 | 22 | #include "src/dbus_event_loop.h" | ||
1474 | 22 | #include "src/dbus_message_handle.h" | 23 | #include "src/dbus_message_handle.h" |
1475 | 23 | #include "src/screen.h" | 24 | #include "src/screen.h" |
1476 | 24 | #include "src/power_state_change_reason.h" | 25 | #include "src/power_state_change_reason.h" |
1477 | 25 | #include "src/unity_screen_service_introspection.h" | 26 | #include "src/unity_screen_service_introspection.h" |
1478 | 26 | #include "wait_condition.h" | 27 | #include "wait_condition.h" |
1479 | 27 | #include "dbus_bus.h" | 28 | #include "dbus_bus.h" |
1481 | 28 | #include "dbus_client.h" | 29 | #include "unity_screen_dbus_client.h" |
1482 | 29 | 30 | ||
1483 | 31 | #include "usc/test/mock_screen.h" | ||
1484 | 30 | #include <gtest/gtest.h> | 32 | #include <gtest/gtest.h> |
1485 | 31 | #include <gmock/gmock.h> | 33 | #include <gmock/gmock.h> |
1486 | 32 | 34 | ||
1487 | @@ -38,157 +40,20 @@ | |||
1488 | 38 | namespace | 40 | namespace |
1489 | 39 | { | 41 | { |
1490 | 40 | 42 | ||
1491 | 41 | struct MockScreen : usc::Screen | ||
1492 | 42 | { | ||
1493 | 43 | MOCK_METHOD1(enable_inactivity_timers, void(bool enable)); | ||
1494 | 44 | MOCK_METHOD0(keep_display_on_temporarily, void()); | ||
1495 | 45 | |||
1496 | 46 | MOCK_METHOD0(get_screen_power_mode, MirPowerMode()); | ||
1497 | 47 | MOCK_METHOD2(set_screen_power_mode, void(MirPowerMode mode, PowerStateChangeReason reason)); | ||
1498 | 48 | MOCK_METHOD1(keep_display_on, void(bool on)); | ||
1499 | 49 | MOCK_METHOD1(set_brightness, void(int brightness)); | ||
1500 | 50 | MOCK_METHOD1(enable_auto_brightness, void(bool enable)); | ||
1501 | 51 | MOCK_METHOD2(set_inactivity_timeouts, void(int power_off_timeout, int dimmer_timeout)); | ||
1502 | 52 | |||
1503 | 53 | MOCK_METHOD1(set_touch_visualization_enabled, void(bool enabled)); | ||
1504 | 54 | |||
1505 | 55 | void register_power_state_change_handler( | ||
1506 | 56 | usc::PowerStateChangeHandler const& handler) | ||
1507 | 57 | { | ||
1508 | 58 | power_state_change_handler = handler; | ||
1509 | 59 | } | ||
1510 | 60 | |||
1511 | 61 | usc::PowerStateChangeHandler power_state_change_handler; | ||
1512 | 62 | }; | ||
1513 | 63 | |||
1514 | 64 | class UnityScreenDBusClient : public ut::DBusClient | ||
1515 | 65 | { | ||
1516 | 66 | public: | ||
1517 | 67 | UnityScreenDBusClient(std::string const& address) | ||
1518 | 68 | : ut::DBusClient{ | ||
1519 | 69 | address, | ||
1520 | 70 | "com.canonical.Unity.Screen", | ||
1521 | 71 | "/com/canonical/Unity/Screen"} | ||
1522 | 72 | { | ||
1523 | 73 | connection.add_match( | ||
1524 | 74 | "type='signal'," | ||
1525 | 75 | "interface='com.canonical.Unity.Screen'," | ||
1526 | 76 | "member='DisplayPowerStateChange'"); | ||
1527 | 77 | } | ||
1528 | 78 | |||
1529 | 79 | ut::DBusAsyncReplyString request_introspection() | ||
1530 | 80 | { | ||
1531 | 81 | return invoke_with_reply<ut::DBusAsyncReplyString>( | ||
1532 | 82 | "org.freedesktop.DBus.Introspectable", "Introspect", | ||
1533 | 83 | DBUS_TYPE_INVALID); | ||
1534 | 84 | } | ||
1535 | 85 | |||
1536 | 86 | ut::DBusAsyncReplyVoid request_set_user_brightness(int32_t brightness) | ||
1537 | 87 | { | ||
1538 | 88 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1539 | 89 | unity_screen_interface, "setUserBrightness", | ||
1540 | 90 | DBUS_TYPE_INT32, &brightness, | ||
1541 | 91 | DBUS_TYPE_INVALID); | ||
1542 | 92 | } | ||
1543 | 93 | |||
1544 | 94 | ut::DBusAsyncReplyVoid request_user_auto_brightness_enable(bool enabled) | ||
1545 | 95 | { | ||
1546 | 96 | dbus_bool_t const e = enabled ? TRUE : FALSE; | ||
1547 | 97 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1548 | 98 | unity_screen_interface, "userAutobrightnessEnable", | ||
1549 | 99 | DBUS_TYPE_BOOLEAN, &e, | ||
1550 | 100 | DBUS_TYPE_INVALID); | ||
1551 | 101 | } | ||
1552 | 102 | |||
1553 | 103 | ut::DBusAsyncReplyVoid request_set_inactivity_timeouts( | ||
1554 | 104 | int32_t poweroff_timeout, int32_t dimmer_timeout) | ||
1555 | 105 | { | ||
1556 | 106 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1557 | 107 | unity_screen_interface, "setInactivityTimeouts", | ||
1558 | 108 | DBUS_TYPE_INT32, &poweroff_timeout, | ||
1559 | 109 | DBUS_TYPE_INT32, &dimmer_timeout, | ||
1560 | 110 | DBUS_TYPE_INVALID); | ||
1561 | 111 | } | ||
1562 | 112 | |||
1563 | 113 | ut::DBusAsyncReplyVoid request_set_touch_visualization_enabled(bool enabled) | ||
1564 | 114 | { | ||
1565 | 115 | dbus_bool_t const e = enabled ? TRUE : FALSE; | ||
1566 | 116 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1567 | 117 | unity_screen_interface, "setTouchVisualizationEnabled", | ||
1568 | 118 | DBUS_TYPE_BOOLEAN, &e, | ||
1569 | 119 | DBUS_TYPE_INVALID); | ||
1570 | 120 | } | ||
1571 | 121 | |||
1572 | 122 | ut::DBusAsyncReplyBool request_set_screen_power_mode( | ||
1573 | 123 | std::string const& mode, int reason) | ||
1574 | 124 | { | ||
1575 | 125 | auto mode_cstr = mode.c_str(); | ||
1576 | 126 | return invoke_with_reply<ut::DBusAsyncReplyBool>( | ||
1577 | 127 | unity_screen_interface, "setScreenPowerMode", | ||
1578 | 128 | DBUS_TYPE_STRING, &mode_cstr, | ||
1579 | 129 | DBUS_TYPE_INT32, &reason, | ||
1580 | 130 | DBUS_TYPE_INVALID); | ||
1581 | 131 | } | ||
1582 | 132 | |||
1583 | 133 | ut::DBusAsyncReplyInt request_keep_display_on() | ||
1584 | 134 | { | ||
1585 | 135 | return invoke_with_reply<ut::DBusAsyncReplyInt>( | ||
1586 | 136 | unity_screen_interface, "keepDisplayOn", | ||
1587 | 137 | DBUS_TYPE_INVALID); | ||
1588 | 138 | } | ||
1589 | 139 | |||
1590 | 140 | ut::DBusAsyncReplyVoid request_remove_display_on_request(int id) | ||
1591 | 141 | { | ||
1592 | 142 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1593 | 143 | unity_screen_interface, "removeDisplayOnRequest", | ||
1594 | 144 | DBUS_TYPE_INT32, &id, | ||
1595 | 145 | DBUS_TYPE_INVALID); | ||
1596 | 146 | } | ||
1597 | 147 | |||
1598 | 148 | ut::DBusAsyncReply request_invalid_method() | ||
1599 | 149 | { | ||
1600 | 150 | return invoke_with_reply<ut::DBusAsyncReply>( | ||
1601 | 151 | unity_screen_interface, "invalidMethod", | ||
1602 | 152 | DBUS_TYPE_INVALID); | ||
1603 | 153 | } | ||
1604 | 154 | |||
1605 | 155 | ut::DBusAsyncReply request_method_with_invalid_arguments() | ||
1606 | 156 | { | ||
1607 | 157 | char const* const str = "abcd"; | ||
1608 | 158 | return invoke_with_reply<ut::DBusAsyncReply>( | ||
1609 | 159 | unity_screen_interface, "setUserBrightness", | ||
1610 | 160 | DBUS_TYPE_STRING, &str, | ||
1611 | 161 | DBUS_TYPE_INVALID); | ||
1612 | 162 | } | ||
1613 | 163 | |||
1614 | 164 | usc::DBusMessageHandle listen_for_power_state_change_signal() | ||
1615 | 165 | { | ||
1616 | 166 | while (true) | ||
1617 | 167 | { | ||
1618 | 168 | dbus_connection_read_write(connection, 1); | ||
1619 | 169 | auto msg = usc::DBusMessageHandle{dbus_connection_pop_message(connection)}; | ||
1620 | 170 | |||
1621 | 171 | if (msg && dbus_message_is_signal(msg, "com.canonical.Unity.Screen", "DisplayPowerStateChange")) | ||
1622 | 172 | { | ||
1623 | 173 | return msg; | ||
1624 | 174 | } | ||
1625 | 175 | } | ||
1626 | 176 | } | ||
1627 | 177 | |||
1628 | 178 | char const* const unity_screen_interface = "com.canonical.Unity.Screen"; | ||
1629 | 179 | }; | ||
1630 | 180 | |||
1631 | 181 | struct AUnityScreenService : testing::Test | 43 | struct AUnityScreenService : testing::Test |
1632 | 182 | { | 44 | { |
1633 | 183 | std::chrono::seconds const default_timeout{3}; | 45 | std::chrono::seconds const default_timeout{3}; |
1634 | 184 | ut::DBusBus bus; | 46 | ut::DBusBus bus; |
1635 | 185 | 47 | ||
1639 | 186 | std::shared_ptr<MockScreen> const mock_screen = | 48 | std::shared_ptr<ut::MockScreen> const mock_screen = |
1640 | 187 | std::make_shared<testing::NiceMock<MockScreen>>(); | 49 | std::make_shared<testing::NiceMock<ut::MockScreen>>(); |
1641 | 188 | UnityScreenDBusClient client{bus.address()}; | 50 | ut::UnityScreenDBusClient client{bus.address()}; |
1642 | 51 | std::shared_ptr<usc::DBusEventLoop> const dbus_loop= | ||
1643 | 52 | std::make_shared<usc::DBusEventLoop>(); | ||
1644 | 53 | usc::UnityScreenService service{dbus_loop, bus.address(), mock_screen}; | ||
1645 | 189 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = | 54 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = |
1648 | 190 | std::make_shared<usc::DBusConnectionThread>(bus.address()); | 55 | std::make_shared<usc::DBusConnectionThread>(dbus_loop); |
1649 | 191 | usc::UnityScreenService service{dbus_thread, mock_screen}; | 56 | |
1650 | 192 | }; | 57 | }; |
1651 | 193 | 58 | ||
1652 | 194 | } | 59 | } |
1653 | @@ -340,7 +205,7 @@ | |||
1654 | 340 | { | 205 | { |
1655 | 341 | using namespace testing; | 206 | using namespace testing; |
1656 | 342 | 207 | ||
1658 | 343 | UnityScreenDBusClient other_client{bus.address()}; | 208 | ut::UnityScreenDBusClient other_client{bus.address()}; |
1659 | 344 | 209 | ||
1660 | 345 | EXPECT_CALL(*mock_screen, keep_display_on(true)).Times(4); | 210 | EXPECT_CALL(*mock_screen, keep_display_on(true)).Times(4); |
1661 | 346 | EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0); | 211 | EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0); |
1662 | 347 | 212 | ||
1663 | === added file 'tests/integration-tests/test_unity_services.cpp' | |||
1664 | --- tests/integration-tests/test_unity_services.cpp 1970-01-01 00:00:00 +0000 | |||
1665 | +++ tests/integration-tests/test_unity_services.cpp 2016-01-21 17:48:37 +0000 | |||
1666 | @@ -0,0 +1,82 @@ | |||
1667 | 1 | /* | ||
1668 | 2 | * Copyright © 2016 Canonical Ltd. | ||
1669 | 3 | * | ||
1670 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1671 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1672 | 6 | * published by the Free Software Foundation. | ||
1673 | 7 | * | ||
1674 | 8 | * This program is distributed in the hope that it will be useful, | ||
1675 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1676 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1677 | 11 | * GNU General Public License for more details. | ||
1678 | 12 | * | ||
1679 | 13 | * You should have received a copy of the GNU General Public License | ||
1680 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1681 | 15 | * | ||
1682 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1683 | 17 | */ | ||
1684 | 18 | #include "src/unity_input_service.h" | ||
1685 | 19 | #include "src/dbus_connection_handle.h" | ||
1686 | 20 | #include "src/dbus_connection_thread.h" | ||
1687 | 21 | #include "src/dbus_event_loop.h" | ||
1688 | 22 | #include "src/dbus_message_handle.h" | ||
1689 | 23 | #include "src/unity_screen_service.h" | ||
1690 | 24 | #include "src/unity_input_service_introspection.h" | ||
1691 | 25 | #include "src/unity_screen_service_introspection.h" | ||
1692 | 26 | |||
1693 | 27 | #include "wait_condition.h" | ||
1694 | 28 | #include "dbus_bus.h" | ||
1695 | 29 | #include "dbus_client.h" | ||
1696 | 30 | #include "unity_input_dbus_client.h" | ||
1697 | 31 | #include "unity_screen_dbus_client.h" | ||
1698 | 32 | |||
1699 | 33 | #include "usc/test/mock_input_configuration.h" | ||
1700 | 34 | #include "usc/test/mock_screen.h" | ||
1701 | 35 | |||
1702 | 36 | namespace ut = usc::test; | ||
1703 | 37 | using namespace testing; | ||
1704 | 38 | |||
1705 | 39 | namespace | ||
1706 | 40 | { | ||
1707 | 41 | |||
1708 | 42 | struct UnityServices : testing::Test | ||
1709 | 43 | { | ||
1710 | 44 | std::chrono::seconds const default_timeout{3}; | ||
1711 | 45 | ut::DBusBus bus; | ||
1712 | 46 | |||
1713 | 47 | ut::UnityScreenDBusClient screen_client{bus.address()}; | ||
1714 | 48 | ut::UnityInputDBusClient input_client{bus.address()}; | ||
1715 | 49 | std::shared_ptr<ut::MockScreen> const mock_screen = | ||
1716 | 50 | std::make_shared<testing::NiceMock<ut::MockScreen>>(); | ||
1717 | 51 | std::shared_ptr<ut::MockInputConfiguration> const mock_input_configuration = | ||
1718 | 52 | std::make_shared<testing::NiceMock<ut::MockInputConfiguration>>(); | ||
1719 | 53 | std::shared_ptr<usc::DBusEventLoop> const dbus_loop= | ||
1720 | 54 | std::make_shared<usc::DBusEventLoop>(); | ||
1721 | 55 | usc::UnityScreenService screen_service{dbus_loop, bus.address(), mock_screen}; | ||
1722 | 56 | usc::UnityInputService input_service{dbus_loop, bus.address(), mock_input_configuration}; | ||
1723 | 57 | std::shared_ptr<usc::DBusConnectionThread> const dbus_thread = | ||
1724 | 58 | std::make_shared<usc::DBusConnectionThread>(dbus_loop); | ||
1725 | 59 | }; | ||
1726 | 60 | |||
1727 | 61 | } | ||
1728 | 62 | |||
1729 | 63 | TEST_F(UnityServices, offer_screen_introspection) | ||
1730 | 64 | { | ||
1731 | 65 | auto reply = screen_client.request_introspection(); | ||
1732 | 66 | EXPECT_THAT(reply.get(), Eq(unity_screen_service_introspection)); | ||
1733 | 67 | } | ||
1734 | 68 | |||
1735 | 69 | TEST_F(UnityServices, offer_input_introspection) | ||
1736 | 70 | { | ||
1737 | 71 | auto reply = input_client.request_introspection(); | ||
1738 | 72 | EXPECT_THAT(reply.get(), Eq(unity_input_service_introspection)); | ||
1739 | 73 | } | ||
1740 | 74 | |||
1741 | 75 | TEST_F(UnityServices, provides_access_to_input_methods) | ||
1742 | 76 | { | ||
1743 | 77 | double const speed = 8.0; | ||
1744 | 78 | |||
1745 | 79 | EXPECT_CALL(*mock_input_configuration, set_mouse_scroll_speed(speed)); | ||
1746 | 80 | |||
1747 | 81 | input_client.request_set_mouse_scroll_speed(speed); | ||
1748 | 82 | } | ||
1749 | 0 | 83 | ||
1750 | === added file 'tests/integration-tests/unity_input_dbus_client.cpp' | |||
1751 | --- tests/integration-tests/unity_input_dbus_client.cpp 1970-01-01 00:00:00 +0000 | |||
1752 | +++ tests/integration-tests/unity_input_dbus_client.cpp 2016-01-21 17:48:37 +0000 | |||
1753 | @@ -0,0 +1,113 @@ | |||
1754 | 1 | /* | ||
1755 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1756 | 3 | * | ||
1757 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1758 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1759 | 6 | * published by the Free Software Foundation. | ||
1760 | 7 | * | ||
1761 | 8 | * This program is distributed in the hope that it will be useful, | ||
1762 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1763 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1764 | 11 | * GNU General Public License for more details. | ||
1765 | 12 | * | ||
1766 | 13 | * You should have received a copy of the GNU General Public License | ||
1767 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1768 | 15 | * | ||
1769 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1770 | 17 | */ | ||
1771 | 18 | |||
1772 | 19 | #include "unity_input_dbus_client.h" | ||
1773 | 20 | |||
1774 | 21 | namespace ut = usc::test; | ||
1775 | 22 | |||
1776 | 23 | ut::UnityInputDBusClient::UnityInputDBusClient(std::string const& address) | ||
1777 | 24 | : ut::DBusClient{ | ||
1778 | 25 | address, | ||
1779 | 26 | "com.canonical.Unity.Input", | ||
1780 | 27 | "/com/canonical/Unity/Input"} | ||
1781 | 28 | { | ||
1782 | 29 | } | ||
1783 | 30 | |||
1784 | 31 | ut::DBusAsyncReplyString ut::UnityInputDBusClient::request_introspection() | ||
1785 | 32 | { | ||
1786 | 33 | return invoke_with_reply<ut::DBusAsyncReplyString>( | ||
1787 | 34 | "org.freedesktop.DBus.Introspectable", "Introspect", | ||
1788 | 35 | DBUS_TYPE_INVALID); | ||
1789 | 36 | } | ||
1790 | 37 | |||
1791 | 38 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, int32_t value) | ||
1792 | 39 | { | ||
1793 | 40 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1794 | 41 | unity_input_interface, requestName, | ||
1795 | 42 | DBUS_TYPE_INT32, &value, | ||
1796 | 43 | DBUS_TYPE_INVALID); | ||
1797 | 44 | } | ||
1798 | 45 | |||
1799 | 46 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_primary_button(int32_t button) | ||
1800 | 47 | { | ||
1801 | 48 | return request("setMousePrimaryButton", button); | ||
1802 | 49 | } | ||
1803 | 50 | |||
1804 | 51 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_primary_button(int32_t button) | ||
1805 | 52 | { | ||
1806 | 53 | return request("setTouchpadPrimaryButton", button); | ||
1807 | 54 | } | ||
1808 | 55 | |||
1809 | 56 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, double value) | ||
1810 | 57 | { | ||
1811 | 58 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1812 | 59 | unity_input_interface, requestName, | ||
1813 | 60 | DBUS_TYPE_DOUBLE, &value, | ||
1814 | 61 | DBUS_TYPE_INVALID); | ||
1815 | 62 | } | ||
1816 | 63 | |||
1817 | 64 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_cursor_speed(double speed) | ||
1818 | 65 | { | ||
1819 | 66 | return request("setMouseCursorSpeed", speed); | ||
1820 | 67 | } | ||
1821 | 68 | |||
1822 | 69 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_mouse_scroll_speed(double speed) | ||
1823 | 70 | { | ||
1824 | 71 | return request("setMouseScrollSpeed", speed); | ||
1825 | 72 | } | ||
1826 | 73 | |||
1827 | 74 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_cursor_speed(double speed) | ||
1828 | 75 | { | ||
1829 | 76 | return request("setTouchpadCursorSpeed", speed); | ||
1830 | 77 | } | ||
1831 | 78 | |||
1832 | 79 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_scroll_speed(double speed) | ||
1833 | 80 | { | ||
1834 | 81 | return request("setTouchpadScrollSpeed", speed); | ||
1835 | 82 | } | ||
1836 | 83 | |||
1837 | 84 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request(char const* requestName, bool value) | ||
1838 | 85 | { | ||
1839 | 86 | dbus_bool_t copied = value; | ||
1840 | 87 | return invoke_with_reply<ut::DBusAsyncReplyVoid>( | ||
1841 | 88 | unity_input_interface, requestName, | ||
1842 | 89 | DBUS_TYPE_BOOLEAN, &copied, | ||
1843 | 90 | DBUS_TYPE_INVALID); | ||
1844 | 91 | } | ||
1845 | 92 | |||
1846 | 93 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_two_finger_scroll(bool enabled) | ||
1847 | 94 | { | ||
1848 | 95 | return request("setTouchpadTwoFingerScroll", enabled); | ||
1849 | 96 | } | ||
1850 | 97 | |||
1851 | 98 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_tap_to_click(bool enabled) | ||
1852 | 99 | { | ||
1853 | 100 | return request("setTouchpadTapToClick", enabled); | ||
1854 | 101 | } | ||
1855 | 102 | |||
1856 | 103 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_disable_with_mouse(bool enabled) | ||
1857 | 104 | { | ||
1858 | 105 | return request("setTouchpadDisableWithMouse", enabled); | ||
1859 | 106 | } | ||
1860 | 107 | |||
1861 | 108 | ut::DBusAsyncReplyVoid ut::UnityInputDBusClient::request_set_touchpad_disable_while_typing(bool enabled) | ||
1862 | 109 | { | ||
1863 | 110 | return request("setTouchpadDisableWhileTyping", enabled); | ||
1864 | 111 | } | ||
1865 | 112 | |||
1866 | 113 | |||
1867 | 0 | 114 | ||
1868 | === added file 'tests/integration-tests/unity_input_dbus_client.h' | |||
1869 | --- tests/integration-tests/unity_input_dbus_client.h 1970-01-01 00:00:00 +0000 | |||
1870 | +++ tests/integration-tests/unity_input_dbus_client.h 2016-01-21 17:48:37 +0000 | |||
1871 | @@ -0,0 +1,52 @@ | |||
1872 | 1 | /* | ||
1873 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1874 | 3 | * | ||
1875 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1876 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1877 | 6 | * published by the Free Software Foundation. | ||
1878 | 7 | * | ||
1879 | 8 | * This program is distributed in the hope that it will be useful, | ||
1880 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1881 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1882 | 11 | * GNU General Public License for more details. | ||
1883 | 12 | * | ||
1884 | 13 | * You should have received a copy of the GNU General Public License | ||
1885 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1886 | 15 | * | ||
1887 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1888 | 17 | */ | ||
1889 | 18 | |||
1890 | 19 | #ifndef USC_TEST_UNITY_INPUT_DBUS_CLIENT_H_ | ||
1891 | 20 | #define USC_TEST_UNITY_INPUT_DBUS_CLIENT_H_ | ||
1892 | 21 | |||
1893 | 22 | #include "dbus_client.h" | ||
1894 | 23 | |||
1895 | 24 | namespace usc | ||
1896 | 25 | { | ||
1897 | 26 | namespace test | ||
1898 | 27 | { | ||
1899 | 28 | class UnityInputDBusClient : public DBusClient | ||
1900 | 29 | { | ||
1901 | 30 | public: | ||
1902 | 31 | UnityInputDBusClient(std::string const& address); | ||
1903 | 32 | DBusAsyncReplyString request_introspection(); | ||
1904 | 33 | DBusAsyncReplyVoid request(char const* requestName, int32_t value); | ||
1905 | 34 | DBusAsyncReplyVoid request_set_mouse_primary_button(int32_t button); | ||
1906 | 35 | DBusAsyncReplyVoid request_set_touchpad_primary_button(int32_t button); | ||
1907 | 36 | DBusAsyncReplyVoid request(char const* requestName, double value); | ||
1908 | 37 | DBusAsyncReplyVoid request_set_mouse_cursor_speed(double speed); | ||
1909 | 38 | DBusAsyncReplyVoid request_set_mouse_scroll_speed(double speed); | ||
1910 | 39 | DBusAsyncReplyVoid request_set_touchpad_cursor_speed(double speed); | ||
1911 | 40 | DBusAsyncReplyVoid request_set_touchpad_scroll_speed(double speed); | ||
1912 | 41 | DBusAsyncReplyVoid request(char const* requestName, bool value); | ||
1913 | 42 | DBusAsyncReplyVoid request_set_touchpad_two_finger_scroll(bool enabled); | ||
1914 | 43 | DBusAsyncReplyVoid request_set_touchpad_tap_to_click(bool enabled); | ||
1915 | 44 | DBusAsyncReplyVoid request_set_touchpad_disable_with_mouse(bool enabled); | ||
1916 | 45 | DBusAsyncReplyVoid request_set_touchpad_disable_while_typing(bool enabled); | ||
1917 | 46 | char const* const unity_input_interface = "com.canonical.Unity.Input"; | ||
1918 | 47 | }; | ||
1919 | 48 | |||
1920 | 49 | } | ||
1921 | 50 | } | ||
1922 | 51 | |||
1923 | 52 | #endif | ||
1924 | 0 | 53 | ||
1925 | === added file 'tests/integration-tests/unity_screen_dbus_client.cpp' | |||
1926 | --- tests/integration-tests/unity_screen_dbus_client.cpp 1970-01-01 00:00:00 +0000 | |||
1927 | +++ tests/integration-tests/unity_screen_dbus_client.cpp 2016-01-21 17:48:37 +0000 | |||
1928 | @@ -0,0 +1,112 @@ | |||
1929 | 1 | /* | ||
1930 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1931 | 3 | * | ||
1932 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1933 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1934 | 6 | * published by the Free Software Foundation. | ||
1935 | 7 | * | ||
1936 | 8 | * This program is distributed in the hope that it will be useful, | ||
1937 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1938 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1939 | 11 | * GNU General Public License for more details. | ||
1940 | 12 | * | ||
1941 | 13 | * You should have received a copy of the GNU General Public License | ||
1942 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1943 | 15 | * | ||
1944 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
1945 | 17 | */ | ||
1946 | 18 | |||
1947 | 19 | #include "unity_screen_dbus_client.h" | ||
1948 | 20 | #include "src/dbus_message_handle.h" | ||
1949 | 21 | |||
1950 | 22 | namespace ut = usc::test; | ||
1951 | 23 | |||
1952 | 24 | ut::UnityScreenDBusClient::UnityScreenDBusClient(std::string const& address) | ||
1953 | 25 | : ut::DBusClient{ | ||
1954 | 26 | address, | ||
1955 | 27 | "com.canonical.Unity.Screen", | ||
1956 | 28 | "/com/canonical/Unity/Screen"} | ||
1957 | 29 | { | ||
1958 | 30 | connection.add_match( | ||
1959 | 31 | "type='signal'," | ||
1960 | 32 | "interface='com.canonical.Unity.Screen'," | ||
1961 | 33 | "member='DisplayPowerStateChange'"); | ||
1962 | 34 | } | ||
1963 | 35 | |||
1964 | 36 | ut::DBusAsyncReplyString ut::UnityScreenDBusClient::request_introspection() | ||
1965 | 37 | { | ||
1966 | 38 | return invoke_with_reply<ut::DBusAsyncReplyString>("org.freedesktop.DBus.Introspectable", "Introspect", | ||
1967 | 39 | DBUS_TYPE_INVALID); | ||
1968 | 40 | } | ||
1969 | 41 | |||
1970 | 42 | ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_user_brightness(int32_t brightness) | ||
1971 | 43 | { | ||
1972 | 44 | return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setUserBrightness", DBUS_TYPE_INT32, | ||
1973 | 45 | &brightness, DBUS_TYPE_INVALID); | ||
1974 | 46 | } | ||
1975 | 47 | |||
1976 | 48 | ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_user_auto_brightness_enable(bool enabled) | ||
1977 | 49 | { | ||
1978 | 50 | dbus_bool_t const e = enabled ? TRUE : FALSE; | ||
1979 | 51 | return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "userAutobrightnessEnable", | ||
1980 | 52 | DBUS_TYPE_BOOLEAN, &e, DBUS_TYPE_INVALID); | ||
1981 | 53 | } | ||
1982 | 54 | |||
1983 | 55 | ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_inactivity_timeouts(int32_t poweroff_timeout, | ||
1984 | 56 | int32_t dimmer_timeout) | ||
1985 | 57 | { | ||
1986 | 58 | return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setInactivityTimeouts", DBUS_TYPE_INT32, | ||
1987 | 59 | &poweroff_timeout, DBUS_TYPE_INT32, &dimmer_timeout, | ||
1988 | 60 | DBUS_TYPE_INVALID); | ||
1989 | 61 | } | ||
1990 | 62 | |||
1991 | 63 | ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_set_touch_visualization_enabled(bool enabled) | ||
1992 | 64 | { | ||
1993 | 65 | dbus_bool_t const e = enabled ? TRUE : FALSE; | ||
1994 | 66 | return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "setTouchVisualizationEnabled", | ||
1995 | 67 | DBUS_TYPE_BOOLEAN, &e, DBUS_TYPE_INVALID); | ||
1996 | 68 | } | ||
1997 | 69 | |||
1998 | 70 | ut::DBusAsyncReplyBool ut::UnityScreenDBusClient::request_set_screen_power_mode(std::string const& mode, int reason) | ||
1999 | 71 | { | ||
2000 | 72 | auto mode_cstr = mode.c_str(); | ||
2001 | 73 | return invoke_with_reply<ut::DBusAsyncReplyBool>(unity_screen_interface, "setScreenPowerMode", DBUS_TYPE_STRING, | ||
2002 | 74 | &mode_cstr, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INVALID); | ||
2003 | 75 | } | ||
2004 | 76 | |||
2005 | 77 | ut::DBusAsyncReplyInt ut::UnityScreenDBusClient::request_keep_display_on() | ||
2006 | 78 | { | ||
2007 | 79 | return invoke_with_reply<ut::DBusAsyncReplyInt>(unity_screen_interface, "keepDisplayOn", DBUS_TYPE_INVALID); | ||
2008 | 80 | } | ||
2009 | 81 | |||
2010 | 82 | ut::DBusAsyncReplyVoid ut::UnityScreenDBusClient::request_remove_display_on_request(int id) | ||
2011 | 83 | { | ||
2012 | 84 | return invoke_with_reply<ut::DBusAsyncReplyVoid>(unity_screen_interface, "removeDisplayOnRequest", DBUS_TYPE_INT32, | ||
2013 | 85 | &id, DBUS_TYPE_INVALID); | ||
2014 | 86 | } | ||
2015 | 87 | |||
2016 | 88 | ut::DBusAsyncReply ut::UnityScreenDBusClient::request_invalid_method() | ||
2017 | 89 | { | ||
2018 | 90 | return invoke_with_reply<ut::DBusAsyncReply>(unity_screen_interface, "invalidMethod", DBUS_TYPE_INVALID); | ||
2019 | 91 | } | ||
2020 | 92 | |||
2021 | 93 | ut::DBusAsyncReply ut::UnityScreenDBusClient::request_method_with_invalid_arguments() | ||
2022 | 94 | { | ||
2023 | 95 | char const* const str = "abcd"; | ||
2024 | 96 | return invoke_with_reply<ut::DBusAsyncReply>(unity_screen_interface, "setUserBrightness", DBUS_TYPE_STRING, &str, | ||
2025 | 97 | DBUS_TYPE_INVALID); | ||
2026 | 98 | } | ||
2027 | 99 | |||
2028 | 100 | usc::DBusMessageHandle ut::UnityScreenDBusClient::listen_for_power_state_change_signal() | ||
2029 | 101 | { | ||
2030 | 102 | while (true) | ||
2031 | 103 | { | ||
2032 | 104 | dbus_connection_read_write(connection, 1); | ||
2033 | 105 | auto msg = usc::DBusMessageHandle{dbus_connection_pop_message(connection)}; | ||
2034 | 106 | |||
2035 | 107 | if (msg && dbus_message_is_signal(msg, "com.canonical.Unity.Screen", "DisplayPowerStateChange")) | ||
2036 | 108 | { | ||
2037 | 109 | return msg; | ||
2038 | 110 | } | ||
2039 | 111 | } | ||
2040 | 112 | } | ||
2041 | 0 | 113 | ||
2042 | === added file 'tests/integration-tests/unity_screen_dbus_client.h' | |||
2043 | --- tests/integration-tests/unity_screen_dbus_client.h 1970-01-01 00:00:00 +0000 | |||
2044 | +++ tests/integration-tests/unity_screen_dbus_client.h 2016-01-21 17:48:37 +0000 | |||
2045 | @@ -0,0 +1,54 @@ | |||
2046 | 1 | /* | ||
2047 | 2 | * Copyright © 2015 Canonical Ltd. | ||
2048 | 3 | * | ||
2049 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2050 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2051 | 6 | * published by the Free Software Foundation. | ||
2052 | 7 | * | ||
2053 | 8 | * This program is distributed in the hope that it will be useful, | ||
2054 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2055 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2056 | 11 | * GNU General Public License for more details. | ||
2057 | 12 | * | ||
2058 | 13 | * You should have received a copy of the GNU General Public License | ||
2059 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2060 | 15 | * | ||
2061 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
2062 | 17 | */ | ||
2063 | 18 | |||
2064 | 19 | #ifndef USC_TEST_UNITY_SCREEN_DBUS_CLIENT_H_ | ||
2065 | 20 | #define USC_TEST_UNITY_SCREEN_DBUS_CLIENT_H_ | ||
2066 | 21 | |||
2067 | 22 | #include "dbus_client.h" | ||
2068 | 23 | |||
2069 | 24 | namespace usc | ||
2070 | 25 | { | ||
2071 | 26 | namespace test | ||
2072 | 27 | { | ||
2073 | 28 | |||
2074 | 29 | class UnityScreenDBusClient : public DBusClient | ||
2075 | 30 | { | ||
2076 | 31 | public: | ||
2077 | 32 | UnityScreenDBusClient(std::string const& address); | ||
2078 | 33 | |||
2079 | 34 | DBusAsyncReplyString request_introspection(); | ||
2080 | 35 | DBusAsyncReplyVoid request_set_user_brightness(int32_t brightness); | ||
2081 | 36 | DBusAsyncReplyVoid request_user_auto_brightness_enable(bool enabled); | ||
2082 | 37 | DBusAsyncReplyVoid request_set_inactivity_timeouts( | ||
2083 | 38 | int32_t poweroff_timeout, int32_t dimmer_timeout); | ||
2084 | 39 | DBusAsyncReplyVoid request_set_touch_visualization_enabled(bool enabled); | ||
2085 | 40 | DBusAsyncReplyBool request_set_screen_power_mode( | ||
2086 | 41 | std::string const& mode, int reason); | ||
2087 | 42 | |||
2088 | 43 | DBusAsyncReplyInt request_keep_display_on(); | ||
2089 | 44 | DBusAsyncReplyVoid request_remove_display_on_request(int id); | ||
2090 | 45 | DBusAsyncReply request_invalid_method(); | ||
2091 | 46 | DBusAsyncReply request_method_with_invalid_arguments(); | ||
2092 | 47 | usc::DBusMessageHandle listen_for_power_state_change_signal(); | ||
2093 | 48 | char const* const unity_screen_interface = "com.canonical.Unity.Screen"; | ||
2094 | 49 | }; | ||
2095 | 50 | |||
2096 | 51 | } | ||
2097 | 52 | } | ||
2098 | 53 | |||
2099 | 54 | #endif | ||
2100 | 0 | 55 | ||
2101 | === modified file 'tests/unit-tests/CMakeLists.txt' | |||
2102 | --- tests/unit-tests/CMakeLists.txt 2015-02-18 14:40:29 +0000 | |||
2103 | +++ tests/unit-tests/CMakeLists.txt 2016-01-21 17:48:37 +0000 | |||
2104 | @@ -25,6 +25,7 @@ | |||
2105 | 25 | test_session_switcher.cpp | 25 | test_session_switcher.cpp |
2106 | 26 | test_screen_event_handler.cpp | 26 | test_screen_event_handler.cpp |
2107 | 27 | test_mir_screen.cpp | 27 | test_mir_screen.cpp |
2108 | 28 | test_mir_input_configuration.cpp | ||
2109 | 28 | 29 | ||
2110 | 29 | advanceable_timer.cpp | 30 | advanceable_timer.cpp |
2111 | 30 | ) | 31 | ) |
2112 | 31 | 32 | ||
2113 | === added file 'tests/unit-tests/test_mir_input_configuration.cpp' | |||
2114 | --- tests/unit-tests/test_mir_input_configuration.cpp 1970-01-01 00:00:00 +0000 | |||
2115 | +++ tests/unit-tests/test_mir_input_configuration.cpp 2016-01-21 17:48:37 +0000 | |||
2116 | @@ -0,0 +1,114 @@ | |||
2117 | 1 | /* | ||
2118 | 2 | * Copyright © 2015 Canonical Ltd. | ||
2119 | 3 | * | ||
2120 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2121 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2122 | 6 | * published by the Free Software Foundation. | ||
2123 | 7 | * | ||
2124 | 8 | * This program is distributed in the hope that it will be useful, | ||
2125 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2126 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2127 | 11 | * GNU General Public License for more details. | ||
2128 | 12 | * | ||
2129 | 13 | * You should have received a copy of the GNU General Public License | ||
2130 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2131 | 15 | * | ||
2132 | 16 | * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com> | ||
2133 | 17 | */ | ||
2134 | 18 | |||
2135 | 19 | |||
2136 | 20 | #include "src/mir_input_configuration.h" | ||
2137 | 21 | #include "mir/input/input_device_hub.h" | ||
2138 | 22 | #include "mir/input/device_capability.h" | ||
2139 | 23 | #include "mir/input/input_device_observer.h" | ||
2140 | 24 | #include "mir/input/device.h" | ||
2141 | 25 | |||
2142 | 26 | #include <gtest/gtest.h> | ||
2143 | 27 | #include <gmock/gmock.h> | ||
2144 | 28 | |||
2145 | 29 | namespace mi = mir::input; | ||
2146 | 30 | |||
2147 | 31 | using namespace ::testing; | ||
2148 | 32 | |||
2149 | 33 | namespace | ||
2150 | 34 | { | ||
2151 | 35 | struct MockDevice : mi::Device | ||
2152 | 36 | { | ||
2153 | 37 | MOCK_CONST_METHOD0(id, MirInputDeviceId()); | ||
2154 | 38 | MOCK_CONST_METHOD0(capabilities, mi::DeviceCapabilities()); | ||
2155 | 39 | MOCK_CONST_METHOD0(name, std::string()); | ||
2156 | 40 | MOCK_CONST_METHOD0(unique_id, std::string()); | ||
2157 | 41 | MOCK_CONST_METHOD0(pointer_configuration, mir::optional_value<mi::PointerConfiguration>()); | ||
2158 | 42 | MOCK_METHOD1(apply_pointer_configuration, void(mi::PointerConfiguration const&)); | ||
2159 | 43 | MOCK_CONST_METHOD0(touchpad_configuration, mir::optional_value<mi::TouchpadConfiguration> ()); | ||
2160 | 44 | MOCK_METHOD1(apply_touchpad_configuration, void(mi::TouchpadConfiguration const&)); | ||
2161 | 45 | |||
2162 | 46 | MockDevice(mi::DeviceCapabilities caps) | ||
2163 | 47 | : caps(caps) | ||
2164 | 48 | { | ||
2165 | 49 | ON_CALL(*this, capabilities()).WillByDefault(Return(this->caps)); | ||
2166 | 50 | } | ||
2167 | 51 | |||
2168 | 52 | mi::DeviceCapabilities caps; | ||
2169 | 53 | }; | ||
2170 | 54 | |||
2171 | 55 | struct MockInputDeviceHub : mi::InputDeviceHub | ||
2172 | 56 | { | ||
2173 | 57 | MOCK_METHOD1(add_observer,void(std::shared_ptr<mi::InputDeviceObserver> const&)); | ||
2174 | 58 | MOCK_METHOD1(remove_observer,void(std::weak_ptr<mi::InputDeviceObserver> const&)); | ||
2175 | 59 | }; | ||
2176 | 60 | |||
2177 | 61 | struct MirInputConfiguration : ::testing::Test | ||
2178 | 62 | { | ||
2179 | 63 | template<typename T> | ||
2180 | 64 | using shared_mock = std::shared_ptr<::testing::NiceMock<T>>; | ||
2181 | 65 | shared_mock<MockInputDeviceHub> mock_hub{std::make_shared<::testing::NiceMock<MockInputDeviceHub>>()}; | ||
2182 | 66 | shared_mock<MockDevice> mock_mouse{ | ||
2183 | 67 | std::make_shared<::testing::NiceMock<MockDevice>>(mi::DeviceCapability::pointer)}; | ||
2184 | 68 | shared_mock<MockDevice> mock_touchpad{std::make_shared<::testing::NiceMock<MockDevice>>( | ||
2185 | 69 | mi::DeviceCapability::pointer | mi::DeviceCapability::touchpad)}; | ||
2186 | 70 | shared_mock<MockDevice> mock_keyboard{std::make_shared<::testing::NiceMock<MockDevice>>( | ||
2187 | 71 | mi::DeviceCapability::keyboard | mi::DeviceCapability::alpha_numeric)}; | ||
2188 | 72 | |||
2189 | 73 | std::shared_ptr<mi::InputDeviceObserver> obs; | ||
2190 | 74 | |||
2191 | 75 | MirInputConfiguration() | ||
2192 | 76 | { | ||
2193 | 77 | ON_CALL(*mock_hub, add_observer(_)).WillByDefault(SaveArg<0>(&obs)); | ||
2194 | 78 | } | ||
2195 | 79 | }; | ||
2196 | 80 | } | ||
2197 | 81 | |||
2198 | 82 | TEST_F(MirInputConfiguration, registers_something_as_device_observer) | ||
2199 | 83 | { | ||
2200 | 84 | EXPECT_CALL(*mock_hub, add_observer(_)); | ||
2201 | 85 | |||
2202 | 86 | usc::MirInputConfiguration config(mock_hub); | ||
2203 | 87 | } | ||
2204 | 88 | |||
2205 | 89 | TEST_F(MirInputConfiguration, configures_device_on_add) | ||
2206 | 90 | { | ||
2207 | 91 | usc::MirInputConfiguration config(mock_hub); | ||
2208 | 92 | |||
2209 | 93 | EXPECT_CALL(*mock_touchpad, apply_pointer_configuration(_)); | ||
2210 | 94 | EXPECT_CALL(*mock_touchpad, apply_touchpad_configuration(_)); | ||
2211 | 95 | obs->device_added(mock_touchpad); | ||
2212 | 96 | } | ||
2213 | 97 | |||
2214 | 98 | TEST_F(MirInputConfiguration, configures_mouse_on_add) | ||
2215 | 99 | { | ||
2216 | 100 | usc::MirInputConfiguration config(mock_hub); | ||
2217 | 101 | |||
2218 | 102 | EXPECT_CALL(*mock_mouse, apply_pointer_configuration(_)); | ||
2219 | 103 | obs->device_added(mock_mouse); | ||
2220 | 104 | } | ||
2221 | 105 | |||
2222 | 106 | TEST_F(MirInputConfiguration, ignores_keyboard_when_added) | ||
2223 | 107 | { | ||
2224 | 108 | usc::MirInputConfiguration config(mock_hub); | ||
2225 | 109 | |||
2226 | 110 | EXPECT_CALL(*mock_keyboard, apply_touchpad_configuration(_)).Times(0); | ||
2227 | 111 | EXPECT_CALL(*mock_keyboard, apply_pointer_configuration(_)).Times(0); | ||
2228 | 112 | obs->device_added(mock_keyboard); | ||
2229 | 113 | } | ||
2230 | 114 | |||
2231 | 0 | 115 | ||
2232 | === modified file 'tests/unit-tests/test_screen_event_handler.cpp' | |||
2233 | --- tests/unit-tests/test_screen_event_handler.cpp 2015-12-01 13:53:20 +0000 | |||
2234 | +++ tests/unit-tests/test_screen_event_handler.cpp 2016-01-21 17:48:37 +0000 | |||
2235 | @@ -203,23 +203,50 @@ | |||
2236 | 203 | touch_screen(); | 203 | touch_screen(); |
2237 | 204 | } | 204 | } |
2238 | 205 | 205 | ||
2241 | 206 | TEST_F(AScreenEventHandler, keeps_display_on_temporarily_on_pointer_event) | 206 | TEST_F(AScreenEventHandler, turns_on_screen_and_filters_first_pointer_event_when_screen_is_off) |
2242 | 207 | { | 207 | { |
2243 | 208 | mock_screen.mock_mode = MirPowerMode::mir_power_mode_off; | ||
2244 | 209 | EXPECT_CALL(mock_screen, | ||
2245 | 210 | set_screen_power_mode(MirPowerMode::mir_power_mode_on, | ||
2246 | 211 | PowerStateChangeReason::unknown)); | ||
2247 | 212 | |||
2248 | 213 | auto const event_filtered = screen_event_handler.handle(*pointer_event); | ||
2249 | 214 | EXPECT_TRUE(event_filtered); | ||
2250 | 215 | } | ||
2251 | 216 | |||
2252 | 217 | TEST_F(AScreenEventHandler, turns_on_screen_and_propagates_keys_when_screen_is_off) | ||
2253 | 218 | { | ||
2254 | 219 | mock_screen.mock_mode = MirPowerMode::mir_power_mode_off; | ||
2255 | 220 | EXPECT_CALL(mock_screen, | ||
2256 | 221 | set_screen_power_mode(MirPowerMode::mir_power_mode_on, | ||
2257 | 222 | PowerStateChangeReason::unknown)); | ||
2258 | 223 | |||
2259 | 224 | auto const event_filtered = screen_event_handler.handle(*another_key_down_event); | ||
2260 | 225 | EXPECT_FALSE(event_filtered); | ||
2261 | 226 | } | ||
2262 | 227 | |||
2263 | 228 | TEST_F(AScreenEventHandler, keeps_display_on_temporarily_for_pointer_event_when_screen_is_on) | ||
2264 | 229 | { | ||
2265 | 230 | mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; | ||
2266 | 208 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()); | 231 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()); |
2267 | 209 | 232 | ||
2268 | 210 | move_pointer(); | 233 | move_pointer(); |
2269 | 211 | } | 234 | } |
2270 | 212 | 235 | ||
2272 | 213 | TEST_F(AScreenEventHandler, keeps_display_on_temporarily_on_other_keys) | 236 | TEST_F(AScreenEventHandler, keeps_display_on_temporarily_key_event_when_screen_is_on) |
2273 | 214 | { | 237 | { |
2274 | 238 | mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; | ||
2275 | 215 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()); | 239 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()); |
2276 | 216 | 240 | ||
2277 | 217 | press_a_key(); | 241 | press_a_key(); |
2278 | 218 | } | 242 | } |
2279 | 219 | 243 | ||
2281 | 220 | TEST_F(AScreenEventHandler, does_not_keep_display_on_for_volume_keys) | 244 | TEST_F(AScreenEventHandler, does_not_affect_screen_state_for_volume_keys) |
2282 | 221 | { | 245 | { |
2283 | 246 | using namespace testing; | ||
2284 | 247 | |||
2285 | 222 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()).Times(0); | 248 | EXPECT_CALL(mock_screen, keep_display_on_temporarily()).Times(0); |
2286 | 249 | EXPECT_CALL(mock_screen, set_screen_power_mode(_,_)).Times(0); | ||
2287 | 223 | 250 | ||
2288 | 224 | press_volume_keys(); | 251 | press_volume_keys(); |
2289 | 225 | } | 252 | } |
2290 | @@ -255,10 +282,12 @@ | |||
2291 | 255 | release_power_key(); | 282 | release_power_key(); |
2292 | 256 | } | 283 | } |
2293 | 257 | 284 | ||
2295 | 258 | TEST_F(AScreenEventHandler, passes_through_all_handled_events) | 285 | TEST_F(AScreenEventHandler, passes_through_all_handled_events_when_screen_is_on) |
2296 | 259 | { | 286 | { |
2297 | 260 | using namespace testing; | 287 | using namespace testing; |
2298 | 261 | 288 | ||
2299 | 289 | mock_screen.mock_mode = MirPowerMode::mir_power_mode_on; | ||
2300 | 290 | |||
2301 | 262 | EXPECT_FALSE(screen_event_handler.handle(*power_key_down_event)); | 291 | EXPECT_FALSE(screen_event_handler.handle(*power_key_down_event)); |
2302 | 263 | EXPECT_FALSE(screen_event_handler.handle(*power_key_up_event)); | 292 | EXPECT_FALSE(screen_event_handler.handle(*power_key_up_event)); |
2303 | 264 | EXPECT_FALSE(screen_event_handler.handle(*touch_event)); | 293 | EXPECT_FALSE(screen_event_handler.handle(*touch_event)); |