Mir

Merge lp:~alan-griffiths/mir/test-of-SkeletonWindowManager into lp:mir

Proposed by Alan Griffiths
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~alan-griffiths/mir/test-of-SkeletonWindowManager
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/even-NullWindowManager-configures-surface
Diff against target: 245 lines (+219/-0)
3 files modified
tests/acceptance-tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/test_skeleton_window_manager.cpp (+217/-0)
tests/include/mir_test_doubles/mock_display.h (+1/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/test-of-SkeletonWindowManager
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+254384@code.launchpad.net

Commit message

tests: Supply missing test suite for SkeletonWindowManager

Description of the change

tests: Supply missing test suite for SkeletonWindowManager

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

okay

review: Approve

Unmerged revisions

2438. By Alan Griffiths

Avoid an explicit list of surface states

2437. By Alan Griffiths

SkeletonWindowManager.does_not_resize_on_state_changes

2436. By Alan Griffiths

merge lp:~alan-griffiths/mir/even-NullWindowManager-configures-surface

2435. By Alan Griffiths

SkeletonWindowManager.does_not_set_focus

2434. By Alan Griffiths

SkeletonWindowManager.ignores_output_selection

2433. By Alan Griffiths

merge lp:mir

2432. By Alan Griffiths

A few tests of SkeletonWindowManager

2431. By Alan Griffiths

merge lp:~alan-griffiths/mir/even-NullWindowManager-configures-surface

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/CMakeLists.txt'
2--- tests/acceptance-tests/CMakeLists.txt 2015-03-25 02:48:40 +0000
3+++ tests/acceptance-tests/CMakeLists.txt 2015-03-27 12:44:37 +0000
4@@ -37,6 +37,7 @@
5 test_client_platform_operation.cpp
6 test_latency.cpp
7 test_shell_control_of_surface_configuration.cpp
8+ test_skeleton_window_manager.cpp
9 )
10
11 if (MIR_TEST_PLATFORM STREQUAL "mesa")
12
13=== added file 'tests/acceptance-tests/test_skeleton_window_manager.cpp'
14--- tests/acceptance-tests/test_skeleton_window_manager.cpp 1970-01-01 00:00:00 +0000
15+++ tests/acceptance-tests/test_skeleton_window_manager.cpp 2015-03-27 12:44:37 +0000
16@@ -0,0 +1,217 @@
17+/*
18+ * Copyright © 2015 Canonical Ltd.
19+ *
20+ * This program is free software: you can redistribute it and/or modify it
21+ * under the terms of the GNU General Public License version 3,
22+ * as published by the Free Software Foundation.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ *
32+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
33+ */
34+
35+#include "mir/shell/skeleton_window_manager.h"
36+
37+#include "mir/geometry/rectangle.h"
38+
39+#include "mir_test_framework/connected_client_with_a_surface.h"
40+
41+#include <gtest/gtest.h>
42+#include <gmock/gmock.h>
43+
44+#include <atomic>
45+
46+namespace msh = mir::shell;
47+
48+namespace mt = mir::test;
49+
50+using mir_test_framework::ConnectedClientWithASurface;
51+using namespace mir::geometry;
52+using namespace testing;
53+
54+namespace
55+{
56+std::vector<Rectangle> const display_geometry { {{0, 0},{1, 1}}, {{0, 1},{1, 2}} };
57+
58+struct EventCallback
59+{
60+ void operator()(MirSurface* surface, MirEvent const* event)
61+ {
62+ switch (mir_event_get_type(event))
63+ {
64+ case mir_event_type_surface:
65+ surface_event(surface, mir_event_get_surface_event(event));
66+ break;
67+
68+ case mir_event_type_resize:
69+ resize_event(surface, mir_event_get_resize_event(event));
70+ break;
71+
72+ default:
73+ break;
74+ }
75+ }
76+
77+ virtual ~EventCallback() = default;
78+ virtual void surface_event(MirSurface* /*surface*/, MirSurfaceEvent const* /*event*/) {}
79+ virtual void resize_event(MirSurface* /*surface*/, MirResizeEvent const* /*event*/) {}
80+};
81+
82+void event_callback(MirSurface* surface, MirEvent const* event, void* context)
83+{
84+ (*static_cast<EventCallback*>(context))(surface, event);
85+}
86+
87+MirSurfaceState operator++(MirSurfaceState& state)
88+{
89+ return state = static_cast<MirSurfaceState>(state+1);
90+}
91+
92+struct SkeletonWindowManager : ConnectedClientWithASurface
93+{
94+ SkeletonWindowManager()
95+ {
96+ add_to_environment("MIR_SERVER_ENABLE_INPUT","off");
97+ initial_display_layout(display_geometry);
98+ }
99+
100+ void SetUp() override
101+ {
102+ server.override_the_window_manager_builder([](msh::FocusController*)
103+ { return std::make_shared<msh::SkeletonWindowManager>(); });
104+
105+ ConnectedClientWithASurface::SetUp();
106+ }
107+};
108+}
109+
110+TEST_F(SkeletonWindowManager, allows_surface_creation)
111+{
112+ EXPECT_TRUE(mir_surface_is_valid(surface));
113+}
114+
115+TEST_F(SkeletonWindowManager, does_not_size_surface_to_display)
116+{
117+ MirSurfaceParameters params;
118+ mir_surface_get_parameters(surface, &params);
119+
120+ EXPECT_THAT(params.width, Gt(2));
121+ EXPECT_THAT(params.height, Gt(2));
122+}
123+
124+TEST_F(SkeletonWindowManager, allows_all_states)
125+{
126+ for (auto state = mir_surface_state_unknown; state != mir_surface_states; ++state)
127+ {
128+ mir_wait_for(mir_surface_set_state(surface, state));
129+
130+ EXPECT_THAT(mir_surface_get_state(surface), Eq(state));
131+ }
132+}
133+
134+TEST_F(SkeletonWindowManager, does_not_resize_on_state_changes)
135+{
136+ struct ResizeEventCounter : EventCallback
137+ {
138+ std::atomic<unsigned> events{0};
139+
140+ void resize_event(MirSurface* /*surface*/, MirResizeEvent const* /*event*/) override
141+ {
142+ ++events;
143+ }
144+ } resize;
145+
146+ MirEventDelegate const event_delegate{event_callback, &resize};
147+
148+ mir_surface_set_event_handler(surface, &event_delegate);
149+
150+ for (auto state = mir_surface_state_unknown; state != mir_surface_states; ++state)
151+ {
152+ mir_wait_for(mir_surface_set_state(surface, state));
153+ }
154+
155+ EXPECT_THAT(resize.events, Eq(0));
156+}
157+
158+TEST_F(SkeletonWindowManager, ignores_output_selection)
159+{
160+ int const width = 13;
161+ int const height= 17;
162+
163+ MirDisplayConfiguration* const config = mir_connection_create_display_config(connection);
164+
165+ MirDisplayOutput* const output = config->outputs + 0;
166+
167+ MirSurfaceSpec* const spec = mir_connection_create_spec_for_normal_surface(
168+ connection,
169+ width,
170+ height,
171+ mir_pixel_format_abgr_8888);
172+
173+ mir_surface_spec_set_fullscreen_on_output(spec, output->output_id);
174+
175+ MirSurface* const surface = mir_surface_create_sync(spec);
176+ mir_surface_spec_release(spec);
177+
178+ MirSurfaceParameters params;
179+ mir_surface_get_parameters(surface, &params);
180+
181+ MirDisplayMode* const mode = output->modes + output->current_mode;
182+ EXPECT_THAT(params.width, Ne(mode->horizontal_resolution));
183+ EXPECT_THAT(params.height, Ne(mode->vertical_resolution));
184+
185+ EXPECT_THAT(params.width, Eq(width));
186+ EXPECT_THAT(params.height, Eq(height));
187+
188+ mir_surface_release_sync(surface);
189+ mir_display_config_destroy(config);
190+}
191+
192+TEST_F(SkeletonWindowManager, does_not_set_focus)
193+{
194+ int const width = 11;
195+ int const height = 9;
196+
197+ struct FocusEventCounter : EventCallback
198+ {
199+ std::atomic<unsigned> events{0};
200+
201+ void surface_event(MirSurface* /*surface*/, MirSurfaceEvent const* event) override
202+ {
203+ if (mir_surface_event_get_attribute(event) == mir_surface_attrib_focus)
204+ ++events;
205+ }
206+ } focus;
207+
208+ MirEventDelegate const event_delegate{event_callback, &focus};
209+
210+ mir_surface_set_event_handler(surface, &event_delegate);
211+
212+ MirSurface* surfaces[19] { nullptr };
213+
214+ for (MirSurface*& surface : surfaces)
215+ {
216+ MirSurfaceSpec* const spec = mir_connection_create_spec_for_normal_surface(
217+ connection,
218+ width,
219+ height,
220+ mir_pixel_format_abgr_8888);
221+
222+ surface = mir_surface_create_sync(spec);
223+ mir_surface_spec_release(spec);
224+ mir_surface_set_event_handler(surface, &event_delegate);
225+ }
226+
227+ for (MirSurface* surface : surfaces)
228+ {
229+ mir_surface_release_sync(surface);
230+ }
231+
232+ EXPECT_THAT(focus.events, Eq(0));
233+}
234
235=== modified file 'tests/include/mir_test_doubles/mock_display.h'
236--- tests/include/mir_test_doubles/mock_display.h 2015-03-25 02:48:40 +0000
237+++ tests/include/mir_test_doubles/mock_display.h 2015-03-27 12:44:37 +0000
238@@ -20,6 +20,7 @@
239 #define MIR_TEST_DOUBLES_MOCK_DISPLAY_H_
240
241 #include "mir/graphics/display.h"
242+#include "mir/graphics/display_configuration.h"
243 #include "mir/graphics/gl_context.h"
244 #include "mir/main_loop.h"
245 #include "mir_test/gmock_fixes.h"

Subscribers

People subscribed via source and target branches