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

Subscribers

People subscribed via source and target branches