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