Mir

Merge lp:~raof/mir/display-changer-callback-lifetime into lp:mir

Proposed by Chris Halse Rogers
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~raof/mir/display-changer-callback-lifetime
Merge into: lp:mir
Diff against target: 375 lines (+118/-104)
8 files modified
include/server/mir/scene/session_coordinator.h (+0/-2)
src/server/scene/default_configuration.cpp (+1/-2)
src/server/scene/mediating_display_changer.cpp (+97/-34)
src/server/scene/mediating_display_changer.h (+11/-1)
src/server/scene/session_manager.cpp (+0/-10)
src/server/scene/session_manager.h (+0/-3)
tests/unit-tests/scene/test_mediating_display_changer.cpp (+9/-9)
tests/unit-tests/scene/test_session_manager.cpp (+0/-43)
To merge this branch: bzr merge lp:~raof/mir/display-changer-callback-lifetime
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Alan Griffiths Needs Information
Chris Halse Rogers Needs Fixing
Review via email: mp+329241@code.launchpad.net

Commit message

ms::MediatingDisplayChanger: Ensure we live at least as long as our signal handlers.

MediatingDisplayChanger registers some handlers on the session_event_handler_register; these need to ensure that the display changer is actually live before invoking methods on it.

To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote :

For some reason which is absolutely opaque to me this appears to cause the testsuite to crash with an invalid read from 0x0 when *exiting* from ConnectedClientWithASurface::SetUp(), when run under Valgrind and under load.

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

Oh, nasty! Unlike some other listener patterns we have the SessionEventHandlerRegister has no way to unregister listeners.

Is this approach the best approach to resolving the problem this causes?

review: Needs Information
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4232
https://mir-jenkins.ubuntu.com/job/mir-ci/3560/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4879
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5094
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5083
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5083
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5083
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4916/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4916
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4916/artifact/output/*zip*/output.zip

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

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

- void add_listener(std::shared_ptr<SessionListener> const& listener) override;
- void remove_listener(std::shared_ptr<SessionListener> const& listener) override;
-

I guess this is an unrelated deletion of dead code?

Revision history for this message
Chris Halse Rogers (raof) wrote :

It's (hopefully) the most expedient. I also have a branch with much of the changes required to switch to a more classical observe with MultiplexingObserver done.

This was less effort. It, at least, would be, if it didn't mysteriously die under load.

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

> It's (hopefully) the most expedient. I also have a branch with much of the
> changes required to switch to a more classical observe with
> MultiplexingObserver done.
>
> This was less effort. It, at least, would be, if it didn't mysteriously die
> under load.

Well, using BasicObservers<> seems to both simplify the code and address the end-of-life issues:

    lp:~alan-griffiths/mir/rework-BroadcastingSessionEventSink/+merge/329255

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

We landed an alternative

Unmerged revisions

4232. By Chris Halse Rogers

ms::MediatingDisplayChanger: Ensure we live at least as long as our signal handlers.

MediatingDisplayChanger registers some handlers on the session_event_handler_register;
these need to ensure that the display changer is actually live before invoking methods on
it.

4231. By Chris Halse Rogers

ms::SessionCoordinator: Remove {add,remove}_listener methods.

These methods are used only by the tests which check their behaviour.

Sigh.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/server/mir/scene/session_coordinator.h'
--- include/server/mir/scene/session_coordinator.h 2017-07-28 17:00:43 +0000
+++ include/server/mir/scene/session_coordinator.h 2017-08-18 08:06:31 +0000
@@ -54,8 +54,6 @@
5454
55 virtual std::shared_ptr<Session> successor_of(std::shared_ptr<Session> const&) const = 0;55 virtual std::shared_ptr<Session> successor_of(std::shared_ptr<Session> const&) const = 0;
5656
57 virtual void add_listener(std::shared_ptr<SessionListener> const&) = 0;
58 virtual void remove_listener(std::shared_ptr<SessionListener> const&) = 0;
59protected:57protected:
60 SessionCoordinator() = default;58 SessionCoordinator() = default;
61 virtual ~SessionCoordinator() = default;59 virtual ~SessionCoordinator() = default;
6260
=== modified file 'src/server/scene/default_configuration.cpp'
--- src/server/scene/default_configuration.cpp 2017-07-28 17:00:43 +0000
+++ src/server/scene/default_configuration.cpp 2017-08-18 08:06:31 +0000
@@ -132,7 +132,7 @@
132 return mediating_display_changer(132 return mediating_display_changer(
133 [this]()133 [this]()
134 {134 {
135 return std::make_shared<ms::MediatingDisplayChanger>(135 return ms::MediatingDisplayChanger::create(
136 the_display(),136 the_display(),
137 the_compositor(),137 the_compositor(),
138 the_display_configuration_policy(),138 the_display_configuration_policy(),
@@ -142,7 +142,6 @@
142 the_display_configuration_observer(),142 the_display_configuration_observer(),
143 the_main_loop());143 the_main_loop());
144 });144 });
145
146}145}
147146
148std::shared_ptr<mf::DisplayChanger>147std::shared_ptr<mf::DisplayChanger>
149148
=== modified file 'src/server/scene/mediating_display_changer.cpp'
--- src/server/scene/mediating_display_changer.cpp 2017-08-09 15:03:31 +0000
+++ src/server/scene/mediating_display_changer.cpp 2017-08-18 08:06:31 +0000
@@ -124,6 +124,103 @@
124};124};
125}125}
126126
127std::shared_ptr<ms::MediatingDisplayChanger> ms::MediatingDisplayChanger::create(
128 std::shared_ptr<mg::Display> const& display,
129 std::shared_ptr<mc::Compositor> const& compositor,
130 std::shared_ptr<mg::DisplayConfigurationPolicy> const& display_configuration_policy,
131 std::shared_ptr<SessionContainer> const& session_container,
132 std::shared_ptr<SessionEventHandlerRegister> const& session_event_handler_register,
133 std::shared_ptr<ServerActionQueue> const& server_action_queue,
134 std::shared_ptr<mg::DisplayConfigurationObserver> const& observer,
135 std::shared_ptr<mt::AlarmFactory> const& alarm_factory)
136{
137 std::shared_ptr<ms::MediatingDisplayChanger> const result{
138 new ms::MediatingDisplayChanger{
139 display,
140 compositor,
141 display_configuration_policy,
142 session_container,
143 session_event_handler_register,
144 server_action_queue,
145 observer,
146 alarm_factory
147 }};
148
149 std::weak_ptr<ms::MediatingDisplayChanger> const weak_changer = result;
150
151 /*
152 * Caution! Reference cycle!
153 *
154 * result owns a reference to session_event_handler_register;
155 * if we capture a strong reference in the handler, then
156 * session_Event_handler_register will have a strong reference to
157 * result.
158 */
159 session_event_handler_register->register_focus_change_handler(
160 [weak_changer](std::shared_ptr<ms::Session> const& session)
161 {
162 auto const weak_session = std::weak_ptr<ms::Session>(session);
163 if (auto const changer = weak_changer.lock())
164 {
165 /*
166 * Caution! Bonus reference cycle!
167 *
168 * As before, changer owns a reference to server_action_queue.
169 */
170 changer->server_action_queue->enqueue(
171 changer.get(),
172 [weak_changer, weak_session]
173 {
174 if (auto const changer = weak_changer.lock())
175 {
176 if (auto const session = weak_session.lock())
177 {
178 changer->focus_change_handler(session);
179 }
180 }
181 });
182 }
183 });
184
185 session_event_handler_register->register_no_focus_handler(
186 [weak_changer]
187 {
188 if (auto const changer = weak_changer.lock())
189 {
190 changer->server_action_queue->enqueue(
191 changer.get(),
192 [weak_changer]
193 {
194 if (auto const changer = weak_changer.lock())
195 {
196 changer->no_focus_handler();
197 }
198 });
199 }
200 });
201
202 session_event_handler_register->register_session_stopping_handler(
203 [weak_changer](std::shared_ptr<ms::Session> const& session)
204 {
205 auto const weak_session = std::weak_ptr<ms::Session>(session);
206 if (auto const changer = weak_changer.lock())
207 {
208 changer->server_action_queue->enqueue(
209 changer.get(),
210 [weak_changer,weak_session]
211 {
212 if (auto const changer = weak_changer.lock())
213 {
214 if (auto const session = weak_session.lock())
215 changer->session_stopping_handler(session);
216 }
217 });
218 }
219 });
220
221 return result;
222}
223
127ms::MediatingDisplayChanger::MediatingDisplayChanger(224ms::MediatingDisplayChanger::MediatingDisplayChanger(
128 std::shared_ptr<mg::Display> const& display,225 std::shared_ptr<mg::Display> const& display,
129 std::shared_ptr<mc::Compositor> const& compositor,226 std::shared_ptr<mc::Compositor> const& compositor,
@@ -144,40 +241,6 @@
144 base_configuration_applied{true},241 base_configuration_applied{true},
145 alarm_factory{alarm_factory}242 alarm_factory{alarm_factory}
146{243{
147 session_event_handler_register->register_focus_change_handler(
148 [this](std::shared_ptr<ms::Session> const& session)
149 {
150 auto const weak_session = std::weak_ptr<ms::Session>(session);
151 this->server_action_queue->enqueue(
152 this,
153 [this,weak_session]
154 {
155 if (auto const session = weak_session.lock())
156 focus_change_handler(session);
157 });
158 });
159
160 session_event_handler_register->register_no_focus_handler(
161 [this]
162 {
163 this->server_action_queue->enqueue(
164 this,
165 [this] { no_focus_handler(); });
166 });
167
168 session_event_handler_register->register_session_stopping_handler(
169 [this](std::shared_ptr<ms::Session> const& session)
170 {
171 auto const weak_session = std::weak_ptr<ms::Session>(session);
172 this->server_action_queue->enqueue(
173 this,
174 [this,weak_session]
175 {
176 if (auto const session = weak_session.lock())
177 session_stopping_handler(session);
178 });
179 });
180
181 observer->initial_configuration(base_configuration_);244 observer->initial_configuration(base_configuration_);
182}245}
183246
184247
=== modified file 'src/server/scene/mediating_display_changer.h'
--- src/server/scene/mediating_display_changer.h 2017-07-28 17:00:43 +0000
+++ src/server/scene/mediating_display_changer.h 2017-08-18 08:06:31 +0000
@@ -55,7 +55,7 @@
55 public shell::DisplayConfigurationController55 public shell::DisplayConfigurationController
56{56{
57public:57public:
58 MediatingDisplayChanger(58 static std::shared_ptr<MediatingDisplayChanger> create(
59 std::shared_ptr<graphics::Display> const& display,59 std::shared_ptr<graphics::Display> const& display,
60 std::shared_ptr<compositor::Compositor> const& compositor,60 std::shared_ptr<compositor::Compositor> const& compositor,
61 std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,61 std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,
@@ -92,6 +92,16 @@
92 void set_base_configuration(std::shared_ptr<graphics::DisplayConfiguration> const &conf) override;92 void set_base_configuration(std::shared_ptr<graphics::DisplayConfiguration> const &conf) override;
9393
94private:94private:
95 MediatingDisplayChanger(
96 std::shared_ptr<graphics::Display> const& display,
97 std::shared_ptr<compositor::Compositor> const& compositor,
98 std::shared_ptr<graphics::DisplayConfigurationPolicy> const& display_configuration_policy,
99 std::shared_ptr<SessionContainer> const& session_container,
100 std::shared_ptr<SessionEventHandlerRegister> const& session_event_handler_register,
101 std::shared_ptr<ServerActionQueue> const& server_action_queue,
102 std::shared_ptr<graphics::DisplayConfigurationObserver> const& observer,
103 std::shared_ptr<time::AlarmFactory> const& alarm_factory);
104
95 void focus_change_handler(std::shared_ptr<Session> const& session);105 void focus_change_handler(std::shared_ptr<Session> const& session);
96 void no_focus_handler();106 void no_focus_handler();
97 void session_stopping_handler(std::shared_ptr<Session> const& session);107 void session_stopping_handler(std::shared_ptr<Session> const& session);
98108
=== modified file 'src/server/scene/session_manager.cpp'
--- src/server/scene/session_manager.cpp 2017-07-28 17:00:43 +0000
+++ src/server/scene/session_manager.cpp 2017-08-18 08:06:31 +0000
@@ -186,13 +186,3 @@
186{186{
187 return app_container->successor_of(session);187 return app_container->successor_of(session);
188}188}
189
190void ms::SessionManager::add_listener(std::shared_ptr<SessionListener> const& listener)
191{
192 observers->register_interest(listener);
193}
194
195void ms::SessionManager::remove_listener(std::shared_ptr<SessionListener> const& listener)
196{
197 observers->unregister_interest(*listener);
198}
199189
=== modified file 'src/server/scene/session_manager.h'
--- src/server/scene/session_manager.h 2017-07-28 17:00:43 +0000
+++ src/server/scene/session_manager.h 2017-08-18 08:06:31 +0000
@@ -77,9 +77,6 @@
77 void set_focus_to(std::shared_ptr<Session> const& focus) override;77 void set_focus_to(std::shared_ptr<Session> const& focus) override;
78 void unset_focus() override;78 void unset_focus() override;
7979
80 void add_listener(std::shared_ptr<SessionListener> const& listener) override;
81 void remove_listener(std::shared_ptr<SessionListener> const& listener) override;
82
83protected:80protected:
84 SessionManager(const SessionManager&) = delete;81 SessionManager(const SessionManager&) = delete;
85 SessionManager& operator=(const SessionManager&) = delete;82 SessionManager& operator=(const SessionManager&) = delete;
8683
=== modified file 'tests/unit-tests/scene/test_mediating_display_changer.cpp'
--- tests/unit-tests/scene/test_mediating_display_changer.cpp 2017-08-09 11:30:59 +0000
+++ tests/unit-tests/scene/test_mediating_display_changer.cpp 2017-08-18 08:06:31 +0000
@@ -140,7 +140,7 @@
140 {140 {
141 using namespace testing;141 using namespace testing;
142142
143 changer = std::make_shared<ms::MediatingDisplayChanger>(143 changer = ms::MediatingDisplayChanger::create(
144 mt::fake_shared(mock_display),144 mt::fake_shared(mock_display),
145 mt::fake_shared(mock_compositor),145 mt::fake_shared(mock_compositor),
146 mt::fake_shared(mock_conf_policy),146 mt::fake_shared(mock_conf_policy),
@@ -688,7 +688,7 @@
688 stub_session_container.insert_session(session1);688 stub_session_container.insert_session(session1);
689 stub_session_container.insert_session(session2);689 stub_session_container.insert_session(session2);
690690
691 ms::MediatingDisplayChanger display_changer(691 auto display_changer = ms::MediatingDisplayChanger::create(
692 mt::fake_shared(mock_display),692 mt::fake_shared(mock_display),
693 mt::fake_shared(mock_compositor),693 mt::fake_shared(mock_compositor),
694 mt::fake_shared(mock_conf_policy),694 mt::fake_shared(mock_conf_policy),
@@ -706,11 +706,11 @@
706 Mock::VerifyAndClearExpectations(&mock_server_action_queue);706 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
707707
708 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));708 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));
709 display_changer.configure(session1, conf);709 display_changer->configure(session1, conf);
710 Mock::VerifyAndClearExpectations(&mock_server_action_queue);710 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
711711
712 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));712 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));
713 display_changer.configure_for_hardware_change(conf);713 display_changer->configure_for_hardware_change(conf);
714 Mock::VerifyAndClearExpectations(&mock_server_action_queue);714 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
715715
716 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));716 EXPECT_CALL(mock_server_action_queue, enqueue(owner, _));
@@ -722,11 +722,11 @@
722 Mock::VerifyAndClearExpectations(&mock_server_action_queue);722 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
723723
724 EXPECT_CALL(mock_server_action_queue, pause_processing_for(owner));724 EXPECT_CALL(mock_server_action_queue, pause_processing_for(owner));
725 display_changer.pause_display_config_processing();725 display_changer->pause_display_config_processing();
726 Mock::VerifyAndClearExpectations(&mock_server_action_queue);726 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
727727
728 EXPECT_CALL(mock_server_action_queue, resume_processing_for(owner));728 EXPECT_CALL(mock_server_action_queue, resume_processing_for(owner));
729 display_changer.resume_display_config_processing();729 display_changer->resume_display_config_processing();
730 Mock::VerifyAndClearExpectations(&mock_server_action_queue);730 Mock::VerifyAndClearExpectations(&mock_server_action_queue);
731}731}
732732
@@ -742,7 +742,7 @@
742 stub_session_container.insert_session(active_session);742 stub_session_container.insert_session(active_session);
743 stub_session_container.insert_session(inactive_session);743 stub_session_container.insert_session(inactive_session);
744744
745 ms::MediatingDisplayChanger display_changer(745 auto display_changer = ms::MediatingDisplayChanger::create(
746 mt::fake_shared(mock_display),746 mt::fake_shared(mock_display),
747 mt::fake_shared(mock_compositor),747 mt::fake_shared(mock_compositor),
748 mt::fake_shared(mock_conf_policy),748 mt::fake_shared(mock_conf_policy),
@@ -758,7 +758,7 @@
758758
759 EXPECT_CALL(mock_server_action_queue, enqueue(_, _)).Times(0);759 EXPECT_CALL(mock_server_action_queue, enqueue(_, _)).Times(0);
760760
761 display_changer.configure(inactive_session, conf);761 display_changer->configure(inactive_session, conf);
762}762}
763763
764TEST_F(MediatingDisplayChangerTest, set_base_configuration_doesnt_override_session_configuration)764TEST_F(MediatingDisplayChangerTest, set_base_configuration_doesnt_override_session_configuration)
@@ -871,7 +871,7 @@
871 MOCK_METHOD1(base_configuration_updated, void (std::shared_ptr<mg::DisplayConfiguration const> const& base_config));871 MOCK_METHOD1(base_configuration_updated, void (std::shared_ptr<mg::DisplayConfiguration const> const& base_config));
872 } display_configuration_observer;872 } display_configuration_observer;
873873
874 changer = std::make_shared<ms::MediatingDisplayChanger>(874 changer = ms::MediatingDisplayChanger::create(
875 mt::fake_shared(mock_display),875 mt::fake_shared(mock_display),
876 mt::fake_shared(mock_compositor),876 mt::fake_shared(mock_compositor),
877 mt::fake_shared(mock_conf_policy),877 mt::fake_shared(mock_conf_policy),
878878
=== modified file 'tests/unit-tests/scene/test_session_manager.cpp'
--- tests/unit-tests/scene/test_session_manager.cpp 2017-07-28 17:00:43 +0000
+++ tests/unit-tests/scene/test_session_manager.cpp 2017-08-18 08:06:31 +0000
@@ -184,49 +184,6 @@
184 session_manager.close_session(session);184 session_manager.close_session(session);
185}185}
186186
187TEST_F(SessionManagerSessionListenerSetup, additional_listeners_receive_session_callbacks)
188{
189 using namespace ::testing;
190
191 auto additional_listener = std::make_shared<testing::NiceMock<mtd::MockSessionListener>>();
192 EXPECT_CALL(*additional_listener, starting(_)).Times(1);
193 EXPECT_CALL(*additional_listener, stopping(_)).Times(1);
194
195 session_manager.add_listener(additional_listener);
196 auto session = session_manager.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>());
197 session_manager.close_session(session);
198}
199
200TEST_F(SessionManagerSessionListenerSetup, additional_listeners_receive_focus_changes)
201{
202 using namespace ::testing;
203
204 auto additional_listener = std::make_shared<testing::NiceMock<mtd::MockSessionListener>>();
205 EXPECT_CALL(*additional_listener, starting(_)).Times(1);
206 EXPECT_CALL(*additional_listener, focused(_)).Times(1);
207 EXPECT_CALL(*additional_listener, unfocused()).Times(1);
208
209 session_manager.add_listener(additional_listener);
210 auto session = session_manager.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>());
211 session_manager.set_focus_to(session);
212 session_manager.unset_focus();
213}
214
215TEST_F(SessionManagerSessionListenerSetup, additional_listeners_receive_surface_creation)
216{
217 using namespace ::testing;
218 mtd::NullEventSink event_sink;
219 auto additional_listener = std::make_shared<testing::NiceMock<mtd::MockSessionListener>>();
220 EXPECT_CALL(*additional_listener, starting(_)).Times(1);
221 EXPECT_CALL(*additional_listener, surface_created(_,_)).Times(1);
222
223 session_manager.add_listener(additional_listener);
224 auto session = session_manager.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>());
225 auto bs = session->create_buffer_stream(
226 mg::BufferProperties{{640, 480}, mir_pixel_format_abgr_8888, mg::BufferUsage::hardware});
227 session->create_surface(ms::SurfaceCreationParameters().with_buffer_stream(bs), mt::fake_shared(event_sink));
228}
229
230namespace187namespace
231{188{
232struct SessionManagerSessionEventsSetup : public testing::Test189struct SessionManagerSessionEventsSetup : public testing::Test

Subscribers

People subscribed via source and target branches