Merge lp:~afrantzis/mir/vt-switching-1 into lp:~mir-team/mir/trunk
- vt-switching-1
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alexandros Frantzis | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 585 | ||||
Proposed branch: | lp:~afrantzis/mir/vt-switching-1 | ||||
Merge into: | lp:~mir-team/mir/trunk | ||||
Diff against target: |
1824 lines (+935/-65) 33 files modified
include/server/mir/graphics/display.h (+11/-0) include/test/mir_test_doubles/mock_display.h (+5/-0) include/test/mir_test_doubles/null_display.h (+7/-0) include/test/mir_test_doubles/null_virtual_terminal.h (+47/-0) src/server/display_server.cpp (+12/-0) src/server/graphics/android/android_display.cpp (+15/-0) src/server/graphics/android/android_display.h (+8/-0) src/server/graphics/gbm/CMakeLists.txt (+1/-0) src/server/graphics/gbm/gbm_display.cpp (+31/-3) src/server/graphics/gbm/gbm_display.h (+12/-2) src/server/graphics/gbm/gbm_display_buffer.cpp (+17/-2) src/server/graphics/gbm/gbm_display_buffer.h (+4/-0) src/server/graphics/gbm/gbm_display_helpers.cpp (+40/-0) src/server/graphics/gbm/gbm_display_helpers.h (+3/-0) src/server/graphics/gbm/gbm_platform.cpp (+9/-4) src/server/graphics/gbm/gbm_platform.h (+7/-2) src/server/graphics/gbm/linux_virtual_terminal.cpp (+180/-0) src/server/graphics/gbm/linux_virtual_terminal.h (+67/-0) src/server/graphics/gbm/virtual_terminal.h (+55/-0) tests/behavior-tests/session_management_context.cpp (+9/-0) tests/integration-tests/test_display_server_main_loop_events.cpp (+178/-0) tests/integration-tests/test_surfaceloop.cpp (+7/-0) tests/mir_test_framework/testing_server_options.cpp (+7/-0) tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+7/-0) tests/unit-tests/graphics/gbm/mock_drm.cpp (+10/-0) tests/unit-tests/graphics/gbm/mock_drm.h (+3/-0) tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp (+4/-1) tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp (+3/-1) tests/unit-tests/graphics/gbm/test_gbm_display.cpp (+117/-31) tests/unit-tests/graphics/gbm/test_gbm_display_configuration.cpp (+13/-6) tests/unit-tests/graphics/gbm/test_gbm_display_multi_monitor.cpp (+12/-5) tests/unit-tests/graphics/gbm/test_gbm_platform.cpp (+18/-5) tests/unit-tests/graphics/test_graphics_platform.cpp (+16/-3) |
||||
To merge this branch: | bzr merge lp:~afrantzis/mir/vt-switching-1 | ||||
Related bugs: |
|
||||
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Daniel van Vugt | Abstain | ||
Robert Carr (community) | Approve | ||
Kevin DuBois (community) | Approve | ||
Robert Ancell | Pending | ||
Review via email: mp+158327@code.launchpad.net |
This proposal supersedes a proposal from 2013-04-10.
Commit message
server,gbm: Support VT switching
Since VT switching is a desktop specific concept at the moment, this branch
introduces it in more generic terms, as pause/resume in the high level
interfaces. Note that the mechanisms that implement pausing/resuming are
not tied to VT switching in particular. We can reuse them to pause/resume
arbitrarily.
In order for VT switching (pause/resume) to work properly, mir needs to be
run with root privileges, since this is required for drm{Drop,
However, if no VT switch (pause/resume) is performed, mir can be happily
run without root priveleges (as before, assuming appropriate device
permissions).
Description of the change
server,gbm: Support VT switching
Since VT switching is a desktop specific concept, this branch introduces it in more generic terms, as pause/resume in the high level interfaces. Note that the mechanisms that implement pausing/resuming are not tied to VT switching in particular. We can reuse them to pause/resume arbitrarily.
In order for VT switching (pause/resume) to work properly, mir needs to be run with root privileges, since this is required for drm{Drop,
There is a bit of code churn in this branch because of the interface changes in mg::Display and mg::Platform, that caused a barrage of amendments to related stub and mock classes.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal | # |
Around + display->pause();
Do we need to pause input?
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> Around + display->pause();
>
> Do we need to pause input?
Good question, we probably do, but I am not familiar with input details and how moving to another VT affects input. I guess from the perspective of pause/resume, it makes sense to stop processing/sending input events anyway when paused.
In any case, I'd rather leave it out of this MP (and let you implement it in an upcoming MP as needed ;))
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
The concepts of pause/resume (although not coded to do anything in android) are useful for what we'll want to do when the display is turned off on android, so I like the general idea
I kept thinking the pause/resume for the platform and the display could be consilidated, however I think its ok as it is
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal | # |
> I kept thinking the pause/resume for the platform and the display could be
> consilidated, however I think its ok as it is
This is doable, although less explicit, but on second thought I prefer it this way too.
We can also move register_
Robert Ancell (robert-ancell) : Posted in a previous version of this proposal | # |
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Text conflict in include/
Text conflict in src/server/
Text conflict in src/server/
Text conflict in src/server/
Text conflict in tests/integrati
Text conflict in tests/integrati
Text conflict in tests/integrati
Text conflict in tests/integrati
Text conflict in tests/mir_
Text conflict in tests/unit-
Text conflict in tests/unit-
Text conflict in tests/unit-
Text conflict in tests/unit-
Text conflict in tests/unit-
14 conflicts encountered.
Alexandros Frantzis (afrantzis) wrote : | # |
> I kept thinking the pause/resume for the platform and the display could be consilidated
Fixed.
> Text conflict in include/
...
Fixed.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:584
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
okay, with the consolidated pause/resume, this looks good to me
Robert Carr (robertcarr) wrote : | # |
I like the changes to consolidate pause/resume on display...was going to ask about this :)
I think it lgtm to me as it stands!
I wonder if LinuxVirtualTer
Daniel van Vugt (vanvugt) wrote : | # |
I can't test this any more. Blocked by bug 1167828 for now.
Alexandros Frantzis (afrantzis) wrote : | # |
> I like the changes to consolidate pause/resume on display...was going to ask
> about this :)
>
> I think it lgtm to me as it stands!
>
> I wonder if LinuxVirtualTer
> it can be unit tested for interaction.
Yes, ideally it should. I considered adding an, e.g., FileOperations dependency on LinuxVirtualTer
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'include/server/mir/graphics/display.h' | |||
2 | --- include/server/mir/graphics/display.h 2013-03-13 04:54:15 +0000 | |||
3 | +++ include/server/mir/graphics/display.h 2013-04-11 11:00:30 +0000 | |||
4 | @@ -26,6 +26,9 @@ | |||
5 | 26 | 26 | ||
6 | 27 | namespace mir | 27 | namespace mir |
7 | 28 | { | 28 | { |
8 | 29 | |||
9 | 30 | class MainLoop; | ||
10 | 31 | |||
11 | 29 | namespace graphics | 32 | namespace graphics |
12 | 30 | { | 33 | { |
13 | 31 | 34 | ||
14 | @@ -40,6 +43,14 @@ | |||
15 | 40 | 43 | ||
16 | 41 | virtual std::shared_ptr<DisplayConfiguration> configuration() = 0; | 44 | virtual std::shared_ptr<DisplayConfiguration> configuration() = 0; |
17 | 42 | 45 | ||
18 | 46 | virtual void register_pause_resume_handlers( | ||
19 | 47 | MainLoop& main_loop, | ||
20 | 48 | std::function<void()> const& pause_handler, | ||
21 | 49 | std::function<void()> const& resume_handler) = 0; | ||
22 | 50 | |||
23 | 51 | virtual void pause() = 0; | ||
24 | 52 | virtual void resume() = 0; | ||
25 | 53 | |||
26 | 43 | protected: | 54 | protected: |
27 | 44 | Display() = default; | 55 | Display() = default; |
28 | 45 | ~Display() = default; | 56 | ~Display() = default; |
29 | 46 | 57 | ||
30 | === modified file 'include/test/mir_test_doubles/mock_display.h' | |||
31 | --- include/test/mir_test_doubles/mock_display.h 2013-03-13 04:54:15 +0000 | |||
32 | +++ include/test/mir_test_doubles/mock_display.h 2013-04-11 11:00:30 +0000 | |||
33 | @@ -35,6 +35,11 @@ | |||
34 | 35 | MOCK_CONST_METHOD0(view_area, geometry::Rectangle ()); | 35 | MOCK_CONST_METHOD0(view_area, geometry::Rectangle ()); |
35 | 36 | MOCK_METHOD1(for_each_display_buffer, void (std::function<void(graphics::DisplayBuffer&)> const&)); | 36 | MOCK_METHOD1(for_each_display_buffer, void (std::function<void(graphics::DisplayBuffer&)> const&)); |
36 | 37 | MOCK_METHOD0(configuration, std::shared_ptr<graphics::DisplayConfiguration>()); | 37 | MOCK_METHOD0(configuration, std::shared_ptr<graphics::DisplayConfiguration>()); |
37 | 38 | MOCK_METHOD3(register_pause_resume_handlers, void(MainLoop&, | ||
38 | 39 | std::function<void()> const&, | ||
39 | 40 | std::function<void()> const&)); | ||
40 | 41 | MOCK_METHOD0(pause, void()); | ||
41 | 42 | MOCK_METHOD0(resume, void()); | ||
42 | 38 | }; | 43 | }; |
43 | 39 | 44 | ||
44 | 40 | } | 45 | } |
45 | 41 | 46 | ||
46 | === modified file 'include/test/mir_test_doubles/null_display.h' | |||
47 | --- include/test/mir_test_doubles/null_display.h 2013-03-13 04:54:15 +0000 | |||
48 | +++ include/test/mir_test_doubles/null_display.h 2013-04-11 11:00:30 +0000 | |||
49 | @@ -42,6 +42,13 @@ | |||
50 | 42 | { | 42 | { |
51 | 43 | return std::shared_ptr<graphics::DisplayConfiguration>(); | 43 | return std::shared_ptr<graphics::DisplayConfiguration>(); |
52 | 44 | } | 44 | } |
53 | 45 | void register_pause_resume_handlers(MainLoop&, | ||
54 | 46 | std::function<void()> const&, | ||
55 | 47 | std::function<void()> const&) | ||
56 | 48 | { | ||
57 | 49 | } | ||
58 | 50 | void pause() {} | ||
59 | 51 | void resume() {} | ||
60 | 45 | }; | 52 | }; |
61 | 46 | 53 | ||
62 | 47 | } | 54 | } |
63 | 48 | 55 | ||
64 | === added file 'include/test/mir_test_doubles/null_virtual_terminal.h' | |||
65 | --- include/test/mir_test_doubles/null_virtual_terminal.h 1970-01-01 00:00:00 +0000 | |||
66 | +++ include/test/mir_test_doubles/null_virtual_terminal.h 2013-04-11 11:00:30 +0000 | |||
67 | @@ -0,0 +1,47 @@ | |||
68 | 1 | /* | ||
69 | 2 | * Copyright © 2013 Canonical Ltd. | ||
70 | 3 | * | ||
71 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
72 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
73 | 6 | * as published by the Free Software Foundation. | ||
74 | 7 | * | ||
75 | 8 | * This program is distributed in the hope that it will be useful, | ||
76 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
77 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
78 | 11 | * GNU General Public License for more details. | ||
79 | 12 | * | ||
80 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
81 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
82 | 15 | * | ||
83 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
84 | 17 | */ | ||
85 | 18 | |||
86 | 19 | #ifndef MIR_TEST_DOUBLES_NULL_VIRTUAL_TERMINAL_H_ | ||
87 | 20 | #define MIR_TEST_DOUBLES_NULL_VIRTUAL_TERMINAL_H_ | ||
88 | 21 | |||
89 | 22 | #include "src/server/graphics/gbm/virtual_terminal.h" | ||
90 | 23 | |||
91 | 24 | namespace mir | ||
92 | 25 | { | ||
93 | 26 | namespace test | ||
94 | 27 | { | ||
95 | 28 | namespace doubles | ||
96 | 29 | { | ||
97 | 30 | |||
98 | 31 | class NullVirtualTerminal : public graphics::gbm::VirtualTerminal | ||
99 | 32 | { | ||
100 | 33 | public: | ||
101 | 34 | void set_graphics_mode() {} | ||
102 | 35 | |||
103 | 36 | void register_switch_handlers(MainLoop&, | ||
104 | 37 | std::function<void()> const&, | ||
105 | 38 | std::function<void()> const&) | ||
106 | 39 | { | ||
107 | 40 | } | ||
108 | 41 | }; | ||
109 | 42 | |||
110 | 43 | } | ||
111 | 44 | } | ||
112 | 45 | } | ||
113 | 46 | |||
114 | 47 | #endif /* MIR_TEST_DOUBLES_NULL_VIRTUAL_TERMINAL_H_ */ | ||
115 | 0 | 48 | ||
116 | === modified file 'src/server/display_server.cpp' | |||
117 | --- src/server/display_server.cpp 2013-04-10 16:23:54 +0000 | |||
118 | +++ src/server/display_server.cpp 2013-04-11 11:00:30 +0000 | |||
119 | @@ -44,6 +44,18 @@ | |||
120 | 44 | input_manager{config.the_input_manager()}, | 44 | input_manager{config.the_input_manager()}, |
121 | 45 | main_loop{config.the_main_loop()} | 45 | main_loop{config.the_main_loop()} |
122 | 46 | { | 46 | { |
123 | 47 | display->register_pause_resume_handlers( | ||
124 | 48 | *main_loop, | ||
125 | 49 | [this] | ||
126 | 50 | { | ||
127 | 51 | compositor->stop(); | ||
128 | 52 | display->pause(); | ||
129 | 53 | }, | ||
130 | 54 | [this] | ||
131 | 55 | { | ||
132 | 56 | display->resume(); | ||
133 | 57 | compositor->start(); | ||
134 | 58 | }); | ||
135 | 47 | } | 59 | } |
136 | 48 | 60 | ||
137 | 49 | std::shared_ptr<mg::Display> display; | 61 | std::shared_ptr<mg::Display> display; |
138 | 50 | 62 | ||
139 | === modified file 'src/server/graphics/android/android_display.cpp' | |||
140 | --- src/server/graphics/android/android_display.cpp 2013-03-21 03:32:59 +0000 | |||
141 | +++ src/server/graphics/android/android_display.cpp 2013-04-11 11:00:30 +0000 | |||
142 | @@ -142,6 +142,21 @@ | |||
143 | 142 | return std::make_shared<NullDisplayConfiguration>(); | 142 | return std::make_shared<NullDisplayConfiguration>(); |
144 | 143 | } | 143 | } |
145 | 144 | 144 | ||
146 | 145 | void mga::AndroidDisplay::register_pause_resume_handlers( | ||
147 | 146 | MainLoop& /*main_loop*/, | ||
148 | 147 | std::function<void()> const& /*pause_handler*/, | ||
149 | 148 | std::function<void()> const& /*resume_handler*/) | ||
150 | 149 | { | ||
151 | 150 | } | ||
152 | 151 | |||
153 | 152 | void mga::AndroidDisplay::pause() | ||
154 | 153 | { | ||
155 | 154 | } | ||
156 | 155 | |||
157 | 156 | void mga::AndroidDisplay::resume() | ||
158 | 157 | { | ||
159 | 158 | } | ||
160 | 159 | |||
161 | 145 | void mga::AndroidDisplay::make_current() | 160 | void mga::AndroidDisplay::make_current() |
162 | 146 | { | 161 | { |
163 | 147 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) | 162 | if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) |
164 | 148 | 163 | ||
165 | === modified file 'src/server/graphics/android/android_display.h' | |||
166 | --- src/server/graphics/android/android_display.h 2013-03-22 18:33:51 +0000 | |||
167 | +++ src/server/graphics/android/android_display.h 2013-04-11 11:00:30 +0000 | |||
168 | @@ -50,6 +50,14 @@ | |||
169 | 50 | 50 | ||
170 | 51 | std::shared_ptr<DisplayConfiguration> configuration(); | 51 | std::shared_ptr<DisplayConfiguration> configuration(); |
171 | 52 | 52 | ||
172 | 53 | void register_pause_resume_handlers( | ||
173 | 54 | MainLoop& main_loop, | ||
174 | 55 | std::function<void()> const& pause_handler, | ||
175 | 56 | std::function<void()> const& resume_handler); | ||
176 | 57 | |||
177 | 58 | void pause(); | ||
178 | 59 | void resume(); | ||
179 | 60 | |||
180 | 53 | void make_current(); | 61 | void make_current(); |
181 | 54 | private: | 62 | private: |
182 | 55 | std::shared_ptr<AndroidFramebufferWindowQuery> native_window; | 63 | std::shared_ptr<AndroidFramebufferWindowQuery> native_window; |
183 | 56 | 64 | ||
184 | === modified file 'src/server/graphics/gbm/CMakeLists.txt' | |||
185 | --- src/server/graphics/gbm/CMakeLists.txt 2013-03-13 04:54:15 +0000 | |||
186 | +++ src/server/graphics/gbm/CMakeLists.txt 2013-04-11 11:00:30 +0000 | |||
187 | @@ -24,6 +24,7 @@ | |||
188 | 24 | kms_output.cpp | 24 | kms_output.cpp |
189 | 25 | kms_output_container.cpp | 25 | kms_output_container.cpp |
190 | 26 | kms_page_flipper.cpp | 26 | kms_page_flipper.cpp |
191 | 27 | linux_virtual_terminal.cpp | ||
192 | 27 | ) | 28 | ) |
193 | 28 | 29 | ||
194 | 29 | target_link_libraries( | 30 | target_link_libraries( |
195 | 30 | 31 | ||
196 | === modified file 'src/server/graphics/gbm/gbm_display.cpp' | |||
197 | --- src/server/graphics/gbm/gbm_display.cpp 2013-03-13 04:54:15 +0000 | |||
198 | +++ src/server/graphics/gbm/gbm_display.cpp 2013-04-11 11:00:30 +0000 | |||
199 | @@ -22,6 +22,7 @@ | |||
200 | 22 | #include "kms_display_configuration.h" | 22 | #include "kms_display_configuration.h" |
201 | 23 | #include "kms_output.h" | 23 | #include "kms_output.h" |
202 | 24 | #include "kms_page_flipper.h" | 24 | #include "kms_page_flipper.h" |
203 | 25 | #include "virtual_terminal.h" | ||
204 | 25 | 26 | ||
205 | 26 | #include "mir/geometry/rectangle.h" | 27 | #include "mir/geometry/rectangle.h" |
206 | 27 | 28 | ||
207 | @@ -36,6 +37,8 @@ | |||
208 | 36 | output_container{platform->drm.fd, | 37 | output_container{platform->drm.fd, |
209 | 37 | std::make_shared<KMSPageFlipper>(platform->drm.fd)} | 38 | std::make_shared<KMSPageFlipper>(platform->drm.fd)} |
210 | 38 | { | 39 | { |
211 | 40 | platform->vt->set_graphics_mode(); | ||
212 | 41 | |||
213 | 39 | shared_egl.setup(platform->gbm); | 42 | shared_egl.setup(platform->gbm); |
214 | 40 | 43 | ||
215 | 41 | configure(configuration()); | 44 | configure(configuration()); |
216 | @@ -43,6 +46,10 @@ | |||
217 | 43 | shared_egl.make_current(); | 46 | shared_egl.make_current(); |
218 | 44 | } | 47 | } |
219 | 45 | 48 | ||
220 | 49 | mgg::GBMDisplay::~GBMDisplay() | ||
221 | 50 | { | ||
222 | 51 | } | ||
223 | 52 | |||
224 | 46 | geom::Rectangle mgg::GBMDisplay::view_area() const | 53 | geom::Rectangle mgg::GBMDisplay::view_area() const |
225 | 47 | { | 54 | { |
226 | 48 | return display_buffers[0]->view_area(); | 55 | return display_buffers[0]->view_area(); |
227 | @@ -92,8 +99,29 @@ | |||
228 | 92 | max_size.height.as_uint32_t()); | 99 | max_size.height.as_uint32_t()); |
229 | 93 | 100 | ||
230 | 94 | /* Create a single DisplayBuffer that displays the surface on all the outputs */ | 101 | /* Create a single DisplayBuffer that displays the surface on all the outputs */ |
234 | 95 | std::unique_ptr<DisplayBuffer> db{new GBMDisplayBuffer{platform, listener, enabled_outputs, | 102 | std::unique_ptr<GBMDisplayBuffer> db{new GBMDisplayBuffer{platform, listener, enabled_outputs, |
235 | 96 | std::move(surface), max_size, | 103 | std::move(surface), max_size, |
236 | 97 | shared_egl.context()}}; | 104 | shared_egl.context()}}; |
237 | 98 | display_buffers.push_back(std::move(db)); | 105 | display_buffers.push_back(std::move(db)); |
238 | 99 | } | 106 | } |
239 | 107 | |||
240 | 108 | void mgg::GBMDisplay::register_pause_resume_handlers( | ||
241 | 109 | MainLoop& main_loop, | ||
242 | 110 | std::function<void()> const& pause_handler, | ||
243 | 111 | std::function<void()> const& resume_handler) | ||
244 | 112 | { | ||
245 | 113 | platform->vt->register_switch_handlers(main_loop, pause_handler, resume_handler); | ||
246 | 114 | } | ||
247 | 115 | |||
248 | 116 | void mgg::GBMDisplay::pause() | ||
249 | 117 | { | ||
250 | 118 | platform->drm.drop_master(); | ||
251 | 119 | } | ||
252 | 120 | |||
253 | 121 | void mgg::GBMDisplay::resume() | ||
254 | 122 | { | ||
255 | 123 | platform->drm.set_master(); | ||
256 | 124 | |||
257 | 125 | for (auto& db_ptr : display_buffers) | ||
258 | 126 | db_ptr->schedule_set_crtc(); | ||
259 | 127 | } | ||
260 | 100 | 128 | ||
261 | === modified file 'src/server/graphics/gbm/gbm_display.h' | |||
262 | --- src/server/graphics/gbm/gbm_display.h 2013-03-21 03:32:59 +0000 | |||
263 | +++ src/server/graphics/gbm/gbm_display.h 2013-04-11 11:00:30 +0000 | |||
264 | @@ -20,7 +20,6 @@ | |||
265 | 20 | #define MIR_GRAPHICS_GBM_GBM_DISPLAY_H_ | 20 | #define MIR_GRAPHICS_GBM_GBM_DISPLAY_H_ |
266 | 21 | 21 | ||
267 | 22 | #include "mir/graphics/display.h" | 22 | #include "mir/graphics/display.h" |
268 | 23 | #include "mir/graphics/display_buffer.h" | ||
269 | 24 | #include "kms_output_container.h" | 23 | #include "kms_output_container.h" |
270 | 25 | #include "gbm_display_helpers.h" | 24 | #include "gbm_display_helpers.h" |
271 | 26 | 25 | ||
272 | @@ -36,31 +35,42 @@ | |||
273 | 36 | { | 35 | { |
274 | 37 | 36 | ||
275 | 38 | class DisplayReport; | 37 | class DisplayReport; |
276 | 38 | class DisplayBuffer; | ||
277 | 39 | 39 | ||
278 | 40 | namespace gbm | 40 | namespace gbm |
279 | 41 | { | 41 | { |
280 | 42 | 42 | ||
281 | 43 | class GBMPlatform; | 43 | class GBMPlatform; |
282 | 44 | class KMSOutput; | 44 | class KMSOutput; |
283 | 45 | class GBMDisplayBuffer; | ||
284 | 45 | 46 | ||
285 | 46 | class GBMDisplay : public Display | 47 | class GBMDisplay : public Display |
286 | 47 | { | 48 | { |
287 | 48 | public: | 49 | public: |
288 | 49 | GBMDisplay(std::shared_ptr<GBMPlatform> const& platform, | 50 | GBMDisplay(std::shared_ptr<GBMPlatform> const& platform, |
289 | 50 | std::shared_ptr<DisplayReport> const& listener); | 51 | std::shared_ptr<DisplayReport> const& listener); |
290 | 52 | ~GBMDisplay(); | ||
291 | 51 | 53 | ||
292 | 52 | geometry::Rectangle view_area() const; | 54 | geometry::Rectangle view_area() const; |
293 | 53 | void for_each_display_buffer(std::function<void(DisplayBuffer&)> const& f); | 55 | void for_each_display_buffer(std::function<void(DisplayBuffer&)> const& f); |
294 | 54 | 56 | ||
295 | 55 | std::shared_ptr<DisplayConfiguration> configuration(); | 57 | std::shared_ptr<DisplayConfiguration> configuration(); |
296 | 56 | 58 | ||
297 | 59 | void register_pause_resume_handlers( | ||
298 | 60 | MainLoop& main_loop, | ||
299 | 61 | std::function<void()> const& pause_handler, | ||
300 | 62 | std::function<void()> const& resume_handler); | ||
301 | 63 | |||
302 | 64 | void pause(); | ||
303 | 65 | void resume(); | ||
304 | 66 | |||
305 | 57 | private: | 67 | private: |
306 | 58 | void configure(std::shared_ptr<DisplayConfiguration> const& conf); | 68 | void configure(std::shared_ptr<DisplayConfiguration> const& conf); |
307 | 59 | 69 | ||
308 | 60 | std::shared_ptr<GBMPlatform> const platform; | 70 | std::shared_ptr<GBMPlatform> const platform; |
309 | 61 | std::shared_ptr<DisplayReport> const listener; | 71 | std::shared_ptr<DisplayReport> const listener; |
310 | 62 | helpers::EGLHelper shared_egl; | 72 | helpers::EGLHelper shared_egl; |
312 | 63 | std::vector<std::unique_ptr<DisplayBuffer>> display_buffers; | 73 | std::vector<std::unique_ptr<GBMDisplayBuffer>> display_buffers; |
313 | 64 | KMSOutputContainer output_container; | 74 | KMSOutputContainer output_container; |
314 | 65 | }; | 75 | }; |
315 | 66 | 76 | ||
316 | 67 | 77 | ||
317 | === modified file 'src/server/graphics/gbm/gbm_display_buffer.cpp' | |||
318 | --- src/server/graphics/gbm/gbm_display_buffer.cpp 2013-03-21 03:32:59 +0000 | |||
319 | +++ src/server/graphics/gbm/gbm_display_buffer.cpp 2013-04-11 11:00:30 +0000 | |||
320 | @@ -105,7 +105,8 @@ | |||
321 | 105 | drm(platform->drm), | 105 | drm(platform->drm), |
322 | 106 | outputs(outputs), | 106 | outputs(outputs), |
323 | 107 | surface_gbm{std::move(surface_gbm_param)}, | 107 | surface_gbm{std::move(surface_gbm_param)}, |
325 | 108 | size(size) | 108 | size(size), |
326 | 109 | needs_set_crtc{false} | ||
327 | 109 | { | 110 | { |
328 | 110 | egl.setup(platform->gbm, surface_gbm.get(), shared_context); | 111 | egl.setup(platform->gbm, surface_gbm.get(), shared_context); |
329 | 111 | 112 | ||
330 | @@ -180,11 +181,20 @@ | |||
331 | 180 | * If the flip fails, release the buffer object to make it available | 181 | * If the flip fails, release the buffer object to make it available |
332 | 181 | * for future rendering. | 182 | * for future rendering. |
333 | 182 | */ | 183 | */ |
335 | 183 | if (!schedule_and_wait_for_page_flip(bufobj)) | 184 | if (!needs_set_crtc && !schedule_and_wait_for_page_flip(bufobj)) |
336 | 184 | { | 185 | { |
337 | 185 | bufobj->release(); | 186 | bufobj->release(); |
338 | 186 | return false; | 187 | return false; |
339 | 187 | } | 188 | } |
340 | 189 | else if (needs_set_crtc) | ||
341 | 190 | { | ||
342 | 191 | for (auto& output : outputs) | ||
343 | 192 | { | ||
344 | 193 | if (!output->set_crtc(bufobj->get_drm_fb_id())) | ||
345 | 194 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to set DRM crtc")); | ||
346 | 195 | } | ||
347 | 196 | needs_set_crtc = false; | ||
348 | 197 | } | ||
349 | 188 | 198 | ||
350 | 189 | /* | 199 | /* |
351 | 190 | * Release the last flipped buffer object (which is not displayed anymore) | 200 | * Release the last flipped buffer object (which is not displayed anymore) |
352 | @@ -265,3 +275,8 @@ | |||
353 | 265 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to make EGL surface current")); | 275 | BOOST_THROW_EXCEPTION(std::runtime_error("Failed to make EGL surface current")); |
354 | 266 | } | 276 | } |
355 | 267 | } | 277 | } |
356 | 278 | |||
357 | 279 | void mgg::GBMDisplayBuffer::schedule_set_crtc() | ||
358 | 280 | { | ||
359 | 281 | needs_set_crtc = true; | ||
360 | 282 | } | ||
361 | 268 | 283 | ||
362 | === modified file 'src/server/graphics/gbm/gbm_display_buffer.h' | |||
363 | --- src/server/graphics/gbm/gbm_display_buffer.h 2013-03-13 04:54:15 +0000 | |||
364 | +++ src/server/graphics/gbm/gbm_display_buffer.h 2013-04-11 11:00:30 +0000 | |||
365 | @@ -24,6 +24,7 @@ | |||
366 | 24 | 24 | ||
367 | 25 | #include <vector> | 25 | #include <vector> |
368 | 26 | #include <memory> | 26 | #include <memory> |
369 | 27 | #include <atomic> | ||
370 | 27 | 28 | ||
371 | 28 | namespace mir | 29 | namespace mir |
372 | 29 | { | 30 | { |
373 | @@ -55,6 +56,8 @@ | |||
374 | 55 | void clear(); | 56 | void clear(); |
375 | 56 | bool post_update(); | 57 | bool post_update(); |
376 | 57 | 58 | ||
377 | 59 | void schedule_set_crtc(); | ||
378 | 60 | |||
379 | 58 | private: | 61 | private: |
380 | 59 | BufferObject* get_front_buffer_object(); | 62 | BufferObject* get_front_buffer_object(); |
381 | 60 | bool schedule_and_wait_for_page_flip(BufferObject* bufobj); | 63 | bool schedule_and_wait_for_page_flip(BufferObject* bufobj); |
382 | @@ -68,6 +71,7 @@ | |||
383 | 68 | GBMSurfaceUPtr surface_gbm; | 71 | GBMSurfaceUPtr surface_gbm; |
384 | 69 | helpers::EGLHelper egl; | 72 | helpers::EGLHelper egl; |
385 | 70 | geometry::Size size; | 73 | geometry::Size size; |
386 | 74 | std::atomic<bool> needs_set_crtc; | ||
387 | 71 | }; | 75 | }; |
388 | 72 | 76 | ||
389 | 73 | } | 77 | } |
390 | 74 | 78 | ||
391 | === modified file 'src/server/graphics/gbm/gbm_display_helpers.cpp' | |||
392 | --- src/server/graphics/gbm/gbm_display_helpers.cpp 2013-03-13 04:54:15 +0000 | |||
393 | +++ src/server/graphics/gbm/gbm_display_helpers.cpp 2013-04-11 11:00:30 +0000 | |||
394 | @@ -96,6 +96,46 @@ | |||
395 | 96 | } | 96 | } |
396 | 97 | } | 97 | } |
397 | 98 | 98 | ||
398 | 99 | void mggh::DRMHelper::drop_master() const | ||
399 | 100 | { | ||
400 | 101 | /* We must have our own device fd first, so that it has become the DRM master */ | ||
401 | 102 | if (fd < 0) | ||
402 | 103 | { | ||
403 | 104 | BOOST_THROW_EXCEPTION( | ||
404 | 105 | std::runtime_error("Tried to drop DRM master without a DRM device")); | ||
405 | 106 | } | ||
406 | 107 | |||
407 | 108 | int ret = drmDropMaster(fd); | ||
408 | 109 | |||
409 | 110 | if (ret < 0) | ||
410 | 111 | { | ||
411 | 112 | BOOST_THROW_EXCEPTION( | ||
412 | 113 | boost::enable_error_info( | ||
413 | 114 | std::runtime_error("Failed to drop DRM master")) | ||
414 | 115 | << boost::errinfo_errno(ret)); | ||
415 | 116 | } | ||
416 | 117 | } | ||
417 | 118 | |||
418 | 119 | void mggh::DRMHelper::set_master() const | ||
419 | 120 | { | ||
420 | 121 | /* We must have our own device fd first, so that it has become the DRM master */ | ||
421 | 122 | if (fd < 0) | ||
422 | 123 | { | ||
423 | 124 | BOOST_THROW_EXCEPTION( | ||
424 | 125 | std::runtime_error("Tried to set DRM master without a DRM device")); | ||
425 | 126 | } | ||
426 | 127 | |||
427 | 128 | int ret = drmSetMaster(fd); | ||
428 | 129 | |||
429 | 130 | if (ret < 0) | ||
430 | 131 | { | ||
431 | 132 | BOOST_THROW_EXCEPTION( | ||
432 | 133 | boost::enable_error_info( | ||
433 | 134 | std::runtime_error("Failed to set DRM master")) | ||
434 | 135 | << boost::errinfo_errno(ret)); | ||
435 | 136 | } | ||
436 | 137 | } | ||
437 | 138 | |||
438 | 99 | int mggh::DRMHelper::open_drm_device() | 139 | int mggh::DRMHelper::open_drm_device() |
439 | 100 | { | 140 | { |
440 | 101 | static const char *drivers[] = { | 141 | static const char *drivers[] = { |
441 | 102 | 142 | ||
442 | === modified file 'src/server/graphics/gbm/gbm_display_helpers.h' | |||
443 | --- src/server/graphics/gbm/gbm_display_helpers.h 2013-03-21 03:32:59 +0000 | |||
444 | +++ src/server/graphics/gbm/gbm_display_helpers.h 2013-04-11 11:00:30 +0000 | |||
445 | @@ -57,6 +57,9 @@ | |||
446 | 57 | int get_authenticated_fd(); | 57 | int get_authenticated_fd(); |
447 | 58 | void auth_magic(drm_magic_t magic) const; | 58 | void auth_magic(drm_magic_t magic) const; |
448 | 59 | 59 | ||
449 | 60 | void drop_master() const; | ||
450 | 61 | void set_master() const; | ||
451 | 62 | |||
452 | 60 | int fd; | 63 | int fd; |
453 | 61 | 64 | ||
454 | 62 | private: | 65 | private: |
455 | 63 | 66 | ||
456 | === modified file 'src/server/graphics/gbm/gbm_platform.cpp' | |||
457 | --- src/server/graphics/gbm/gbm_platform.cpp 2013-04-09 18:00:48 +0000 | |||
458 | +++ src/server/graphics/gbm/gbm_platform.cpp 2013-04-11 11:00:30 +0000 | |||
459 | @@ -21,6 +21,7 @@ | |||
460 | 21 | #include <boost/throw_exception.hpp> | 21 | #include <boost/throw_exception.hpp> |
461 | 22 | #include "gbm_buffer_allocator.h" | 22 | #include "gbm_buffer_allocator.h" |
462 | 23 | #include "gbm_display.h" | 23 | #include "gbm_display.h" |
463 | 24 | #include "linux_virtual_terminal.h" | ||
464 | 24 | #include "mir/graphics/platform_ipc_package.h" | 25 | #include "mir/graphics/platform_ipc_package.h" |
465 | 25 | #include "mir/graphics/egl/mesa_native_display.h" | 26 | #include "mir/graphics/egl/mesa_native_display.h" |
466 | 26 | #include "mir/logging/logger.h" | 27 | #include "mir/logging/logger.h" |
467 | @@ -54,9 +55,11 @@ | |||
468 | 54 | 55 | ||
469 | 55 | } | 56 | } |
470 | 56 | 57 | ||
474 | 57 | mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener) : | 58 | mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener, |
475 | 58 | listener(listener), | 59 | std::shared_ptr<VirtualTerminal> const& vt) |
476 | 59 | native_display(0) | 60 | : listener(listener), |
477 | 61 | vt{vt}, | ||
478 | 62 | native_display(0) | ||
479 | 60 | { | 63 | { |
480 | 61 | drm.setup(); | 64 | drm.setup(); |
481 | 62 | gbm.setup(drm); | 65 | gbm.setup(drm); |
482 | @@ -97,5 +100,7 @@ | |||
483 | 97 | 100 | ||
484 | 98 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report) | 101 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report) |
485 | 99 | { | 102 | { |
487 | 100 | return std::make_shared<mgg::GBMPlatform>(report); | 103 | return std::make_shared<mgg::GBMPlatform>( |
488 | 104 | report, | ||
489 | 105 | std::make_shared<mgg::LinuxVirtualTerminal>()); | ||
490 | 101 | } | 106 | } |
491 | 102 | 107 | ||
492 | === modified file 'src/server/graphics/gbm/gbm_platform.h' | |||
493 | --- src/server/graphics/gbm/gbm_platform.h 2013-04-09 18:00:48 +0000 | |||
494 | +++ src/server/graphics/gbm/gbm_platform.h 2013-04-11 11:00:30 +0000 | |||
495 | @@ -32,12 +32,15 @@ | |||
496 | 32 | namespace gbm | 32 | namespace gbm |
497 | 33 | { | 33 | { |
498 | 34 | 34 | ||
499 | 35 | class VirtualTerminal; | ||
500 | 36 | |||
501 | 35 | class GBMPlatform : public Platform, | 37 | class GBMPlatform : public Platform, |
502 | 36 | public DRMAuthenticator, | 38 | public DRMAuthenticator, |
503 | 37 | public std::enable_shared_from_this<GBMPlatform> | 39 | public std::enable_shared_from_this<GBMPlatform> |
504 | 38 | { | 40 | { |
505 | 39 | public: | 41 | public: |
507 | 40 | explicit GBMPlatform(std::shared_ptr<DisplayReport> const& reporter); | 42 | explicit GBMPlatform(std::shared_ptr<DisplayReport> const& reporter, |
508 | 43 | std::shared_ptr<VirtualTerminal> const& vt); | ||
509 | 41 | 44 | ||
510 | 42 | /* From Platform */ | 45 | /* From Platform */ |
511 | 43 | std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( | 46 | std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( |
512 | @@ -53,7 +56,9 @@ | |||
513 | 53 | helpers::DRMHelper drm; | 56 | helpers::DRMHelper drm; |
514 | 54 | helpers::GBMHelper gbm; | 57 | helpers::GBMHelper gbm; |
515 | 55 | 58 | ||
517 | 56 | std::shared_ptr<DisplayReport> listener; | 59 | std::shared_ptr<DisplayReport> const listener; |
518 | 60 | std::shared_ptr<VirtualTerminal> const vt; | ||
519 | 61 | |||
520 | 57 | private: | 62 | private: |
521 | 58 | std::shared_ptr<MirMesaEGLNativeDisplay> native_display; | 63 | std::shared_ptr<MirMesaEGLNativeDisplay> native_display; |
522 | 59 | }; | 64 | }; |
523 | 60 | 65 | ||
524 | === added file 'src/server/graphics/gbm/linux_virtual_terminal.cpp' | |||
525 | --- src/server/graphics/gbm/linux_virtual_terminal.cpp 1970-01-01 00:00:00 +0000 | |||
526 | +++ src/server/graphics/gbm/linux_virtual_terminal.cpp 2013-04-11 11:00:30 +0000 | |||
527 | @@ -0,0 +1,180 @@ | |||
528 | 1 | /* | ||
529 | 2 | * Copyright © 2013 Canonical Ltd. | ||
530 | 3 | * | ||
531 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
532 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
533 | 6 | * as published by the Free Software Foundation. | ||
534 | 7 | * | ||
535 | 8 | * This program is distributed in the hope that it will be useful, | ||
536 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
537 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
538 | 11 | * GNU General Public License for more details. | ||
539 | 12 | * | ||
540 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
541 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
542 | 15 | * | ||
543 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
544 | 17 | */ | ||
545 | 18 | |||
546 | 19 | #include "linux_virtual_terminal.h" | ||
547 | 20 | #include "mir/main_loop.h" | ||
548 | 21 | |||
549 | 22 | #include <boost/throw_exception.hpp> | ||
550 | 23 | #include <boost/exception/errinfo_errno.hpp> | ||
551 | 24 | #include <boost/exception/errinfo_file_name.hpp> | ||
552 | 25 | |||
553 | 26 | #include <vector> | ||
554 | 27 | #include <string> | ||
555 | 28 | #include <sstream> | ||
556 | 29 | #include <stdexcept> | ||
557 | 30 | #include <csignal> | ||
558 | 31 | |||
559 | 32 | #include <fcntl.h> | ||
560 | 33 | #include <linux/vt.h> | ||
561 | 34 | #include <linux/kd.h> | ||
562 | 35 | #include <sys/ioctl.h> | ||
563 | 36 | |||
564 | 37 | namespace mgg = mir::graphics::gbm; | ||
565 | 38 | |||
566 | 39 | namespace | ||
567 | 40 | { | ||
568 | 41 | |||
569 | 42 | int find_active_vt_number() | ||
570 | 43 | { | ||
571 | 44 | static std::vector<std::string> const paths{"/dev/tty", "/dev/tty0"}; | ||
572 | 45 | int active_vt{-1}; | ||
573 | 46 | |||
574 | 47 | for (auto& p : paths) | ||
575 | 48 | { | ||
576 | 49 | auto fd = open(p.c_str(), O_RDONLY, 0); | ||
577 | 50 | if (fd < 0) | ||
578 | 51 | fd = open(p.c_str(), O_WRONLY, 0); | ||
579 | 52 | |||
580 | 53 | if (fd >= 0) | ||
581 | 54 | { | ||
582 | 55 | struct vt_stat vts; | ||
583 | 56 | auto status = ioctl(fd, VT_GETSTATE, &vts); | ||
584 | 57 | close(fd); | ||
585 | 58 | |||
586 | 59 | if (status >= 0) | ||
587 | 60 | { | ||
588 | 61 | active_vt = vts.v_active; | ||
589 | 62 | break; | ||
590 | 63 | } | ||
591 | 64 | } | ||
592 | 65 | } | ||
593 | 66 | |||
594 | 67 | if (active_vt < 0) | ||
595 | 68 | { | ||
596 | 69 | BOOST_THROW_EXCEPTION( | ||
597 | 70 | std::runtime_error("Failed to find the current VT")); | ||
598 | 71 | } | ||
599 | 72 | |||
600 | 73 | return active_vt; | ||
601 | 74 | } | ||
602 | 75 | |||
603 | 76 | int open_vt(int vt_number) | ||
604 | 77 | { | ||
605 | 78 | std::stringstream vt_path_stream; | ||
606 | 79 | vt_path_stream << "/dev/tty" << vt_number; | ||
607 | 80 | |||
608 | 81 | std::string const active_vt_path{vt_path_stream.str()}; | ||
609 | 82 | |||
610 | 83 | auto vt_fd = open(active_vt_path.c_str(), O_RDONLY | O_NDELAY, 0); | ||
611 | 84 | |||
612 | 85 | if (vt_fd < 0) | ||
613 | 86 | { | ||
614 | 87 | BOOST_THROW_EXCEPTION( | ||
615 | 88 | boost::enable_error_info( | ||
616 | 89 | std::runtime_error("Failed to open current VT")) | ||
617 | 90 | << boost::errinfo_file_name(active_vt_path) | ||
618 | 91 | << boost::errinfo_errno(errno)); | ||
619 | 92 | } | ||
620 | 93 | |||
621 | 94 | return vt_fd; | ||
622 | 95 | } | ||
623 | 96 | |||
624 | 97 | } | ||
625 | 98 | |||
626 | 99 | mgg::LinuxVirtualTerminal::LinuxVirtualTerminal() | ||
627 | 100 | : vt_fd{open_vt(find_active_vt_number())}, | ||
628 | 101 | prev_kd_mode{0}, | ||
629 | 102 | prev_vt_mode(), | ||
630 | 103 | active{true} | ||
631 | 104 | { | ||
632 | 105 | if (ioctl(vt_fd.fd(), KDGETMODE, &prev_kd_mode) < 0) | ||
633 | 106 | { | ||
634 | 107 | BOOST_THROW_EXCEPTION( | ||
635 | 108 | boost::enable_error_info( | ||
636 | 109 | std::runtime_error("Failed to get current VT mode")) | ||
637 | 110 | << boost::errinfo_errno(errno)); | ||
638 | 111 | } | ||
639 | 112 | |||
640 | 113 | if (ioctl(vt_fd.fd(), VT_GETMODE, &prev_vt_mode) < 0) | ||
641 | 114 | { | ||
642 | 115 | BOOST_THROW_EXCEPTION( | ||
643 | 116 | boost::enable_error_info( | ||
644 | 117 | std::runtime_error("Failed to get the current VT")) << boost::errinfo_errno(errno)); | ||
645 | 118 | } | ||
646 | 119 | } | ||
647 | 120 | |||
648 | 121 | mgg::LinuxVirtualTerminal::~LinuxVirtualTerminal() noexcept(true) | ||
649 | 122 | { | ||
650 | 123 | if (vt_fd.fd() > 0) | ||
651 | 124 | { | ||
652 | 125 | ioctl(vt_fd.fd(), KDSETMODE, prev_kd_mode); | ||
653 | 126 | ioctl(vt_fd.fd(), VT_SETMODE, &prev_vt_mode); | ||
654 | 127 | } | ||
655 | 128 | } | ||
656 | 129 | |||
657 | 130 | void mgg::LinuxVirtualTerminal::set_graphics_mode() | ||
658 | 131 | { | ||
659 | 132 | if (ioctl(vt_fd.fd(), KDSETMODE, KD_GRAPHICS) < 0) | ||
660 | 133 | { | ||
661 | 134 | BOOST_THROW_EXCEPTION( | ||
662 | 135 | boost::enable_error_info( | ||
663 | 136 | std::runtime_error("Failed to set VT to graphics mode")) | ||
664 | 137 | << boost::errinfo_errno(errno)); | ||
665 | 138 | } | ||
666 | 139 | } | ||
667 | 140 | |||
668 | 141 | void mgg::LinuxVirtualTerminal::register_switch_handlers( | ||
669 | 142 | MainLoop& main_loop, | ||
670 | 143 | std::function<void()> const& switch_away, | ||
671 | 144 | std::function<void()> const& switch_back) | ||
672 | 145 | { | ||
673 | 146 | main_loop.register_signal_handler( | ||
674 | 147 | {SIGUSR1}, | ||
675 | 148 | [this, switch_away, switch_back](int) | ||
676 | 149 | { | ||
677 | 150 | active = !active; | ||
678 | 151 | if (active) | ||
679 | 152 | { | ||
680 | 153 | static int const allow_switch{2}; | ||
681 | 154 | switch_back(); | ||
682 | 155 | ioctl(vt_fd.fd(), VT_RELDISP, allow_switch); | ||
683 | 156 | } | ||
684 | 157 | else | ||
685 | 158 | { | ||
686 | 159 | switch_away(); | ||
687 | 160 | ioctl(vt_fd.fd(), VT_RELDISP, VT_ACKACQ); | ||
688 | 161 | } | ||
689 | 162 | }); | ||
690 | 163 | |||
691 | 164 | struct vt_mode vtm | ||
692 | 165 | { | ||
693 | 166 | VT_PROCESS, | ||
694 | 167 | 0, | ||
695 | 168 | SIGUSR1, | ||
696 | 169 | SIGUSR1, | ||
697 | 170 | 0 | ||
698 | 171 | }; | ||
699 | 172 | |||
700 | 173 | if (ioctl(vt_fd.fd(), VT_SETMODE, &vtm) < 0) | ||
701 | 174 | { | ||
702 | 175 | BOOST_THROW_EXCEPTION( | ||
703 | 176 | boost::enable_error_info( | ||
704 | 177 | std::runtime_error("Failed to set the current VT mode")) | ||
705 | 178 | << boost::errinfo_errno(errno)); | ||
706 | 179 | } | ||
707 | 180 | } | ||
708 | 0 | 181 | ||
709 | === added file 'src/server/graphics/gbm/linux_virtual_terminal.h' | |||
710 | --- src/server/graphics/gbm/linux_virtual_terminal.h 1970-01-01 00:00:00 +0000 | |||
711 | +++ src/server/graphics/gbm/linux_virtual_terminal.h 2013-04-11 11:00:30 +0000 | |||
712 | @@ -0,0 +1,67 @@ | |||
713 | 1 | /* | ||
714 | 2 | * Copyright © 2013 Canonical Ltd. | ||
715 | 3 | * | ||
716 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
717 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
718 | 6 | * as published by the Free Software Foundation. | ||
719 | 7 | * | ||
720 | 8 | * This program is distributed in the hope that it will be useful, | ||
721 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
722 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
723 | 11 | * GNU General Public License for more details. | ||
724 | 12 | * | ||
725 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
726 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
727 | 15 | * | ||
728 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
729 | 17 | */ | ||
730 | 18 | |||
731 | 19 | #ifndef MIR_GRAPHICS_GBM_LINUX_VIRTUAL_TERMINAL_H_ | ||
732 | 20 | #define MIR_GRAPHICS_GBM_LINUX_VIRTUAL_TERMINAL_H_ | ||
733 | 21 | |||
734 | 22 | #include "virtual_terminal.h" | ||
735 | 23 | |||
736 | 24 | #include <linux/vt.h> | ||
737 | 25 | #include <unistd.h> | ||
738 | 26 | |||
739 | 27 | namespace mir | ||
740 | 28 | { | ||
741 | 29 | namespace graphics | ||
742 | 30 | { | ||
743 | 31 | namespace gbm | ||
744 | 32 | { | ||
745 | 33 | |||
746 | 34 | class LinuxVirtualTerminal : public VirtualTerminal | ||
747 | 35 | { | ||
748 | 36 | public: | ||
749 | 37 | LinuxVirtualTerminal(); | ||
750 | 38 | ~LinuxVirtualTerminal() noexcept(true); | ||
751 | 39 | |||
752 | 40 | void set_graphics_mode(); | ||
753 | 41 | void register_switch_handlers( | ||
754 | 42 | MainLoop& main_loop, | ||
755 | 43 | std::function<void()> const& switch_away, | ||
756 | 44 | std::function<void()> const& switch_back); | ||
757 | 45 | |||
758 | 46 | private: | ||
759 | 47 | class FDWrapper | ||
760 | 48 | { | ||
761 | 49 | public: | ||
762 | 50 | FDWrapper(int fd) : fd_{fd} {} | ||
763 | 51 | ~FDWrapper() { if (fd_ >= 0) close(fd_); } | ||
764 | 52 | int fd() const { return fd_; } | ||
765 | 53 | private: | ||
766 | 54 | int const fd_; | ||
767 | 55 | }; | ||
768 | 56 | |||
769 | 57 | FDWrapper const vt_fd; | ||
770 | 58 | int prev_kd_mode; | ||
771 | 59 | struct vt_mode prev_vt_mode; | ||
772 | 60 | bool active; | ||
773 | 61 | }; | ||
774 | 62 | |||
775 | 63 | } | ||
776 | 64 | } | ||
777 | 65 | } | ||
778 | 66 | |||
779 | 67 | #endif /* MIR_GRAPHICS_GBM_LINUX_VIRTUAL_TERMINAL_H_ */ | ||
780 | 0 | 68 | ||
781 | === added file 'src/server/graphics/gbm/virtual_terminal.h' | |||
782 | --- src/server/graphics/gbm/virtual_terminal.h 1970-01-01 00:00:00 +0000 | |||
783 | +++ src/server/graphics/gbm/virtual_terminal.h 2013-04-11 11:00:30 +0000 | |||
784 | @@ -0,0 +1,55 @@ | |||
785 | 1 | /* | ||
786 | 2 | * Copyright © 2013 Canonical Ltd. | ||
787 | 3 | * | ||
788 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
789 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
790 | 6 | * as published by the Free Software Foundation. | ||
791 | 7 | * | ||
792 | 8 | * This program is distributed in the hope that it will be useful, | ||
793 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
794 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
795 | 11 | * GNU General Public License for more details. | ||
796 | 12 | * | ||
797 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
798 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
799 | 15 | * | ||
800 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | ||
801 | 17 | */ | ||
802 | 18 | |||
803 | 19 | #ifndef MIR_GRAPHICS_GBM_VIRTUAL_TERMINAL_H_ | ||
804 | 20 | #define MIR_GRAPHICS_GBM_VIRTUAL_TERMINAL_H_ | ||
805 | 21 | |||
806 | 22 | #include <functional> | ||
807 | 23 | |||
808 | 24 | namespace mir | ||
809 | 25 | { | ||
810 | 26 | |||
811 | 27 | class MainLoop; | ||
812 | 28 | |||
813 | 29 | namespace graphics | ||
814 | 30 | { | ||
815 | 31 | namespace gbm | ||
816 | 32 | { | ||
817 | 33 | |||
818 | 34 | class VirtualTerminal | ||
819 | 35 | { | ||
820 | 36 | public: | ||
821 | 37 | virtual ~VirtualTerminal() = default; | ||
822 | 38 | |||
823 | 39 | virtual void set_graphics_mode() = 0; | ||
824 | 40 | virtual void register_switch_handlers( | ||
825 | 41 | MainLoop& main_loop, | ||
826 | 42 | std::function<void()> const& switch_away, | ||
827 | 43 | std::function<void()> const& switch_back) = 0; | ||
828 | 44 | |||
829 | 45 | protected: | ||
830 | 46 | VirtualTerminal() = default; | ||
831 | 47 | VirtualTerminal(VirtualTerminal const&) = delete; | ||
832 | 48 | VirtualTerminal& operator=(VirtualTerminal const&) = delete; | ||
833 | 49 | }; | ||
834 | 50 | |||
835 | 51 | } | ||
836 | 52 | } | ||
837 | 53 | } | ||
838 | 54 | |||
839 | 55 | #endif /* MIR_GRAPHICS_GBM_VIRTUAL_TERMINAL_H_ */ | ||
840 | 0 | 56 | ||
841 | === modified file 'tests/behavior-tests/session_management_context.cpp' | |||
842 | --- tests/behavior-tests/session_management_context.cpp 2013-04-01 16:11:03 +0000 | |||
843 | +++ tests/behavior-tests/session_management_context.cpp 2013-04-11 11:00:30 +0000 | |||
844 | @@ -105,6 +105,15 @@ | |||
845 | 105 | return std::shared_ptr<mg::DisplayConfiguration>(); | 105 | return std::shared_ptr<mg::DisplayConfiguration>(); |
846 | 106 | } | 106 | } |
847 | 107 | 107 | ||
848 | 108 | void register_pause_resume_handlers(MainLoop&, | ||
849 | 109 | std::function<void()> const&, | ||
850 | 110 | std::function<void()> const&) | ||
851 | 111 | { | ||
852 | 112 | } | ||
853 | 113 | |||
854 | 114 | void pause() {} | ||
855 | 115 | void resume() {} | ||
856 | 116 | |||
857 | 108 | geom::Rectangle area; | 117 | geom::Rectangle area; |
858 | 109 | }; | 118 | }; |
859 | 110 | 119 | ||
860 | 111 | 120 | ||
861 | === modified file 'tests/integration-tests/test_display_server_main_loop_events.cpp' | |||
862 | --- tests/integration-tests/test_display_server_main_loop_events.cpp 2013-04-08 16:20:33 +0000 | |||
863 | +++ tests/integration-tests/test_display_server_main_loop_events.cpp 2013-04-11 11:00:30 +0000 | |||
864 | @@ -17,6 +17,8 @@ | |||
865 | 17 | */ | 17 | */ |
866 | 18 | 18 | ||
867 | 19 | #include "mir/compositor/compositor.h" | 19 | #include "mir/compositor/compositor.h" |
868 | 20 | #include "mir/graphics/display.h" | ||
869 | 21 | #include "mir/main_loop.h" | ||
870 | 20 | 22 | ||
871 | 21 | #include "mir_test_framework/testing_server_configuration.h" | 23 | #include "mir_test_framework/testing_server_configuration.h" |
872 | 22 | #include "mir_test_doubles/mock_input_manager.h" | 24 | #include "mir_test_doubles/mock_input_manager.h" |
873 | @@ -30,6 +32,7 @@ | |||
874 | 30 | 32 | ||
875 | 31 | namespace mi = mir::input; | 33 | namespace mi = mir::input; |
876 | 32 | namespace mc = mir::compositor; | 34 | namespace mc = mir::compositor; |
877 | 35 | namespace mg = mir::graphics; | ||
878 | 33 | namespace mtd = mir::test::doubles; | 36 | namespace mtd = mir::test::doubles; |
879 | 34 | namespace mtf = mir_test_framework; | 37 | namespace mtf = mir_test_framework; |
880 | 35 | 38 | ||
881 | @@ -43,6 +46,54 @@ | |||
882 | 43 | MOCK_METHOD0(stop, void()); | 46 | MOCK_METHOD0(stop, void()); |
883 | 44 | }; | 47 | }; |
884 | 45 | 48 | ||
885 | 49 | class MockDisplay : public mg::Display | ||
886 | 50 | { | ||
887 | 51 | public: | ||
888 | 52 | MockDisplay(std::shared_ptr<mg::Display> const& display, | ||
889 | 53 | int pause_signal, int resume_signal) | ||
890 | 54 | : display{display}, | ||
891 | 55 | pause_signal{pause_signal}, | ||
892 | 56 | resume_signal{resume_signal} | ||
893 | 57 | { | ||
894 | 58 | } | ||
895 | 59 | |||
896 | 60 | mir::geometry::Rectangle view_area() const | ||
897 | 61 | { | ||
898 | 62 | return display->view_area(); | ||
899 | 63 | } | ||
900 | 64 | |||
901 | 65 | void for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& f) | ||
902 | 66 | { | ||
903 | 67 | display->for_each_display_buffer(f); | ||
904 | 68 | } | ||
905 | 69 | |||
906 | 70 | std::shared_ptr<mg::DisplayConfiguration> configuration() | ||
907 | 71 | { | ||
908 | 72 | return display->configuration(); | ||
909 | 73 | } | ||
910 | 74 | |||
911 | 75 | void register_pause_resume_handlers( | ||
912 | 76 | mir::MainLoop& main_loop, | ||
913 | 77 | std::function<void()> const& pause_handler, | ||
914 | 78 | std::function<void()> const& resume_handler) | ||
915 | 79 | { | ||
916 | 80 | main_loop.register_signal_handler( | ||
917 | 81 | {pause_signal}, | ||
918 | 82 | [pause_handler](int) { pause_handler(); }); | ||
919 | 83 | main_loop.register_signal_handler( | ||
920 | 84 | {resume_signal}, | ||
921 | 85 | [resume_handler](int) { resume_handler(); }); | ||
922 | 86 | } | ||
923 | 87 | |||
924 | 88 | MOCK_METHOD0(pause, void()); | ||
925 | 89 | MOCK_METHOD0(resume, void()); | ||
926 | 90 | |||
927 | 91 | private: | ||
928 | 92 | std::shared_ptr<mg::Display> const display; | ||
929 | 93 | int const pause_signal; | ||
930 | 94 | int const resume_signal; | ||
931 | 95 | }; | ||
932 | 96 | |||
933 | 46 | class ServerConfig : public mtf::TestingServerConfiguration | 97 | class ServerConfig : public mtf::TestingServerConfiguration |
934 | 47 | { | 98 | { |
935 | 48 | public: | 99 | public: |
936 | @@ -77,6 +128,66 @@ | |||
937 | 77 | std::shared_ptr<MockCompositor> mock_compositor; | 128 | std::shared_ptr<MockCompositor> mock_compositor; |
938 | 78 | }; | 129 | }; |
939 | 79 | 130 | ||
940 | 131 | |||
941 | 132 | class PauseResumeServerConfig : public mtf::TestingServerConfiguration | ||
942 | 133 | { | ||
943 | 134 | public: | ||
944 | 135 | PauseResumeServerConfig() | ||
945 | 136 | : pause_signal{SIGUSR1}, resume_signal{SIGUSR2} | ||
946 | 137 | { | ||
947 | 138 | } | ||
948 | 139 | |||
949 | 140 | std::shared_ptr<mg::Display> the_display() override | ||
950 | 141 | { | ||
951 | 142 | if (!mock_display) | ||
952 | 143 | { | ||
953 | 144 | auto display = mtf::TestingServerConfiguration::the_display(); | ||
954 | 145 | mock_display = std::make_shared<MockDisplay>(display, | ||
955 | 146 | pause_signal, | ||
956 | 147 | resume_signal); | ||
957 | 148 | } | ||
958 | 149 | |||
959 | 150 | return mock_display; | ||
960 | 151 | } | ||
961 | 152 | |||
962 | 153 | std::shared_ptr<mc::Compositor> the_compositor() override | ||
963 | 154 | { | ||
964 | 155 | if (!mock_compositor) | ||
965 | 156 | mock_compositor = std::make_shared<MockCompositor>(); | ||
966 | 157 | |||
967 | 158 | return mock_compositor; | ||
968 | 159 | } | ||
969 | 160 | |||
970 | 161 | std::shared_ptr<MockDisplay> the_mock_display() | ||
971 | 162 | { | ||
972 | 163 | the_display(); | ||
973 | 164 | return mock_display; | ||
974 | 165 | } | ||
975 | 166 | |||
976 | 167 | std::shared_ptr<MockCompositor> the_mock_compositor() | ||
977 | 168 | { | ||
978 | 169 | the_compositor(); | ||
979 | 170 | return mock_compositor; | ||
980 | 171 | } | ||
981 | 172 | |||
982 | 173 | void emit_pause_event() | ||
983 | 174 | { | ||
984 | 175 | kill(getpid(), pause_signal); | ||
985 | 176 | } | ||
986 | 177 | |||
987 | 178 | void emit_resume_event() | ||
988 | 179 | { | ||
989 | 180 | kill(getpid(), resume_signal); | ||
990 | 181 | } | ||
991 | 182 | |||
992 | 183 | private: | ||
993 | 184 | std::shared_ptr<MockCompositor> mock_compositor; | ||
994 | 185 | std::shared_ptr<MockDisplay> mock_display; | ||
995 | 186 | |||
996 | 187 | int const pause_signal; | ||
997 | 188 | int const resume_signal; | ||
998 | 189 | }; | ||
999 | 190 | |||
1000 | 80 | } | 191 | } |
1001 | 81 | 192 | ||
1002 | 82 | TEST(DisplayServerMainLoopEvents, display_server_shuts_down_properly_on_sigint) | 193 | TEST(DisplayServerMainLoopEvents, display_server_shuts_down_properly_on_sigint) |
1003 | @@ -100,3 +211,70 @@ | |||
1004 | 100 | kill(getpid(), SIGTERM); | 211 | kill(getpid(), SIGTERM); |
1005 | 101 | }); | 212 | }); |
1006 | 102 | } | 213 | } |
1007 | 214 | |||
1008 | 215 | TEST(DisplayServerMainLoopEvents, display_server_components_pause_and_resume) | ||
1009 | 216 | { | ||
1010 | 217 | using namespace testing; | ||
1011 | 218 | |||
1012 | 219 | PauseResumeServerConfig server_config; | ||
1013 | 220 | |||
1014 | 221 | auto mock_compositor = server_config.the_mock_compositor(); | ||
1015 | 222 | auto mock_display = server_config.the_mock_display(); | ||
1016 | 223 | |||
1017 | 224 | { | ||
1018 | 225 | InSequence s; | ||
1019 | 226 | |||
1020 | 227 | /* Start */ | ||
1021 | 228 | EXPECT_CALL(*mock_compositor, start()).Times(1); | ||
1022 | 229 | |||
1023 | 230 | /* Pause */ | ||
1024 | 231 | EXPECT_CALL(*mock_compositor, stop()).Times(1); | ||
1025 | 232 | EXPECT_CALL(*mock_display, pause()).Times(1); | ||
1026 | 233 | |||
1027 | 234 | /* Resume */ | ||
1028 | 235 | EXPECT_CALL(*mock_display, resume()).Times(1); | ||
1029 | 236 | EXPECT_CALL(*mock_compositor, start()).Times(1); | ||
1030 | 237 | |||
1031 | 238 | /* Stop */ | ||
1032 | 239 | EXPECT_CALL(*mock_compositor, stop()).Times(1); | ||
1033 | 240 | } | ||
1034 | 241 | |||
1035 | 242 | mir::run_mir(server_config, | ||
1036 | 243 | [&server_config](mir::DisplayServer&) | ||
1037 | 244 | { | ||
1038 | 245 | server_config.emit_pause_event(); | ||
1039 | 246 | server_config.emit_resume_event(); | ||
1040 | 247 | kill(getpid(), SIGTERM); | ||
1041 | 248 | }); | ||
1042 | 249 | } | ||
1043 | 250 | |||
1044 | 251 | TEST(DisplayServerMainLoopEvents, display_server_quits_when_paused) | ||
1045 | 252 | { | ||
1046 | 253 | using namespace testing; | ||
1047 | 254 | |||
1048 | 255 | PauseResumeServerConfig server_config; | ||
1049 | 256 | |||
1050 | 257 | auto mock_compositor = server_config.the_mock_compositor(); | ||
1051 | 258 | auto mock_display = server_config.the_mock_display(); | ||
1052 | 259 | |||
1053 | 260 | { | ||
1054 | 261 | InSequence s; | ||
1055 | 262 | |||
1056 | 263 | /* Start */ | ||
1057 | 264 | EXPECT_CALL(*mock_compositor, start()).Times(1); | ||
1058 | 265 | |||
1059 | 266 | /* Pause */ | ||
1060 | 267 | EXPECT_CALL(*mock_compositor, stop()).Times(1); | ||
1061 | 268 | EXPECT_CALL(*mock_display, pause()).Times(1); | ||
1062 | 269 | |||
1063 | 270 | /* Stop */ | ||
1064 | 271 | EXPECT_CALL(*mock_compositor, stop()).Times(1); | ||
1065 | 272 | } | ||
1066 | 273 | |||
1067 | 274 | mir::run_mir(server_config, | ||
1068 | 275 | [&server_config](mir::DisplayServer&) | ||
1069 | 276 | { | ||
1070 | 277 | server_config.emit_pause_event(); | ||
1071 | 278 | kill(getpid(), SIGTERM); | ||
1072 | 279 | }); | ||
1073 | 280 | } | ||
1074 | 103 | 281 | ||
1075 | === modified file 'tests/integration-tests/test_surfaceloop.cpp' | |||
1076 | --- tests/integration-tests/test_surfaceloop.cpp 2013-04-10 16:40:04 +0000 | |||
1077 | +++ tests/integration-tests/test_surfaceloop.cpp 2013-04-11 11:00:30 +0000 | |||
1078 | @@ -133,6 +133,13 @@ | |||
1079 | 133 | auto null_configuration = std::shared_ptr<mg::DisplayConfiguration>(); | 133 | auto null_configuration = std::shared_ptr<mg::DisplayConfiguration>(); |
1080 | 134 | return null_configuration; | 134 | return null_configuration; |
1081 | 135 | } | 135 | } |
1082 | 136 | void register_pause_resume_handlers(mir::MainLoop&, | ||
1083 | 137 | std::function<void()> const&, | ||
1084 | 138 | std::function<void()> const&) | ||
1085 | 139 | { | ||
1086 | 140 | } | ||
1087 | 141 | void pause() {} | ||
1088 | 142 | void resume() {} | ||
1089 | 136 | }; | 143 | }; |
1090 | 137 | 144 | ||
1091 | 138 | struct SurfaceSync | 145 | struct SurfaceSync |
1092 | 139 | 146 | ||
1093 | === modified file 'tests/mir_test_framework/testing_server_options.cpp' | |||
1094 | --- tests/mir_test_framework/testing_server_options.cpp 2013-04-09 18:00:48 +0000 | |||
1095 | +++ tests/mir_test_framework/testing_server_options.cpp 2013-04-11 11:00:30 +0000 | |||
1096 | @@ -86,6 +86,13 @@ | |||
1097 | 86 | auto null_configuration = std::shared_ptr<mg::DisplayConfiguration>(); | 86 | auto null_configuration = std::shared_ptr<mg::DisplayConfiguration>(); |
1098 | 87 | return null_configuration; | 87 | return null_configuration; |
1099 | 88 | } | 88 | } |
1100 | 89 | void register_pause_resume_handlers(mir::MainLoop&, | ||
1101 | 90 | std::function<void()> const&, | ||
1102 | 91 | std::function<void()> const&) | ||
1103 | 92 | { | ||
1104 | 93 | } | ||
1105 | 94 | void pause() {} | ||
1106 | 95 | void resume() {} | ||
1107 | 89 | }; | 96 | }; |
1108 | 90 | 97 | ||
1109 | 91 | class StubGraphicPlatform : public mg::Platform | 98 | class StubGraphicPlatform : public mg::Platform |
1110 | 92 | 99 | ||
1111 | === modified file 'tests/unit-tests/compositor/test_multi_threaded_compositor.cpp' | |||
1112 | --- tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-03-27 15:12:09 +0000 | |||
1113 | +++ tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-04-11 11:00:30 +0000 | |||
1114 | @@ -53,6 +53,13 @@ | |||
1115 | 53 | { | 53 | { |
1116 | 54 | return std::shared_ptr<mg::DisplayConfiguration>(); | 54 | return std::shared_ptr<mg::DisplayConfiguration>(); |
1117 | 55 | } | 55 | } |
1118 | 56 | void register_pause_resume_handlers(mir::MainLoop&, | ||
1119 | 57 | std::function<void()> const&, | ||
1120 | 58 | std::function<void()> const&) | ||
1121 | 59 | { | ||
1122 | 60 | } | ||
1123 | 61 | void pause() {} | ||
1124 | 62 | void resume() {} | ||
1125 | 56 | 63 | ||
1126 | 57 | private: | 64 | private: |
1127 | 58 | std::vector<mtd::NullDisplayBuffer> buffers; | 65 | std::vector<mtd::NullDisplayBuffer> buffers; |
1128 | 59 | 66 | ||
1129 | === modified file 'tests/unit-tests/graphics/gbm/mock_drm.cpp' | |||
1130 | --- tests/unit-tests/graphics/gbm/mock_drm.cpp 2013-03-07 06:00:18 +0000 | |||
1131 | +++ tests/unit-tests/graphics/gbm/mock_drm.cpp 2013-04-11 11:00:30 +0000 | |||
1132 | @@ -351,3 +351,13 @@ | |||
1133 | 351 | { | 351 | { |
1134 | 352 | return global_mock->drmPrimeFDToHandle(fd, prime_fd, handle); | 352 | return global_mock->drmPrimeFDToHandle(fd, prime_fd, handle); |
1135 | 353 | } | 353 | } |
1136 | 354 | |||
1137 | 355 | int drmSetMaster(int fd) | ||
1138 | 356 | { | ||
1139 | 357 | return global_mock->drmSetMaster(fd); | ||
1140 | 358 | } | ||
1141 | 359 | |||
1142 | 360 | int drmDropMaster(int fd) | ||
1143 | 361 | { | ||
1144 | 362 | return global_mock->drmDropMaster(fd); | ||
1145 | 363 | } | ||
1146 | 354 | 364 | ||
1147 | === modified file 'tests/unit-tests/graphics/gbm/mock_drm.h' | |||
1148 | --- tests/unit-tests/graphics/gbm/mock_drm.h 2013-03-07 06:00:18 +0000 | |||
1149 | +++ tests/unit-tests/graphics/gbm/mock_drm.h 2013-04-11 11:00:30 +0000 | |||
1150 | @@ -117,6 +117,9 @@ | |||
1151 | 117 | MOCK_METHOD4(drmPrimeHandleToFD, int(int fd, uint32_t handle, uint32_t flags, int *prime_fd)); | 117 | MOCK_METHOD4(drmPrimeHandleToFD, int(int fd, uint32_t handle, uint32_t flags, int *prime_fd)); |
1152 | 118 | MOCK_METHOD3(drmPrimeFDToHandle, int(int fd, int prime_fd, uint32_t *handle)); | 118 | MOCK_METHOD3(drmPrimeFDToHandle, int(int fd, int prime_fd, uint32_t *handle)); |
1153 | 119 | 119 | ||
1154 | 120 | MOCK_METHOD1(drmSetMaster, int(int fd)); | ||
1155 | 121 | MOCK_METHOD1(drmDropMaster, int(int fd)); | ||
1156 | 122 | |||
1157 | 120 | FakeDRMResources fake_drm; | 123 | FakeDRMResources fake_drm; |
1158 | 121 | }; | 124 | }; |
1159 | 122 | 125 | ||
1160 | 123 | 126 | ||
1161 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp' | |||
1162 | --- tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp 2013-03-27 04:39:27 +0000 | |||
1163 | +++ tests/unit-tests/graphics/gbm/test_gbm_buffer.cpp 2013-04-11 11:00:30 +0000 | |||
1164 | @@ -27,6 +27,7 @@ | |||
1165 | 27 | #include "mir/graphics/buffer_initializer.h" | 27 | #include "mir/graphics/buffer_initializer.h" |
1166 | 28 | #include "mir/compositor/buffer_ipc_package.h" | 28 | #include "mir/compositor/buffer_ipc_package.h" |
1167 | 29 | #include "mir/compositor/buffer_properties.h" | 29 | #include "mir/compositor/buffer_properties.h" |
1168 | 30 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1169 | 30 | 31 | ||
1170 | 31 | #include "mir/graphics/null_display_report.h" | 32 | #include "mir/graphics/null_display_report.h" |
1171 | 32 | 33 | ||
1172 | @@ -42,6 +43,7 @@ | |||
1173 | 42 | namespace mg=mir::graphics; | 43 | namespace mg=mir::graphics; |
1174 | 43 | namespace mgg=mir::graphics::gbm; | 44 | namespace mgg=mir::graphics::gbm; |
1175 | 44 | namespace geom=mir::geometry; | 45 | namespace geom=mir::geometry; |
1176 | 46 | namespace mtd=mir::test::doubles; | ||
1177 | 45 | 47 | ||
1178 | 46 | class GBMGraphicBufferBasic : public ::testing::Test | 48 | class GBMGraphicBufferBasic : public ::testing::Test |
1179 | 47 | { | 49 | { |
1180 | @@ -77,7 +79,8 @@ | |||
1181 | 77 | ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) | 79 | ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1182 | 78 | .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); | 80 | .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); |
1183 | 79 | 81 | ||
1185 | 80 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 82 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>(), |
1186 | 83 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1187 | 81 | null_init = std::make_shared<mg::NullBufferInitializer>(); | 84 | null_init = std::make_shared<mg::NullBufferInitializer>(); |
1188 | 82 | allocator.reset(new mgg::GBMBufferAllocator(platform, null_init)); | 85 | allocator.reset(new mgg::GBMBufferAllocator(platform, null_init)); |
1189 | 83 | } | 86 | } |
1190 | 84 | 87 | ||
1191 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp' | |||
1192 | --- tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-03-13 08:09:52 +0000 | |||
1193 | +++ tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-04-11 11:00:30 +0000 | |||
1194 | @@ -27,6 +27,7 @@ | |||
1195 | 27 | #include "mir_test/egl_mock.h" | 27 | #include "mir_test/egl_mock.h" |
1196 | 28 | #include "mir_test/gl_mock.h" | 28 | #include "mir_test/gl_mock.h" |
1197 | 29 | #include "mir_test_doubles/mock_buffer_initializer.h" | 29 | #include "mir_test_doubles/mock_buffer_initializer.h" |
1198 | 30 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1199 | 30 | #include "mir/graphics/null_display_report.h" | 31 | #include "mir/graphics/null_display_report.h" |
1200 | 31 | 32 | ||
1201 | 32 | #include <memory> | 33 | #include <memory> |
1202 | @@ -67,7 +68,8 @@ | |||
1203 | 67 | ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) | 68 | ON_CALL(mock_egl, eglGetProcAddress(StrEq("glEGLImageTargetTexture2DOES"))) |
1204 | 68 | .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); | 69 | .WillByDefault(Return(reinterpret_cast<func_ptr_t>(glEGLImageTargetTexture2DOES))); |
1205 | 69 | 70 | ||
1207 | 70 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 71 | platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>(), |
1208 | 72 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1209 | 71 | mock_buffer_initializer = std::make_shared<testing::NiceMock<mtd::MockBufferInitializer>>(); | 73 | mock_buffer_initializer = std::make_shared<testing::NiceMock<mtd::MockBufferInitializer>>(); |
1210 | 72 | allocator.reset(new mgg::GBMBufferAllocator(platform, mock_buffer_initializer)); | 74 | allocator.reset(new mgg::GBMBufferAllocator(platform, mock_buffer_initializer)); |
1211 | 73 | } | 75 | } |
1212 | 74 | 76 | ||
1213 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_display.cpp' | |||
1214 | --- tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-03-22 11:37:34 +0000 | |||
1215 | +++ tests/unit-tests/graphics/gbm/test_gbm_display.cpp 2013-04-11 11:00:30 +0000 | |||
1216 | @@ -18,13 +18,17 @@ | |||
1217 | 18 | #include <boost/throw_exception.hpp> | 18 | #include <boost/throw_exception.hpp> |
1218 | 19 | #include "src/server/graphics/gbm/gbm_platform.h" | 19 | #include "src/server/graphics/gbm/gbm_platform.h" |
1219 | 20 | #include "src/server/graphics/gbm/gbm_display.h" | 20 | #include "src/server/graphics/gbm/gbm_display.h" |
1220 | 21 | #include "src/server/graphics/gbm/virtual_terminal.h" | ||
1221 | 21 | #include "mir/logging/display_report.h" | 22 | #include "mir/logging/display_report.h" |
1222 | 22 | #include "mir/logging/logger.h" | 23 | #include "mir/logging/logger.h" |
1223 | 24 | #include "mir/graphics/display_buffer.h" | ||
1224 | 25 | #include "mir/main_loop.h" | ||
1225 | 23 | 26 | ||
1226 | 24 | #include "mir_test/egl_mock.h" | 27 | #include "mir_test/egl_mock.h" |
1227 | 25 | #include "mir_test/gl_mock.h" | 28 | #include "mir_test/gl_mock.h" |
1228 | 26 | #include "mir/graphics/null_display_report.h" | 29 | #include "mir/graphics/null_display_report.h" |
1229 | 27 | #include "mir_test_doubles/mock_display_report.h" | 30 | #include "mir_test_doubles/mock_display_report.h" |
1230 | 31 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1231 | 28 | 32 | ||
1232 | 29 | #include "mock_drm.h" | 33 | #include "mock_drm.h" |
1233 | 30 | #include "mock_gbm.h" | 34 | #include "mock_gbm.h" |
1234 | @@ -48,11 +52,24 @@ | |||
1235 | 48 | ~MockLogger() noexcept(true) {} | 52 | ~MockLogger() noexcept(true) {} |
1236 | 49 | }; | 53 | }; |
1237 | 50 | 54 | ||
1238 | 55 | class MockVirtualTerminal : public mgg::VirtualTerminal | ||
1239 | 56 | { | ||
1240 | 57 | public: | ||
1241 | 58 | ~MockVirtualTerminal() noexcept(true) {} | ||
1242 | 59 | |||
1243 | 60 | MOCK_METHOD0(set_graphics_mode, void()); | ||
1244 | 61 | MOCK_METHOD3(register_switch_handlers, | ||
1245 | 62 | void(mir::MainLoop&, | ||
1246 | 63 | std::function<void()> const&, | ||
1247 | 64 | std::function<void()> const&)); | ||
1248 | 65 | }; | ||
1249 | 66 | |||
1250 | 51 | class GBMDisplayTest : public ::testing::Test | 67 | class GBMDisplayTest : public ::testing::Test |
1251 | 52 | { | 68 | { |
1252 | 53 | public: | 69 | public: |
1253 | 54 | GBMDisplayTest() : | 70 | GBMDisplayTest() : |
1255 | 55 | mock_report(new ::testing::NiceMock<mtd::MockDisplayReport>()) | 71 | mock_report{std::make_shared<testing::NiceMock<mtd::MockDisplayReport>>()}, |
1256 | 72 | null_report{std::make_shared<mg::NullDisplayReport>()} | ||
1257 | 56 | { | 73 | { |
1258 | 57 | using namespace testing; | 74 | using namespace testing; |
1259 | 58 | ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_)) | 75 | ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_)) |
1260 | @@ -78,6 +95,12 @@ | |||
1261 | 78 | .Times(AtLeast(0)); | 95 | .Times(AtLeast(0)); |
1262 | 79 | } | 96 | } |
1263 | 80 | 97 | ||
1264 | 98 | std::shared_ptr<mgg::GBMPlatform> create_platform() | ||
1265 | 99 | { | ||
1266 | 100 | return std::make_shared<mgg::GBMPlatform>( | ||
1267 | 101 | null_report, | ||
1268 | 102 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1269 | 103 | } | ||
1270 | 81 | 104 | ||
1271 | 82 | void setup_post_update_expectations() | 105 | void setup_post_update_expectations() |
1272 | 83 | { | 106 | { |
1273 | @@ -167,7 +190,8 @@ | |||
1274 | 167 | ::testing::NiceMock<mir::GLMock> mock_gl; | 190 | ::testing::NiceMock<mir::GLMock> mock_gl; |
1275 | 168 | ::testing::NiceMock<mgg::MockDRM> mock_drm; | 191 | ::testing::NiceMock<mgg::MockDRM> mock_drm; |
1276 | 169 | ::testing::NiceMock<mgg::MockGBM> mock_gbm; | 192 | ::testing::NiceMock<mgg::MockGBM> mock_gbm; |
1278 | 170 | std::shared_ptr<testing::NiceMock<mtd::MockDisplayReport>> mock_report; | 193 | std::shared_ptr<testing::NiceMock<mtd::MockDisplayReport>> const mock_report; |
1279 | 194 | std::shared_ptr<mg::DisplayReport> const null_report; | ||
1280 | 171 | }; | 195 | }; |
1281 | 172 | 196 | ||
1282 | 173 | } | 197 | } |
1283 | @@ -232,8 +256,8 @@ | |||
1284 | 232 | 256 | ||
1285 | 233 | EXPECT_NO_THROW( | 257 | EXPECT_NO_THROW( |
1286 | 234 | { | 258 | { |
1289 | 235 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 259 | auto platform = create_platform(); |
1290 | 236 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 260 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1291 | 237 | }); | 261 | }); |
1292 | 238 | } | 262 | } |
1293 | 239 | 263 | ||
1294 | @@ -273,8 +297,8 @@ | |||
1295 | 273 | 297 | ||
1296 | 274 | EXPECT_NO_THROW( | 298 | EXPECT_NO_THROW( |
1297 | 275 | { | 299 | { |
1300 | 276 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 300 | auto platform = create_platform(); |
1301 | 277 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 301 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1302 | 278 | }); | 302 | }); |
1303 | 279 | } | 303 | } |
1304 | 280 | 304 | ||
1305 | @@ -291,8 +315,8 @@ | |||
1306 | 291 | 315 | ||
1307 | 292 | EXPECT_THROW( | 316 | EXPECT_THROW( |
1308 | 293 | { | 317 | { |
1311 | 294 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 318 | auto platform = create_platform(); |
1312 | 295 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 319 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1313 | 296 | }, std::runtime_error); | 320 | }, std::runtime_error); |
1314 | 297 | } | 321 | } |
1315 | 298 | 322 | ||
1316 | @@ -310,10 +334,10 @@ | |||
1317 | 310 | EXPECT_CALL(mock_drm, drmClose(_)) | 334 | EXPECT_CALL(mock_drm, drmClose(_)) |
1318 | 311 | .Times(Exactly(1)); | 335 | .Times(Exactly(1)); |
1319 | 312 | 336 | ||
1321 | 313 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 337 | auto platform = create_platform(); |
1322 | 314 | 338 | ||
1323 | 315 | EXPECT_THROW({ | 339 | EXPECT_THROW({ |
1325 | 316 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 340 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1326 | 317 | }, std::runtime_error) << "Expected that c'tor of GBMDisplay throws"; | 341 | }, std::runtime_error) << "Expected that c'tor of GBMDisplay throws"; |
1327 | 318 | } | 342 | } |
1328 | 319 | 343 | ||
1329 | @@ -332,8 +356,8 @@ | |||
1330 | 332 | .Times(Exactly(1)); | 356 | .Times(Exactly(1)); |
1331 | 333 | 357 | ||
1332 | 334 | EXPECT_THROW({ | 358 | EXPECT_THROW({ |
1335 | 335 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 359 | auto platform = create_platform(); |
1336 | 336 | }, std::runtime_error) << "Expected c'tor of GBMDisplay to throw an exception"; | 360 | }, std::runtime_error) << "Expected c'tor of GBMPlatform to throw an exception"; |
1337 | 337 | } | 361 | } |
1338 | 338 | 362 | ||
1339 | 339 | namespace | 363 | namespace |
1340 | @@ -394,8 +418,8 @@ | |||
1341 | 394 | 418 | ||
1342 | 395 | EXPECT_NO_THROW( | 419 | EXPECT_NO_THROW( |
1343 | 396 | { | 420 | { |
1346 | 397 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 421 | auto platform = create_platform(); |
1347 | 398 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 422 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1348 | 399 | 423 | ||
1349 | 400 | display->for_each_display_buffer([](mg::DisplayBuffer& db) | 424 | display->for_each_display_buffer([](mg::DisplayBuffer& db) |
1350 | 401 | { | 425 | { |
1351 | @@ -434,8 +458,8 @@ | |||
1352 | 434 | 458 | ||
1353 | 435 | EXPECT_NO_THROW( | 459 | EXPECT_NO_THROW( |
1354 | 436 | { | 460 | { |
1357 | 437 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 461 | auto platform = create_platform(); |
1358 | 438 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 462 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1359 | 439 | 463 | ||
1360 | 440 | display->for_each_display_buffer([](mg::DisplayBuffer& db) | 464 | display->for_each_display_buffer([](mg::DisplayBuffer& db) |
1361 | 441 | { | 465 | { |
1362 | @@ -469,7 +493,7 @@ | |||
1363 | 469 | 493 | ||
1364 | 470 | EXPECT_NO_THROW( | 494 | EXPECT_NO_THROW( |
1365 | 471 | { | 495 | { |
1367 | 472 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 496 | auto platform = create_platform(); |
1368 | 473 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 497 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); |
1369 | 474 | }); | 498 | }); |
1370 | 475 | } | 499 | } |
1371 | @@ -478,11 +502,11 @@ | |||
1372 | 478 | { | 502 | { |
1373 | 479 | using namespace ::testing; | 503 | using namespace ::testing; |
1374 | 480 | 504 | ||
1376 | 481 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 505 | auto platform = create_platform(); |
1377 | 482 | auto logger = std::make_shared<MockLogger>(); | 506 | auto logger = std::make_shared<MockLogger>(); |
1378 | 483 | 507 | ||
1379 | 484 | auto reporter = std::make_shared<ml::DisplayReport>(logger); | 508 | auto reporter = std::make_shared<ml::DisplayReport>(logger); |
1381 | 485 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 509 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1382 | 486 | 510 | ||
1383 | 487 | EXPECT_CALL( | 511 | EXPECT_CALL( |
1384 | 488 | *logger, | 512 | *logger, |
1385 | @@ -497,11 +521,11 @@ | |||
1386 | 497 | { | 521 | { |
1387 | 498 | using namespace ::testing; | 522 | using namespace ::testing; |
1388 | 499 | 523 | ||
1390 | 500 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 524 | auto platform = create_platform(); |
1391 | 501 | auto logger = std::make_shared<MockLogger>(); | 525 | auto logger = std::make_shared<MockLogger>(); |
1392 | 502 | 526 | ||
1393 | 503 | auto reporter = std::make_shared<ml::DisplayReport>(logger); | 527 | auto reporter = std::make_shared<ml::DisplayReport>(logger); |
1395 | 504 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 528 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1396 | 505 | 529 | ||
1397 | 506 | EXPECT_CALL( | 530 | EXPECT_CALL( |
1398 | 507 | *logger, | 531 | *logger, |
1399 | @@ -516,11 +540,11 @@ | |||
1400 | 516 | { | 540 | { |
1401 | 517 | using namespace ::testing; | 541 | using namespace ::testing; |
1402 | 518 | 542 | ||
1404 | 519 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 543 | auto platform = create_platform(); |
1405 | 520 | auto logger = std::make_shared<MockLogger>(); | 544 | auto logger = std::make_shared<MockLogger>(); |
1406 | 521 | 545 | ||
1407 | 522 | auto reporter = std::make_shared<ml::DisplayReport>(logger); | 546 | auto reporter = std::make_shared<ml::DisplayReport>(logger); |
1409 | 523 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 547 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1410 | 524 | 548 | ||
1411 | 525 | EXPECT_CALL( | 549 | EXPECT_CALL( |
1412 | 526 | *logger, | 550 | *logger, |
1413 | @@ -535,11 +559,11 @@ | |||
1414 | 535 | { | 559 | { |
1415 | 536 | using namespace ::testing; | 560 | using namespace ::testing; |
1416 | 537 | 561 | ||
1418 | 538 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 562 | auto platform = create_platform(); |
1419 | 539 | auto logger = std::make_shared<MockLogger>(); | 563 | auto logger = std::make_shared<MockLogger>(); |
1420 | 540 | 564 | ||
1421 | 541 | auto reporter = std::make_shared<ml::DisplayReport>(logger); | 565 | auto reporter = std::make_shared<ml::DisplayReport>(logger); |
1423 | 542 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 566 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1424 | 543 | 567 | ||
1425 | 544 | EXPECT_CALL( | 568 | EXPECT_CALL( |
1426 | 545 | *logger, | 569 | *logger, |
1427 | @@ -561,8 +585,8 @@ | |||
1428 | 561 | 585 | ||
1429 | 562 | EXPECT_THROW( | 586 | EXPECT_THROW( |
1430 | 563 | { | 587 | { |
1433 | 564 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 588 | auto platform = create_platform(); |
1434 | 565 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 589 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1435 | 566 | }, std::runtime_error); | 590 | }, std::runtime_error); |
1436 | 567 | } | 591 | } |
1437 | 568 | 592 | ||
1438 | @@ -577,8 +601,8 @@ | |||
1439 | 577 | 601 | ||
1440 | 578 | EXPECT_THROW( | 602 | EXPECT_THROW( |
1441 | 579 | { | 603 | { |
1444 | 580 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 604 | auto platform = create_platform(); |
1445 | 581 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 605 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1446 | 582 | }, std::runtime_error); | 606 | }, std::runtime_error); |
1447 | 583 | } | 607 | } |
1448 | 584 | 608 | ||
1449 | @@ -586,8 +610,8 @@ | |||
1450 | 586 | { | 610 | { |
1451 | 587 | using namespace ::testing; | 611 | using namespace ::testing; |
1452 | 588 | 612 | ||
1455 | 589 | auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>()); | 613 | auto platform = create_platform(); |
1456 | 590 | auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report); | 614 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); |
1457 | 591 | 615 | ||
1458 | 592 | int callback_count{0}; | 616 | int callback_count{0}; |
1459 | 593 | 617 | ||
1460 | @@ -598,3 +622,65 @@ | |||
1461 | 598 | 622 | ||
1462 | 599 | EXPECT_NE(0, callback_count); | 623 | EXPECT_NE(0, callback_count); |
1463 | 600 | } | 624 | } |
1464 | 625 | |||
1465 | 626 | TEST_F(GBMDisplayTest, constructor_sets_vt_graphics_mode) | ||
1466 | 627 | { | ||
1467 | 628 | using namespace testing; | ||
1468 | 629 | |||
1469 | 630 | auto mock_vt = std::make_shared<MockVirtualTerminal>(); | ||
1470 | 631 | |||
1471 | 632 | EXPECT_CALL(*mock_vt, set_graphics_mode()) | ||
1472 | 633 | .Times(1); | ||
1473 | 634 | |||
1474 | 635 | auto platform = std::make_shared<mgg::GBMPlatform>(null_report, mock_vt); | ||
1475 | 636 | |||
1476 | 637 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); | ||
1477 | 638 | } | ||
1478 | 639 | |||
1479 | 640 | TEST_F(GBMDisplayTest, pause_drops_drm_master) | ||
1480 | 641 | { | ||
1481 | 642 | using namespace testing; | ||
1482 | 643 | |||
1483 | 644 | EXPECT_CALL(mock_drm, drmDropMaster(mock_drm.fake_drm.fd())) | ||
1484 | 645 | .Times(1); | ||
1485 | 646 | |||
1486 | 647 | auto platform = create_platform(); | ||
1487 | 648 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); | ||
1488 | 649 | |||
1489 | 650 | display->pause(); | ||
1490 | 651 | } | ||
1491 | 652 | |||
1492 | 653 | TEST_F(GBMDisplayTest, resume_sets_drm_master) | ||
1493 | 654 | { | ||
1494 | 655 | using namespace testing; | ||
1495 | 656 | |||
1496 | 657 | EXPECT_CALL(mock_drm, drmSetMaster(mock_drm.fake_drm.fd())) | ||
1497 | 658 | .Times(1); | ||
1498 | 659 | |||
1499 | 660 | auto platform = create_platform(); | ||
1500 | 661 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); | ||
1501 | 662 | |||
1502 | 663 | display->resume(); | ||
1503 | 664 | } | ||
1504 | 665 | |||
1505 | 666 | TEST_F(GBMDisplayTest, set_or_drop_drm_master_failure_throws) | ||
1506 | 667 | { | ||
1507 | 668 | using namespace testing; | ||
1508 | 669 | |||
1509 | 670 | EXPECT_CALL(mock_drm, drmDropMaster(_)) | ||
1510 | 671 | .WillOnce(Return(-1)); | ||
1511 | 672 | |||
1512 | 673 | EXPECT_CALL(mock_drm, drmSetMaster(_)) | ||
1513 | 674 | .WillOnce(Return(-1)); | ||
1514 | 675 | |||
1515 | 676 | auto platform = create_platform(); | ||
1516 | 677 | auto display = std::make_shared<mgg::GBMDisplay>(platform, null_report); | ||
1517 | 678 | |||
1518 | 679 | EXPECT_THROW({ | ||
1519 | 680 | display->pause(); | ||
1520 | 681 | }, std::runtime_error); | ||
1521 | 682 | |||
1522 | 683 | EXPECT_THROW({ | ||
1523 | 684 | display->resume(); | ||
1524 | 685 | }, std::runtime_error); | ||
1525 | 686 | } | ||
1526 | 601 | 687 | ||
1527 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_display_configuration.cpp' | |||
1528 | --- tests/unit-tests/graphics/gbm/test_gbm_display_configuration.cpp 2013-03-13 08:09:52 +0000 | |||
1529 | +++ tests/unit-tests/graphics/gbm/test_gbm_display_configuration.cpp 2013-04-11 11:00:30 +0000 | |||
1530 | @@ -25,6 +25,7 @@ | |||
1531 | 25 | #include "mir_test/egl_mock.h" | 25 | #include "mir_test/egl_mock.h" |
1532 | 26 | #include "mir_test/gl_mock.h" | 26 | #include "mir_test/gl_mock.h" |
1533 | 27 | #include "mir/graphics/null_display_report.h" | 27 | #include "mir/graphics/null_display_report.h" |
1534 | 28 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1535 | 28 | 29 | ||
1536 | 29 | #include "mock_drm.h" | 30 | #include "mock_drm.h" |
1537 | 30 | #include "mock_gbm.h" | 31 | #include "mock_gbm.h" |
1538 | @@ -37,6 +38,7 @@ | |||
1539 | 37 | namespace mg = mir::graphics; | 38 | namespace mg = mir::graphics; |
1540 | 38 | namespace mgg = mir::graphics::gbm; | 39 | namespace mgg = mir::graphics::gbm; |
1541 | 39 | namespace geom = mir::geometry; | 40 | namespace geom = mir::geometry; |
1542 | 41 | namespace mtd = mir::test::doubles; | ||
1543 | 40 | 42 | ||
1544 | 41 | namespace | 43 | namespace |
1545 | 42 | { | 44 | { |
1546 | @@ -59,8 +61,7 @@ | |||
1547 | 59 | class GBMDisplayConfigurationTest : public ::testing::Test | 61 | class GBMDisplayConfigurationTest : public ::testing::Test |
1548 | 60 | { | 62 | { |
1549 | 61 | public: | 63 | public: |
1552 | 62 | GBMDisplayConfigurationTest() : | 64 | GBMDisplayConfigurationTest() |
1551 | 63 | null_listener{std::make_shared<mg::NullDisplayReport>()} | ||
1553 | 64 | { | 65 | { |
1554 | 65 | using namespace testing; | 66 | using namespace testing; |
1555 | 66 | 67 | ||
1556 | @@ -81,6 +82,13 @@ | |||
1557 | 81 | setup_sample_modes(); | 82 | setup_sample_modes(); |
1558 | 82 | } | 83 | } |
1559 | 83 | 84 | ||
1560 | 85 | std::shared_ptr<mgg::GBMPlatform> create_platform() | ||
1561 | 86 | { | ||
1562 | 87 | return std::make_shared<mgg::GBMPlatform>( | ||
1563 | 88 | std::make_shared<mg::NullDisplayReport>(), | ||
1564 | 89 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1565 | 90 | } | ||
1566 | 91 | |||
1567 | 84 | void setup_sample_modes() | 92 | void setup_sample_modes() |
1568 | 85 | { | 93 | { |
1569 | 86 | /* Add DRM modes */ | 94 | /* Add DRM modes */ |
1570 | @@ -98,7 +106,6 @@ | |||
1571 | 98 | ::testing::NiceMock<mir::GLMock> mock_gl; | 106 | ::testing::NiceMock<mir::GLMock> mock_gl; |
1572 | 99 | ::testing::NiceMock<mgg::MockDRM> mock_drm; | 107 | ::testing::NiceMock<mgg::MockDRM> mock_drm; |
1573 | 100 | ::testing::NiceMock<mgg::MockGBM> mock_gbm; | 108 | ::testing::NiceMock<mgg::MockGBM> mock_gbm; |
1574 | 101 | std::shared_ptr<mg::DisplayReport> const null_listener; | ||
1575 | 102 | 109 | ||
1576 | 103 | std::vector<drmModeModeInfo> modes0; | 110 | std::vector<drmModeModeInfo> modes0; |
1577 | 104 | std::vector<mg::DisplayConfigurationMode> conf_modes0; | 111 | std::vector<mg::DisplayConfigurationMode> conf_modes0; |
1578 | @@ -176,7 +183,7 @@ | |||
1579 | 176 | }; | 183 | }; |
1580 | 177 | 184 | ||
1581 | 178 | /* Test body */ | 185 | /* Test body */ |
1583 | 179 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 186 | auto platform = create_platform(); |
1584 | 180 | auto display = platform->create_display(); | 187 | auto display = platform->create_display(); |
1585 | 181 | 188 | ||
1586 | 182 | auto conf = display->configuration(); | 189 | auto conf = display->configuration(); |
1587 | @@ -214,7 +221,7 @@ | |||
1588 | 214 | resources.prepare(); | 221 | resources.prepare(); |
1589 | 215 | 222 | ||
1590 | 216 | /* Test body */ | 223 | /* Test body */ |
1592 | 217 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 224 | auto platform = create_platform(); |
1593 | 218 | auto display = platform->create_display(); | 225 | auto display = platform->create_display(); |
1594 | 219 | 226 | ||
1595 | 220 | auto conf = display->configuration(); | 227 | auto conf = display->configuration(); |
1596 | @@ -253,7 +260,7 @@ | |||
1597 | 253 | resources.prepare(); | 260 | resources.prepare(); |
1598 | 254 | 261 | ||
1599 | 255 | /* Test body */ | 262 | /* Test body */ |
1601 | 256 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 263 | auto platform = create_platform(); |
1602 | 257 | auto display = platform->create_display(); | 264 | auto display = platform->create_display(); |
1603 | 258 | 265 | ||
1604 | 259 | auto conf = display->configuration(); | 266 | auto conf = display->configuration(); |
1605 | 260 | 267 | ||
1606 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_display_multi_monitor.cpp' | |||
1607 | --- tests/unit-tests/graphics/gbm/test_gbm_display_multi_monitor.cpp 2013-03-13 08:09:52 +0000 | |||
1608 | +++ tests/unit-tests/graphics/gbm/test_gbm_display_multi_monitor.cpp 2013-04-11 11:00:30 +0000 | |||
1609 | @@ -23,6 +23,7 @@ | |||
1610 | 23 | #include "mir_test/egl_mock.h" | 23 | #include "mir_test/egl_mock.h" |
1611 | 24 | #include "mir_test/gl_mock.h" | 24 | #include "mir_test/gl_mock.h" |
1612 | 25 | #include "mir/graphics/null_display_report.h" | 25 | #include "mir/graphics/null_display_report.h" |
1613 | 26 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1614 | 26 | 27 | ||
1615 | 27 | #include "mock_drm.h" | 28 | #include "mock_drm.h" |
1616 | 28 | #include "mock_gbm.h" | 29 | #include "mock_gbm.h" |
1617 | @@ -33,6 +34,7 @@ | |||
1618 | 33 | namespace mg = mir::graphics; | 34 | namespace mg = mir::graphics; |
1619 | 34 | namespace mgg = mir::graphics::gbm; | 35 | namespace mgg = mir::graphics::gbm; |
1620 | 35 | namespace geom = mir::geometry; | 36 | namespace geom = mir::geometry; |
1621 | 37 | namespace mtd = mir::test::doubles; | ||
1622 | 36 | 38 | ||
1623 | 37 | namespace | 39 | namespace |
1624 | 38 | { | 40 | { |
1625 | @@ -41,7 +43,6 @@ | |||
1626 | 41 | { | 43 | { |
1627 | 42 | public: | 44 | public: |
1628 | 43 | GBMDisplayMultiMonitorTest() | 45 | GBMDisplayMultiMonitorTest() |
1629 | 44 | : null_listener{std::make_shared<mg::NullDisplayReport>()} | ||
1630 | 45 | { | 46 | { |
1631 | 46 | using namespace testing; | 47 | using namespace testing; |
1632 | 47 | 48 | ||
1633 | @@ -69,6 +70,13 @@ | |||
1634 | 69 | .Times(AtLeast(0)); | 70 | .Times(AtLeast(0)); |
1635 | 70 | } | 71 | } |
1636 | 71 | 72 | ||
1637 | 73 | std::shared_ptr<mgg::GBMPlatform> create_platform() | ||
1638 | 74 | { | ||
1639 | 75 | return std::make_shared<mgg::GBMPlatform>( | ||
1640 | 76 | std::make_shared<mg::NullDisplayReport>(), | ||
1641 | 77 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1642 | 78 | } | ||
1643 | 79 | |||
1644 | 72 | void setup_outputs(int n) | 80 | void setup_outputs(int n) |
1645 | 73 | { | 81 | { |
1646 | 74 | mgg::FakeDRMResources& resources(mock_drm.fake_drm); | 82 | mgg::FakeDRMResources& resources(mock_drm.fake_drm); |
1647 | @@ -117,7 +125,6 @@ | |||
1648 | 117 | testing::NiceMock<mir::GLMock> mock_gl; | 125 | testing::NiceMock<mir::GLMock> mock_gl; |
1649 | 118 | testing::NiceMock<mgg::MockDRM> mock_drm; | 126 | testing::NiceMock<mgg::MockDRM> mock_drm; |
1650 | 119 | testing::NiceMock<mgg::MockGBM> mock_gbm; | 127 | testing::NiceMock<mgg::MockGBM> mock_gbm; |
1651 | 120 | std::shared_ptr<mg::DisplayReport> const null_listener; | ||
1652 | 121 | 128 | ||
1653 | 122 | std::vector<drmModeModeInfo> modes0; | 129 | std::vector<drmModeModeInfo> modes0; |
1654 | 123 | std::vector<drmModeModeInfo> modes_empty; | 130 | std::vector<drmModeModeInfo> modes_empty; |
1655 | @@ -168,7 +175,7 @@ | |||
1656 | 168 | .After(crtc_setups); | 175 | .After(crtc_setups); |
1657 | 169 | } | 176 | } |
1658 | 170 | 177 | ||
1660 | 171 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 178 | auto platform = create_platform(); |
1661 | 172 | auto display = platform->create_display(); | 179 | auto display = platform->create_display(); |
1662 | 173 | } | 180 | } |
1663 | 174 | 181 | ||
1664 | @@ -201,7 +208,7 @@ | |||
1665 | 201 | .Times(1); | 208 | .Times(1); |
1666 | 202 | } | 209 | } |
1667 | 203 | 210 | ||
1669 | 204 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 211 | auto platform = create_platform(); |
1670 | 205 | auto display = platform->create_display(); | 212 | auto display = platform->create_display(); |
1671 | 206 | } | 213 | } |
1672 | 207 | 214 | ||
1673 | @@ -254,7 +261,7 @@ | |||
1674 | 254 | .WillOnce(DoAll(InvokePageFlipHandler(&user_data[1]), Return(0))) | 261 | .WillOnce(DoAll(InvokePageFlipHandler(&user_data[1]), Return(0))) |
1675 | 255 | .WillOnce(DoAll(InvokePageFlipHandler(&user_data[2]), Return(0))); | 262 | .WillOnce(DoAll(InvokePageFlipHandler(&user_data[2]), Return(0))); |
1676 | 256 | 263 | ||
1678 | 257 | auto platform = std::make_shared<mgg::GBMPlatform>(null_listener); | 264 | auto platform = create_platform(); |
1679 | 258 | auto display = platform->create_display(); | 265 | auto display = platform->create_display(); |
1680 | 259 | 266 | ||
1681 | 260 | display->for_each_display_buffer([](mg::DisplayBuffer& buffer) | 267 | display->for_each_display_buffer([](mg::DisplayBuffer& buffer) |
1682 | 261 | 268 | ||
1683 | === modified file 'tests/unit-tests/graphics/gbm/test_gbm_platform.cpp' | |||
1684 | --- tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-03-13 04:54:15 +0000 | |||
1685 | +++ tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-04-11 11:00:30 +0000 | |||
1686 | @@ -16,9 +16,10 @@ | |||
1687 | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> | 16 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
1688 | 17 | */ | 17 | */ |
1689 | 18 | 18 | ||
1690 | 19 | #include "mir/graphics/platform.h" | ||
1691 | 20 | #include "mir/graphics/platform_ipc_package.h" | 19 | #include "mir/graphics/platform_ipc_package.h" |
1692 | 21 | #include "mir/graphics/drm_authenticator.h" | 20 | #include "mir/graphics/drm_authenticator.h" |
1693 | 21 | #include "src/server/graphics/gbm/gbm_platform.h" | ||
1694 | 22 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1695 | 22 | 23 | ||
1696 | 23 | #include "mir/graphics/null_display_report.h" | 24 | #include "mir/graphics/null_display_report.h" |
1697 | 24 | 25 | ||
1698 | @@ -28,13 +29,17 @@ | |||
1699 | 28 | #include "mock_gbm.h" | 29 | #include "mock_gbm.h" |
1700 | 29 | 30 | ||
1701 | 30 | #include <gtest/gtest.h> | 31 | #include <gtest/gtest.h> |
1702 | 32 | #include <gmock/gmock.h> | ||
1703 | 31 | 33 | ||
1704 | 32 | #include <stdexcept> | 34 | #include <stdexcept> |
1705 | 33 | 35 | ||
1706 | 34 | namespace mg = mir::graphics; | 36 | namespace mg = mir::graphics; |
1707 | 37 | namespace mgg = mir::graphics::gbm; | ||
1708 | 38 | namespace mtd = mir::test::doubles; | ||
1709 | 35 | 39 | ||
1710 | 36 | namespace | 40 | namespace |
1711 | 37 | { | 41 | { |
1712 | 42 | |||
1713 | 38 | class GBMGraphicsPlatform : public ::testing::Test | 43 | class GBMGraphicsPlatform : public ::testing::Test |
1714 | 39 | { | 44 | { |
1715 | 40 | public: | 45 | public: |
1716 | @@ -43,6 +48,14 @@ | |||
1717 | 43 | ::testing::Mock::VerifyAndClearExpectations(&mock_drm); | 48 | ::testing::Mock::VerifyAndClearExpectations(&mock_drm); |
1718 | 44 | ::testing::Mock::VerifyAndClearExpectations(&mock_gbm); | 49 | ::testing::Mock::VerifyAndClearExpectations(&mock_gbm); |
1719 | 45 | } | 50 | } |
1720 | 51 | |||
1721 | 52 | std::shared_ptr<mg::Platform> create_platform() | ||
1722 | 53 | { | ||
1723 | 54 | return std::make_shared<mgg::GBMPlatform>( | ||
1724 | 55 | std::make_shared<mg::NullDisplayReport>(), | ||
1725 | 56 | std::make_shared<mtd::NullVirtualTerminal>()); | ||
1726 | 57 | } | ||
1727 | 58 | |||
1728 | 46 | ::testing::NiceMock<mg::gbm::MockDRM> mock_drm; | 59 | ::testing::NiceMock<mg::gbm::MockDRM> mock_drm; |
1729 | 47 | ::testing::NiceMock<mg::gbm::MockGBM> mock_gbm; | 60 | ::testing::NiceMock<mg::gbm::MockGBM> mock_gbm; |
1730 | 48 | }; | 61 | }; |
1731 | @@ -69,7 +82,7 @@ | |||
1732 | 69 | EXPECT_CALL(mock_drm, drmClose(auth_fd)); | 82 | EXPECT_CALL(mock_drm, drmClose(auth_fd)); |
1733 | 70 | 83 | ||
1734 | 71 | EXPECT_NO_THROW ( | 84 | EXPECT_NO_THROW ( |
1736 | 72 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 85 | auto platform = create_platform(); |
1737 | 73 | auto pkg = platform->get_ipc_package(); | 86 | auto pkg = platform->get_ipc_package(); |
1738 | 74 | 87 | ||
1739 | 75 | ASSERT_TRUE(pkg.get()); | 88 | ASSERT_TRUE(pkg.get()); |
1740 | @@ -87,7 +100,7 @@ | |||
1741 | 87 | 100 | ||
1742 | 88 | try | 101 | try |
1743 | 89 | { | 102 | { |
1745 | 90 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 103 | auto platform = create_platform(); |
1746 | 91 | } catch(...) | 104 | } catch(...) |
1747 | 92 | { | 105 | { |
1748 | 93 | return; | 106 | return; |
1749 | @@ -105,7 +118,7 @@ | |||
1750 | 105 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) | 118 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) |
1751 | 106 | .WillOnce(Return(0)); | 119 | .WillOnce(Return(0)); |
1752 | 107 | 120 | ||
1754 | 108 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 121 | auto platform = create_platform(); |
1755 | 109 | auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); | 122 | auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); |
1756 | 110 | authenticator->drm_auth_magic(magic); | 123 | authenticator->drm_auth_magic(magic); |
1757 | 111 | } | 124 | } |
1758 | @@ -119,7 +132,7 @@ | |||
1759 | 119 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) | 132 | EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic)) |
1760 | 120 | .WillOnce(Return(-1)); | 133 | .WillOnce(Return(-1)); |
1761 | 121 | 134 | ||
1763 | 122 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 135 | auto platform = create_platform(); |
1764 | 123 | auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); | 136 | auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform); |
1765 | 124 | 137 | ||
1766 | 125 | EXPECT_THROW({ | 138 | EXPECT_THROW({ |
1767 | 126 | 139 | ||
1768 | === modified file 'tests/unit-tests/graphics/test_graphics_platform.cpp' | |||
1769 | --- tests/unit-tests/graphics/test_graphics_platform.cpp 2013-03-22 17:08:01 +0000 | |||
1770 | +++ tests/unit-tests/graphics/test_graphics_platform.cpp 2013-04-11 11:00:30 +0000 | |||
1771 | @@ -25,6 +25,8 @@ | |||
1772 | 25 | #ifndef ANDROID | 25 | #ifndef ANDROID |
1773 | 26 | #include "gbm/mock_drm.h" | 26 | #include "gbm/mock_drm.h" |
1774 | 27 | #include "gbm/mock_gbm.h" | 27 | #include "gbm/mock_gbm.h" |
1775 | 28 | #include "mir_test_doubles/null_virtual_terminal.h" | ||
1776 | 29 | #include "src/server/graphics/gbm/gbm_platform.h" | ||
1777 | 28 | #else | 30 | #else |
1778 | 29 | #include "mir_test/hw_mock.h" | 31 | #include "mir_test/hw_mock.h" |
1779 | 30 | #endif | 32 | #endif |
1780 | @@ -69,6 +71,17 @@ | |||
1781 | 69 | #endif | 71 | #endif |
1782 | 70 | } | 72 | } |
1783 | 71 | 73 | ||
1784 | 74 | std::shared_ptr<mg::Platform> create_platform() | ||
1785 | 75 | { | ||
1786 | 76 | #ifdef ANDROID | ||
1787 | 77 | return mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | ||
1788 | 78 | #else | ||
1789 | 79 | return std::make_shared<mg::gbm::GBMPlatform>( | ||
1790 | 80 | std::make_shared<mg::NullDisplayReport>(), | ||
1791 | 81 | std::make_shared<mir::test::doubles::NullVirtualTerminal>()); | ||
1792 | 82 | #endif | ||
1793 | 83 | } | ||
1794 | 84 | |||
1795 | 72 | std::shared_ptr<ml::Logger> logger; | 85 | std::shared_ptr<ml::Logger> logger; |
1796 | 73 | std::shared_ptr<mg::BufferInitializer> buffer_initializer; | 86 | std::shared_ptr<mg::BufferInitializer> buffer_initializer; |
1797 | 74 | 87 | ||
1798 | @@ -87,7 +100,7 @@ | |||
1799 | 87 | using namespace testing; | 100 | using namespace testing; |
1800 | 88 | 101 | ||
1801 | 89 | EXPECT_NO_THROW ( | 102 | EXPECT_NO_THROW ( |
1803 | 90 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 103 | auto platform = create_platform(); |
1804 | 91 | auto allocator = platform->create_buffer_allocator(buffer_initializer); | 104 | auto allocator = platform->create_buffer_allocator(buffer_initializer); |
1805 | 92 | 105 | ||
1806 | 93 | EXPECT_TRUE(allocator.get()); | 106 | EXPECT_TRUE(allocator.get()); |
1807 | @@ -97,7 +110,7 @@ | |||
1808 | 97 | 110 | ||
1809 | 98 | TEST_F(GraphicsPlatform, buffer_creation) | 111 | TEST_F(GraphicsPlatform, buffer_creation) |
1810 | 99 | { | 112 | { |
1812 | 100 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 113 | auto platform = create_platform(); |
1813 | 101 | auto allocator = platform->create_buffer_allocator(buffer_initializer); | 114 | auto allocator = platform->create_buffer_allocator(buffer_initializer); |
1814 | 102 | auto supported_pixel_formats = allocator->supported_pixel_formats(); | 115 | auto supported_pixel_formats = allocator->supported_pixel_formats(); |
1815 | 103 | 116 | ||
1816 | @@ -119,7 +132,7 @@ | |||
1817 | 119 | 132 | ||
1818 | 120 | TEST_F(GraphicsPlatform, get_ipc_package) | 133 | TEST_F(GraphicsPlatform, get_ipc_package) |
1819 | 121 | { | 134 | { |
1821 | 122 | auto platform = mg::create_platform(std::make_shared<mg::NullDisplayReport>()); | 135 | auto platform = create_platform(); |
1822 | 123 | auto pkg = platform->get_ipc_package(); | 136 | auto pkg = platform->get_ipc_package(); |
1823 | 124 | 137 | ||
1824 | 125 | ASSERT_TRUE(pkg.get() != NULL); | 138 | ASSERT_TRUE(pkg.get() != NULL); |
PASSED: Continuous integration, rev:581 jenkins. qa.ubuntu. com/job/ mir-ci/ 348/ jenkins. qa.ubuntu. com/job/ mir-android- raring- i386-build/ 334 jenkins. qa.ubuntu. com/job/ mir-clang- raring- amd64-build/ 217 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 353 jenkins. qa.ubuntu. com/job/ mir-quantal- amd64-ci/ 353/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-ci/ 348/rebuild
http://