Mir

Merge lp:~kdub/mir/fix-1556045 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 3462
Proposed branch: lp:~kdub/mir/fix-1556045
Merge into: lp:mir
Diff against target: 194 lines (+82/-54)
1 file modified
tests/acceptance-tests/test_client_surface_visibility.cpp (+82/-54)
To merge this branch: bzr merge lp:~kdub/mir/fix-1556045
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Chris Halse Rogers Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+291938@code.launchpad.net

Commit message

fix: LP #1556045 which was blocking CI. problem was in the test fixture.

Description of the change

fix: LP #1556045 which was blocking CI. problem was in the test fixture.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3462
https://mir-jenkins.ubuntu.com/job/mir-ci/840/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/851
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/888
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/879
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/879
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/861
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/861/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/861
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/861/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/861
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/861/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/861
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/861/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/861
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/861/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/840/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ testing::NiceMock<MockVisibilityCallback>& mock_callback)

Could use the interface?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_client_surface_visibility.cpp'
2--- tests/acceptance-tests/test_client_surface_visibility.cpp 2016-04-11 16:56:16 +0000
3+++ tests/acceptance-tests/test_client_surface_visibility.cpp 2016-04-14 19:51:14 +0000
4@@ -45,11 +45,8 @@
5 class StoringShell : public msh::ShellWrapper
6 {
7 public:
8- StoringShell(
9- std::shared_ptr<msh::Shell> const& wrapped,
10- std::shared_ptr<msh::SurfaceStack> const surface_stack) :
11- msh::ShellWrapper{wrapped},
12- surface_stack{surface_stack}
13+ StoringShell(std::shared_ptr<msh::Shell> const& wrapped) :
14+ msh::ShellWrapper{wrapped}
15 {}
16
17 mf::SurfaceId create_surface(
18@@ -71,12 +68,10 @@
19
20 void raise(int index)
21 {
22- surface_stack->raise(surface(index));
23+ wrapped->raise_surface(nullptr, surface(index), 0);
24 }
25
26- using msh::ShellWrapper::raise;
27 private:
28- std::shared_ptr<msh::SurfaceStack> const surface_stack;
29 std::vector<std::weak_ptr<ms::Surface>> surfaces;
30
31 };
32@@ -94,56 +89,103 @@
33 if (mir_surface_event_get_attribute(sev) != mir_surface_attrib_visibility)
34 return;
35
36- auto const mock_visibility_callback =
37+ auto const mock_callback =
38 reinterpret_cast<testing::NiceMock<MockVisibilityCallback>*>(ctx);
39- mock_visibility_callback->handle(
40+ mock_callback->handle(
41 surface,
42 static_cast<MirSurfaceVisibility>(mir_surface_event_get_attribute_value(sev)));
43 }
44
45-struct MirSurfaceVisibilityEvent : mtf::ConnectedClientWithASurface
46-{
47-
48+MirSurface* create_surface(MirConnection* connection, geom::Size size,
49+ testing::NiceMock<MockVisibilityCallback>& mock_callback)
50+{
51+ auto const spec = mir_connection_create_spec_for_normal_surface(
52+ connection, size.width.as_int(), size.height.as_int(), mir_pixel_format_bgr_888);
53+ mir_surface_spec_set_name(spec, "ConnectedClientWithASurfaceFixtureSurface");
54+ mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_hardware);
55+ mir_surface_spec_set_event_handler(spec, &event_callback, &mock_callback);
56+ auto surface = mir_surface_create_sync(spec);
57+ mir_surface_spec_release(spec);
58+ return surface;
59+}
60+
61+struct Surface
62+{
63+ Surface(MirConnection* connection, geom::Size size) :
64+ surface(create_surface(connection, size, callback))
65+ {
66+ wait_for_visible();
67+ }
68+
69+ ~Surface()
70+ {
71+ mir_surface_release_sync(surface);
72+ }
73+
74+ void expect_surface_visibility_event_after(
75+ MirSurfaceVisibility visibility,
76+ std::function<void()> const& action)
77+ {
78+ using namespace testing;
79+
80+ mt::Signal event_received;
81+
82+ Mock::VerifyAndClearExpectations(&callback);
83+
84+ EXPECT_CALL(callback, handle(surface, visibility))
85+ .WillOnce(DoAll(Invoke([&visibility](MirSurface *s, MirSurfaceVisibility)
86+ {
87+ EXPECT_EQ(visibility, mir_surface_get_visibility(s));
88+ }), mt::WakeUp(&event_received)));
89+
90+ action();
91+
92+ event_received.wait_for(std::chrono::seconds{2});
93+
94+ Mock::VerifyAndClearExpectations(&callback);
95+ }
96+
97+private:
98+ void wait_for_visible()
99+ {
100+ expect_surface_visibility_event_after(
101+ mir_surface_visibility_exposed,
102+ [this]
103+ {
104+ mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
105+ });
106+ }
107+
108+ testing::NiceMock<MockVisibilityCallback> callback;
109+ MirSurface* surface;
110+};
111+
112+struct MirSurfaceVisibilityEvent : mtf::ConnectedClientHeadlessServer
113+{
114 void SetUp() override
115 {
116 server.wrap_shell([&](std::shared_ptr<msh::Shell> const& wrapped)
117 {
118- auto const result = std::make_shared<StoringShell>(wrapped, server.the_surface_stack());
119+ auto const result = std::make_shared<StoringShell>(wrapped);
120 shell = result;
121 return result;
122 });
123
124- mtf::ConnectedClientWithASurface::SetUp();
125-
126- mir_surface_set_event_handler(surface, &event_callback, &mock_visibility_callback);
127-
128- // Swap enough buffers to ensure compositor threads are into run loop
129- for (auto i = 0; i != 11; ++i)
130- mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
131+ mtf::ConnectedClientHeadlessServer::SetUp();
132+ surface = std::make_unique<Surface>(connection, small_size);
133 }
134
135 void TearDown() override
136 {
137- // Don't call ConnectedClientWithASurface::TearDown() - the sequence matters
138- mir_surface_release_sync(surface);
139- if (second_surface)
140- mir_surface_release_sync(second_surface);
141-
142+ surface.reset();
143+ second_surface.reset();
144 mtf::ConnectedClientHeadlessServer::TearDown();
145 }
146
147 void create_larger_surface_on_top()
148 {
149- auto spec = mir_connection_create_spec_for_normal_surface(connection, 800, 600, mir_pixel_format_bgr_888);
150-
151- second_surface = mir_surface_create_sync(spec);
152- ASSERT_TRUE(mir_surface_is_valid(second_surface));
153-
154- mir_surface_spec_release(spec);
155-
156+ second_surface = std::make_unique<Surface>(connection, large_size);
157 shell.lock()->raise(1);
158-
159- mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(second_surface));
160 }
161
162 std::shared_ptr<ms::Surface> server_surface(size_t index)
163@@ -170,27 +212,13 @@
164 MirSurfaceVisibility visibility,
165 std::function<void()> const& action)
166 {
167- using namespace testing;
168-
169- mt::Signal event_received;
170-
171- Mock::VerifyAndClearExpectations(&mock_visibility_callback);
172-
173- EXPECT_CALL(mock_visibility_callback, handle(surface, visibility))
174- .WillOnce(DoAll(Invoke([&visibility](MirSurface *s, MirSurfaceVisibility)
175- {
176- EXPECT_EQ(visibility, mir_surface_get_visibility(s));
177- }), mt::WakeUp(&event_received)));
178-
179- action();
180-
181- event_received.wait_for(std::chrono::seconds{2});
182-
183- Mock::VerifyAndClearExpectations(&mock_visibility_callback);
184+ surface->expect_surface_visibility_event_after(visibility, action);
185 }
186
187- MirSurface* second_surface = nullptr;
188- testing::NiceMock<MockVisibilityCallback> mock_visibility_callback;
189+ geom::Size const small_size {640, 480};
190+ geom::Size const large_size {800, 600};
191+ std::unique_ptr<Surface> surface;
192+ std::unique_ptr<Surface> second_surface;
193 std::weak_ptr<StoringShell> shell;
194 };
195

Subscribers

People subscribed via source and target branches