Mir

Merge lp:~alan-griffiths/mir/fix-1276704 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1381
Proposed branch: lp:~alan-griffiths/mir/fix-1276704
Merge into: lp:mir
Diff against target: 903 lines (+194/-91)
24 files modified
examples/demo-inprocess-surface-client/inprocess_egl_client.cpp (+4/-2)
include/server/mir/frontend/shell.h (+8/-2)
include/server/mir/shell/session.h (+6/-5)
include/test/mir_test_doubles/mock_shell.h (+6/-3)
include/test/mir_test_doubles/mock_shell_session.h (+2/-1)
include/test/mir_test_doubles/stub_ipc_factory.h (+2/-2)
include/test/mir_test_doubles/stub_shell.h (+1/-1)
include/test/mir_test_doubles/stub_shell_session.h (+6/-1)
src/server/frontend/default_configuration.cpp (+5/-2)
src/server/frontend/protobuf_ipc_factory.h (+7/-2)
src/server/frontend/protobuf_session_creator.cpp (+2/-2)
src/server/frontend/session_mediator.cpp (+4/-2)
src/server/frontend/session_mediator.h (+3/-1)
src/server/scene/application_session.cpp (+8/-1)
src/server/scene/application_session.h (+4/-1)
src/server/scene/session_manager.cpp (+6/-4)
src/server/scene/session_manager.h (+5/-2)
tests/integration-tests/test_session.cpp (+2/-1)
tests/integration-tests/test_session_manager.cpp (+6/-6)
tests/unit-tests/frontend/test_session_mediator.cpp (+5/-5)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+1/-1)
tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+2/-2)
tests/unit-tests/scene/test_application_session.cpp (+91/-34)
tests/unit-tests/scene/test_session_manager.cpp (+8/-8)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1276704
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+205357@code.launchpad.net

Commit message

frontend, shell: provide the client process ID in the shell::Session interface (LP: #1276704)

Description of the change

frontend, shell: provide the client process ID in the shell::Session interface

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Gives me what I need, thanks!

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I haven't reviewed it, but it seems we're desperate to push this to archive, so top-approving.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp'
--- examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-01-13 06:12:33 +0000
+++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -41,6 +41,8 @@
4141
42#include <xkbcommon/xkbcommon-keysyms.h>42#include <xkbcommon/xkbcommon-keysyms.h>
4343
44#include <unistd.h>
45
44#include <functional>46#include <functional>
4547
46#include <assert.h>48#include <assert.h>
@@ -93,7 +95,7 @@
93 .of_size(surface_size)95 .of_size(surface_size)
94 .of_buffer_usage(mg::BufferUsage::hardware)96 .of_buffer_usage(mg::BufferUsage::hardware)
95 .of_pixel_format(mir_pixel_format_argb_8888);97 .of_pixel_format(mir_pixel_format_argb_8888);
96 auto session = shell->open_session("Inprocess client", std::make_shared<NullEventSink>());98 auto session = shell->open_session(getpid(), "Inprocess client", std::make_shared<NullEventSink>());
97 // TODO: Why do we get an ID? ~racarr99 // TODO: Why do we get an ID? ~racarr
98 auto surface = session->get_surface(shell->create_surface_for(session, params));100 auto surface = session->get_surface(shell->create_surface_for(session, params));
99101
100102
=== modified file 'include/server/mir/frontend/shell.h'
--- include/server/mir/frontend/shell.h 2014-01-13 06:12:33 +0000
+++ include/server/mir/frontend/shell.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -20,6 +20,9 @@
20#define MIR_FRONTEND_SHELL_H_20#define MIR_FRONTEND_SHELL_H_
2121
22#include "mir/frontend/surface_id.h"22#include "mir/frontend/surface_id.h"
23
24#include <sys/types.h>
25
23#include <memory>26#include <memory>
2427
25namespace mir28namespace mir
@@ -39,7 +42,10 @@
39 virtual ~Shell() = default;42 virtual ~Shell() = default;
4043
41 virtual std::shared_ptr<Session> open_session(44 virtual std::shared_ptr<Session> open_session(
42 std::string const& name, std::shared_ptr<EventSink> const& sink) = 0;45 pid_t client_pid,
46 std::string const& name,
47 std::shared_ptr<EventSink> const& sink) = 0;
48
43 virtual void close_session(std::shared_ptr<Session> const& session) = 0;49 virtual void close_session(std::shared_ptr<Session> const& session) = 0;
4450
45 virtual SurfaceId create_surface_for(std::shared_ptr<Session> const& session,51 virtual SurfaceId create_surface_for(std::shared_ptr<Session> const& session,
4652
=== modified file 'include/server/mir/shell/session.h'
--- include/server/mir/shell/session.h 2014-01-13 06:12:33 +0000
+++ include/server/mir/shell/session.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -7,11 +7,11 @@
7 *7 *
8 * This program is distributed in the hope that it will be useful,8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.11 * GNU General Public License for more details.
12 *12 *
13 * You should have received a copy of the GNU General Public License13 * 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/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored By: Robert Carr <racarr@canonical.com>16 * Authored By: Robert Carr <racarr@canonical.com>
17 */17 */
@@ -22,9 +22,10 @@
22#include "mir/frontend/session.h"22#include "mir/frontend/session.h"
23#include "mir/shell/snapshot.h"23#include "mir/shell/snapshot.h"
2424
25#include <sys/types.h>
26
25namespace mir27namespace mir
26{28{
27
28namespace shell29namespace shell
29{30{
30class Surface;31class Surface;
@@ -34,12 +35,12 @@
34public:35public:
35 virtual std::string name() const = 0;36 virtual std::string name() const = 0;
36 virtual void force_requests_to_complete() = 0;37 virtual void force_requests_to_complete() = 0;
38 virtual pid_t process_id() const = 0;
3739
38 virtual void take_snapshot(SnapshotCallback const& snapshot_taken) = 0;40 virtual void take_snapshot(SnapshotCallback const& snapshot_taken) = 0;
39 virtual std::shared_ptr<Surface> default_surface() const = 0;41 virtual std::shared_ptr<Surface> default_surface() const = 0;
40 virtual void set_lifecycle_state(MirLifecycleState state) = 0;42 virtual void set_lifecycle_state(MirLifecycleState state) = 0;
41};43};
42
43}44}
44}45}
4546
4647
=== modified file 'include/test/mir_test_doubles/mock_shell.h'
--- include/test/mir_test_doubles/mock_shell.h 2013-08-28 03:41:48 +0000
+++ include/test/mir_test_doubles/mock_shell.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -34,8 +34,11 @@
3434
35struct MockShell : public frontend::Shell35struct MockShell : public frontend::Shell
36{36{
37 MOCK_METHOD2(open_session, std::shared_ptr<frontend::Session>(37 MOCK_METHOD3(open_session, std::shared_ptr<frontend::Session>(
38 std::string const&, std::shared_ptr<frontend::EventSink> const&));38 pid_t client_pid,
39 std::string const&,
40 std::shared_ptr<frontend::EventSink> const&));
41
39 MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&));42 MOCK_METHOD1(close_session, void(std::shared_ptr<frontend::Session> const&));
4043
41 MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, shell::SurfaceCreationParameters const&));44 MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, shell::SurfaceCreationParameters const&));
4245
=== modified file 'include/test/mir_test_doubles/mock_shell_session.h'
--- include/test/mir_test_doubles/mock_shell_session.h 2014-01-13 06:12:33 +0000
+++ include/test/mir_test_doubles/mock_shell_session.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -42,6 +42,7 @@
42 MOCK_CONST_METHOD0(default_surface, std::shared_ptr<shell::Surface>());42 MOCK_CONST_METHOD0(default_surface, std::shared_ptr<shell::Surface>());
4343
44 MOCK_CONST_METHOD0(name, std::string());44 MOCK_CONST_METHOD0(name, std::string());
45 MOCK_CONST_METHOD0(process_id, pid_t());
45 MOCK_METHOD0(force_requests_to_complete, void());46 MOCK_METHOD0(force_requests_to_complete, void());
4647
47 MOCK_METHOD0(hide, void());48 MOCK_METHOD0(hide, void());
4849
=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
--- include/test/mir_test_doubles/stub_ipc_factory.h 2014-01-21 06:27:40 +0000
+++ include/test/mir_test_doubles/stub_ipc_factory.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -41,7 +41,7 @@
41 }41 }
4242
43 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(43 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
44 std::shared_ptr<frontend::EventSink> const&, bool) override44 pid_t, std::shared_ptr<frontend::EventSink> const&, bool) override
45 {45 {
46 return server;46 return server;
47 }47 }
4848
=== modified file 'include/test/mir_test_doubles/stub_shell.h'
--- include/test/mir_test_doubles/stub_shell.h 2013-08-28 03:41:48 +0000
+++ include/test/mir_test_doubles/stub_shell.h 2014-02-07 14:29:43 +0000
@@ -34,7 +34,7 @@
34 StubShell() : stub_session(std::make_shared<StubSession>())34 StubShell() : stub_session(std::make_shared<StubSession>())
35 {35 {
36 }36 }
37 std::shared_ptr<frontend::Session> open_session(std::string const& /* name */, std::shared_ptr<frontend::EventSink> const& /* sink */) override37 std::shared_ptr<frontend::Session> open_session(pid_t, std::string const& /* name */, std::shared_ptr<frontend::EventSink> const& /* sink */) override
38 {38 {
39 return stub_session;39 return stub_session;
40 }40 }
4141
=== modified file 'include/test/mir_test_doubles/stub_shell_session.h'
--- include/test/mir_test_doubles/stub_shell_session.h 2014-01-13 06:12:33 +0000
+++ include/test/mir_test_doubles/stub_shell_session.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -45,6 +45,11 @@
45 {45 {
46 return std::string();46 return std::string();
47 }47 }
48 pid_t process_id() const override
49 {
50 return -1;
51 }
52
48 void force_requests_to_complete() override53 void force_requests_to_complete() override
49 {54 {
50 }55 }
5156
=== modified file 'src/server/frontend/default_configuration.cpp'
--- src/server/frontend/default_configuration.cpp 2014-01-30 13:27:59 +0000
+++ src/server/frontend/default_configuration.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -64,7 +64,9 @@
64 std::shared_ptr<mf::Screencast> const screencast;64 std::shared_ptr<mf::Screencast> const screencast;
6565
66 virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(66 virtual std::shared_ptr<mir::protobuf::DisplayServer> make_ipc_server(
67 std::shared_ptr<mf::EventSink> const& sink, bool authorized_to_resize_display)67 pid_t client_pid,
68 std::shared_ptr<mf::EventSink> const& sink,
69 bool authorized_to_resize_display) override
68 {70 {
69 std::shared_ptr<mf::DisplayChanger> changer;71 std::shared_ptr<mf::DisplayChanger> changer;
70 if(authorized_to_resize_display)72 if(authorized_to_resize_display)
@@ -77,6 +79,7 @@
77 }79 }
7880
79 return std::make_shared<mf::SessionMediator>(81 return std::make_shared<mf::SessionMediator>(
82 client_pid,
80 shell,83 shell,
81 graphics_platform,84 graphics_platform,
82 changer,85 changer,
8386
=== modified file 'src/server/frontend/protobuf_ipc_factory.h'
--- src/server/frontend/protobuf_ipc_factory.h 2014-01-21 06:27:40 +0000
+++ src/server/frontend/protobuf_ipc_factory.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -19,6 +19,8 @@
19#ifndef MIR_FRONTEND_PROTOBUF_IPC_FACTORY_H_19#ifndef MIR_FRONTEND_PROTOBUF_IPC_FACTORY_H_
20#define MIR_FRONTEND_PROTOBUF_IPC_FACTORY_H_20#define MIR_FRONTEND_PROTOBUF_IPC_FACTORY_H_
2121
22#include <sys/types.h>
23
22#include <memory>24#include <memory>
2325
24namespace mir26namespace mir
@@ -37,7 +39,10 @@
37{39{
38public:40public:
39 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(41 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
40 std::shared_ptr<EventSink> const& sink, bool authorized_to_resize_display) = 0;42 pid_t client_pid,
43 std::shared_ptr<EventSink> const& sink,
44 bool authorized_to_resize_display) = 0;
45
41 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;46 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;
4247
43protected:48protected:
4449
=== modified file 'src/server/frontend/protobuf_session_creator.cpp'
--- src/server/frontend/protobuf_session_creator.cpp 2014-01-22 15:54:11 +0000
+++ src/server/frontend/protobuf_session_creator.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -69,7 +69,7 @@
69 auto const event_sink = std::make_shared<detail::EventSender>(messenger);69 auto const event_sink = std::make_shared<detail::EventSender>(messenger);
70 auto const msg_processor = create_processor(70 auto const msg_processor = create_processor(
71 message_sender,71 message_sender,
72 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),72 ipc_factory->make_ipc_server(client_pid, event_sink, authorized_to_resize_display),
73 report);73 report);
7474
75 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);75 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);
7676
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2014-02-06 09:51:46 +0000
+++ src/server/frontend/session_mediator.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -56,6 +56,7 @@
56namespace geom = mir::geometry;56namespace geom = mir::geometry;
5757
58mf::SessionMediator::SessionMediator(58mf::SessionMediator::SessionMediator(
59 pid_t client_pid,
59 std::shared_ptr<frontend::Shell> const& shell,60 std::shared_ptr<frontend::Shell> const& shell,
60 std::shared_ptr<graphics::Platform> const & graphics_platform,61 std::shared_ptr<graphics::Platform> const & graphics_platform,
61 std::shared_ptr<mf::DisplayChanger> const& display_changer,62 std::shared_ptr<mf::DisplayChanger> const& display_changer,
@@ -64,6 +65,7 @@
64 std::shared_ptr<EventSink> const& sender,65 std::shared_ptr<EventSink> const& sender,
65 std::shared_ptr<ResourceCache> const& resource_cache,66 std::shared_ptr<ResourceCache> const& resource_cache,
66 std::shared_ptr<Screencast> const& screencast) :67 std::shared_ptr<Screencast> const& screencast) :
68 client_pid(client_pid),
67 shell(shell),69 shell(shell),
68 graphics_platform(graphics_platform),70 graphics_platform(graphics_platform),
69 surface_pixel_formats(surface_pixel_formats),71 surface_pixel_formats(surface_pixel_formats),
@@ -95,7 +97,7 @@
9597
96 {98 {
97 std::unique_lock<std::mutex> lock(session_mutex);99 std::unique_lock<std::mutex> lock(session_mutex);
98 weak_session = shell->open_session(request->application_name(), event_sink);100 weak_session = shell->open_session(client_pid, request->application_name(), event_sink);
99 }101 }
100102
101 auto ipc_package = graphics_platform->get_ipc_package();103 auto ipc_package = graphics_platform->get_ipc_package();
102104
=== modified file 'src/server/frontend/session_mediator.h'
--- src/server/frontend/session_mediator.h 2014-02-06 09:51:46 +0000
+++ src/server/frontend/session_mediator.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -60,6 +60,7 @@
60{60{
61public:61public:
62 SessionMediator(62 SessionMediator(
63 pid_t client_pid,
63 std::shared_ptr<Shell> const& shell,64 std::shared_ptr<Shell> const& shell,
64 std::shared_ptr<graphics::Platform> const& graphics_platform,65 std::shared_ptr<graphics::Platform> const& graphics_platform,
65 std::shared_ptr<frontend::DisplayChanger> const& display_changer,66 std::shared_ptr<frontend::DisplayChanger> const& display_changer,
@@ -135,6 +136,7 @@
135 bool need_full_ipc);136 bool need_full_ipc);
136137
137 void advance_buffer(SurfaceId surf_id, Surface& surface, std::function<void(graphics::Buffer*, bool)> complete);138 void advance_buffer(SurfaceId surf_id, Surface& surface, std::function<void(graphics::Buffer*, bool)> complete);
139 pid_t client_pid;
138 std::shared_ptr<Shell> const shell;140 std::shared_ptr<Shell> const shell;
139 std::shared_ptr<graphics::Platform> const graphics_platform;141 std::shared_ptr<graphics::Platform> const graphics_platform;
140142
141143
=== modified file 'src/server/scene/application_session.cpp'
--- src/server/scene/application_session.cpp 2014-01-13 06:12:33 +0000
+++ src/server/scene/application_session.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -37,11 +37,13 @@
3737
38ms::ApplicationSession::ApplicationSession(38ms::ApplicationSession::ApplicationSession(
39 std::shared_ptr<msh::SurfaceFactory> const& surface_factory,39 std::shared_ptr<msh::SurfaceFactory> const& surface_factory,
40 pid_t pid,
40 std::string const& session_name,41 std::string const& session_name,
41 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,42 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
42 std::shared_ptr<msh::SessionListener> const& session_listener,43 std::shared_ptr<msh::SessionListener> const& session_listener,
43 std::shared_ptr<mf::EventSink> const& sink) :44 std::shared_ptr<mf::EventSink> const& sink) :
44 surface_factory(surface_factory),45 surface_factory(surface_factory),
46 pid(pid),
45 session_name(session_name),47 session_name(session_name),
46 snapshot_strategy(snapshot_strategy),48 snapshot_strategy(snapshot_strategy),
47 session_listener(session_listener),49 session_listener(session_listener),
@@ -125,6 +127,11 @@
125 return session_name;127 return session_name;
126}128}
127129
130pid_t ms::ApplicationSession::process_id() const
131{
132 return pid;
133}
134
128void ms::ApplicationSession::force_requests_to_complete()135void ms::ApplicationSession::force_requests_to_complete()
129{136{
130 std::unique_lock<std::mutex> lock(surfaces_mutex);137 std::unique_lock<std::mutex> lock(surfaces_mutex);
131138
=== modified file 'src/server/scene/application_session.h'
--- src/server/scene/application_session.h 2014-01-13 06:12:33 +0000
+++ src/server/scene/application_session.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -45,6 +45,7 @@
45public:45public:
46 ApplicationSession(46 ApplicationSession(
47 std::shared_ptr<shell::SurfaceFactory> const& surface_factory,47 std::shared_ptr<shell::SurfaceFactory> const& surface_factory,
48 pid_t pid,
48 std::string const& session_name,49 std::string const& session_name,
49 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,50 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
50 std::shared_ptr<shell::SessionListener> const& session_listener,51 std::shared_ptr<shell::SessionListener> const& session_listener,
@@ -60,6 +61,7 @@
60 std::shared_ptr<shell::Surface> default_surface() const;61 std::shared_ptr<shell::Surface> default_surface() const;
6162
62 std::string name() const;63 std::string name() const;
64 pid_t process_id() const override;
6365
64 void force_requests_to_complete();66 void force_requests_to_complete();
6567
@@ -77,6 +79,7 @@
7779
78private:80private:
79 std::shared_ptr<shell::SurfaceFactory> const surface_factory;81 std::shared_ptr<shell::SurfaceFactory> const surface_factory;
82 pid_t const pid;
80 std::string const session_name;83 std::string const session_name;
81 std::shared_ptr<SnapshotStrategy> const snapshot_strategy;84 std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
82 std::shared_ptr<shell::SessionListener> const session_listener;85 std::shared_ptr<shell::SessionListener> const session_listener;
8386
=== modified file 'src/server/scene/session_manager.cpp'
--- src/server/scene/session_manager.cpp 2014-01-13 06:12:33 +0000
+++ src/server/scene/session_manager.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -73,12 +73,14 @@
73 close_session(session);73 close_session(session);
74}74}
7575
76std::shared_ptr<mf::Session> ms::SessionManager::open_session(std::string const& name,76std::shared_ptr<mf::Session> ms::SessionManager::open_session(
77 std::shared_ptr<mf::EventSink> const& sender)77 pid_t client_pid,
78 std::string const& name,
79 std::shared_ptr<mf::EventSink> const& sender)
78{80{
79 std::shared_ptr<msh::Session> new_session =81 std::shared_ptr<msh::Session> new_session =
80 std::make_shared<ApplicationSession>(82 std::make_shared<ApplicationSession>(
81 surface_factory, name, snapshot_strategy, session_listener, sender);83 surface_factory, client_pid, name, snapshot_strategy, session_listener, sender);
8284
83 app_container->insert_session(new_session);85 app_container->insert_session(new_session);
8486
8587
=== modified file 'src/server/scene/session_manager.h'
--- src/server/scene/session_manager.h 2014-01-13 06:12:33 +0000
+++ src/server/scene/session_manager.h 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * 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,5 * under the terms of the GNU General Public License version 3,
@@ -55,7 +55,10 @@
55 virtual ~SessionManager();55 virtual ~SessionManager();
5656
57 virtual std::shared_ptr<frontend::Session> open_session(57 virtual std::shared_ptr<frontend::Session> open_session(
58 std::string const& name, std::shared_ptr<frontend::EventSink> const& sink);58 pid_t client_pid,
59 std::string const& name,
60 std::shared_ptr<frontend::EventSink> const& sink);
61
59 virtual void close_session(std::shared_ptr<frontend::Session> const& session);62 virtual void close_session(std::shared_ptr<frontend::Session> const& session);
6063
61 frontend::SurfaceId create_surface_for(std::shared_ptr<frontend::Session> const& session,64 frontend::SurfaceId create_surface_for(std::shared_ptr<frontend::Session> const& session,
6265
=== modified file 'tests/integration-tests/test_session.cpp'
--- tests/integration-tests/test_session.cpp 2014-01-31 11:13:57 +0000
+++ tests/integration-tests/test_session.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -170,6 +170,7 @@
170170
171 ms::ApplicationSession session{171 ms::ApplicationSession session{
172 conf.the_shell_surface_factory(),172 conf.the_shell_surface_factory(),
173 __LINE__,
173 "stress",174 "stress",
174 conf.the_snapshot_strategy(),175 conf.the_snapshot_strategy(),
175 std::make_shared<msh::NullSessionListener>(),176 std::make_shared<msh::NullSessionListener>(),
176177
=== modified file 'tests/integration-tests/test_session_manager.cpp'
--- tests/integration-tests/test_session_manager.cpp 2014-01-13 06:12:33 +0000
+++ tests/integration-tests/test_session_manager.cpp 2014-02-07 14:29:43 +0000
@@ -76,9 +76,9 @@
7676
77 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);77 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
7878
79 auto session1 = session_manager.open_session("Visual Basic Studio", std::make_shared<mtd::NullEventSink>());79 auto session1 = session_manager.open_session(__LINE__, "Visual Basic Studio", std::make_shared<mtd::NullEventSink>());
80 auto session2 = session_manager.open_session("Microsoft Access", std::make_shared<mtd::NullEventSink>());80 auto session2 = session_manager.open_session(__LINE__, "Microsoft Access", std::make_shared<mtd::NullEventSink>());
81 auto session3 = session_manager.open_session("WordPerfect", std::make_shared<mtd::NullEventSink>());81 auto session3 = session_manager.open_session(__LINE__, "WordPerfect", std::make_shared<mtd::NullEventSink>());
8282
83 Mock::VerifyAndClearExpectations(&focus_setter);83 Mock::VerifyAndClearExpectations(&focus_setter);
8484
@@ -105,9 +105,9 @@
105105
106 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);106 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(3);
107107
108 auto session1 = session_manager.open_session("Visual Basic Studio", std::make_shared<mtd::NullEventSink>());108 auto session1 = session_manager.open_session(__LINE__, "Visual Basic Studio", std::make_shared<mtd::NullEventSink>());
109 auto session2 = session_manager.open_session("Microsoft Access", std::make_shared<mtd::NullEventSink>());109 auto session2 = session_manager.open_session(__LINE__, "Microsoft Access", std::make_shared<mtd::NullEventSink>());
110 auto session3 = session_manager.open_session("WordPerfect", std::make_shared<mtd::NullEventSink>());110 auto session3 = session_manager.open_session(__LINE__, "WordPerfect", std::make_shared<mtd::NullEventSink>());
111111
112 Mock::VerifyAndClearExpectations(&focus_setter);112 Mock::VerifyAndClearExpectations(&focus_setter);
113113
114114
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2014-02-06 09:51:46 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -206,7 +206,7 @@
206 report{std::make_shared<mf::NullSessionMediatorReport>()},206 report{std::make_shared<mf::NullSessionMediatorReport>()},
207 resource_cache{std::make_shared<mf::ResourceCache>()},207 resource_cache{std::make_shared<mf::ResourceCache>()},
208 stub_screencast{std::make_shared<StubScreencast>()},208 stub_screencast{std::make_shared<StubScreencast>()},
209 mediator{shell, graphics_platform, graphics_changer,209 mediator{__LINE__, shell, graphics_platform, graphics_changer,
210 surface_pixel_formats, report,210 surface_pixel_formats, report,
211 std::make_shared<mtd::NullEventSink>(),211 std::make_shared<mtd::NullEventSink>(),
212 resource_cache, stub_screencast},212 resource_cache, stub_screencast},
@@ -215,7 +215,7 @@
215 {215 {
216 using namespace ::testing;216 using namespace ::testing;
217217
218 ON_CALL(*shell, open_session(_, _)).WillByDefault(Return(stubbed_session));218 ON_CALL(*shell, open_session(_, _, _)).WillByDefault(Return(stubbed_session));
219 ON_CALL(*shell, create_surface_for(_, _))219 ON_CALL(*shell, create_surface_for(_, _))
220 .WillByDefault(WithArg<1>(Invoke(stubbed_session.get(), &StubbedSession::create_surface)));220 .WillByDefault(WithArg<1>(Invoke(stubbed_session.get(), &StubbedSession::create_surface)));
221 }221 }
@@ -370,7 +370,7 @@
370 .Times(1)370 .Times(1)
371 .WillOnce(Return(mt::fake_shared(config)));371 .WillOnce(Return(mt::fake_shared(config)));
372 mf::SessionMediator mediator(372 mf::SessionMediator mediator(
373 shell, graphics_platform, mock_display,373 __LINE__, shell, graphics_platform, mock_display,
374 surface_pixel_formats, report,374 surface_pixel_formats, report,
375 std::make_shared<mtd::NullEventSink>(),375 std::make_shared<mtd::NullEventSink>(),
376 resource_cache, std::make_shared<mtd::NullScreencast>());376 resource_cache, std::make_shared<mtd::NullScreencast>());
@@ -602,7 +602,7 @@
602 .WillOnce(Return(mt::fake_shared(stub_display_config)));602 .WillOnce(Return(mt::fake_shared(stub_display_config)));
603603
604 mf::SessionMediator session_mediator{604 mf::SessionMediator session_mediator{
605 shell, graphics_platform, mock_display_selector,605 __LINE__, shell, graphics_platform, mock_display_selector,
606 surface_pixel_formats, report,606 surface_pixel_formats, report,
607 std::make_shared<mtd::NullEventSink>(), resource_cache,607 std::make_shared<mtd::NullEventSink>(), resource_cache,
608 std::make_shared<mtd::NullScreencast>()};608 std::make_shared<mtd::NullScreencast>()};
609609
=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-01-29 18:02:33 +0000
+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-02-07 14:29:43 +0000
@@ -57,7 +57,7 @@
57 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},57 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},
58 report{std::make_shared<mf::NullSessionMediatorReport>()},58 report{std::make_shared<mf::NullSessionMediatorReport>()},
59 resource_cache{std::make_shared<mf::ResourceCache>()},59 resource_cache{std::make_shared<mf::ResourceCache>()},
60 mediator{shell, graphics_platform, display_changer,60 mediator{__LINE__, shell, graphics_platform, display_changer,
61 surface_pixel_formats, report,61 surface_pixel_formats, report,
62 std::make_shared<mtd::NullEventSink>(),62 std::make_shared<mtd::NullEventSink>(),
63 resource_cache, std::make_shared<mtd::NullScreencast>()},63 resource_cache, std::make_shared<mtd::NullScreencast>()},
6464
=== modified file 'tests/unit-tests/frontend/test_session_mediator_mesa.cpp'
--- tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-01-29 18:02:33 +0000
+++ tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -70,7 +70,7 @@
70 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},70 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},
71 report{std::make_shared<mf::NullSessionMediatorReport>()},71 report{std::make_shared<mf::NullSessionMediatorReport>()},
72 resource_cache{std::make_shared<mf::ResourceCache>()},72 resource_cache{std::make_shared<mf::ResourceCache>()},
73 mediator{shell, mock_platform, display_changer,73 mediator{__LINE__, shell, mock_platform, display_changer,
74 surface_pixel_formats, report,74 surface_pixel_formats, report,
75 std::make_shared<mtd::NullEventSink>(),75 std::make_shared<mtd::NullEventSink>(),
76 resource_cache, std::make_shared<mtd::NullScreencast>()},76 resource_cache, std::make_shared<mtd::NullScreencast>()},
7777
=== modified file 'tests/unit-tests/scene/test_application_session.cpp'
--- tests/unit-tests/scene/test_application_session.cpp 2014-01-13 06:12:33 +0000
+++ tests/unit-tests/scene/test_application_session.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -69,10 +69,13 @@
69 EXPECT_CALL(listener, destroying_surface(_, _))69 EXPECT_CALL(listener, destroying_surface(_, _))
70 .Times(1);70 .Times(1);
7171
72 ms::ApplicationSession session(mt::fake_shared(surface_factory), "Foo",72 ms::ApplicationSession session(
73 std::make_shared<mtd::NullSnapshotStrategy>(),73 mt::fake_shared(surface_factory),
74 mt::fake_shared(listener),74 __LINE__,
75 mt::fake_shared(sender));75 "Foo",
76 std::make_shared<mtd::NullSnapshotStrategy>(),
77 mt::fake_shared(listener),
78 mt::fake_shared(sender));
7679
77 msh::SurfaceCreationParameters params;80 msh::SurfaceCreationParameters params;
78 auto surf = session.create_surface(params);81 auto surf = session.create_surface(params);
@@ -97,9 +100,13 @@
97 EXPECT_CALL(listener, destroying_surface(_, _)).Times(1);100 EXPECT_CALL(listener, destroying_surface(_, _)).Times(1);
98101
99 {102 {
100 ms::ApplicationSession session(mt::fake_shared(surface_factory), "Foo",103 ms::ApplicationSession session(
101 std::make_shared<mtd::NullSnapshotStrategy>(), mt::fake_shared(listener),104 mt::fake_shared(surface_factory),
102 mt::fake_shared(sender));105 __LINE__,
106 "Foo",
107 std::make_shared<mtd::NullSnapshotStrategy>(),
108 mt::fake_shared(listener),
109 mt::fake_shared(sender));
103110
104 msh::SurfaceCreationParameters params;111 msh::SurfaceCreationParameters params;
105 session.create_surface(params);112 session.create_surface(params);
@@ -123,9 +130,13 @@
123 .WillOnce(Return(make_mock_surface()));130 .WillOnce(Return(make_mock_surface()));
124 }131 }
125132
126 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",133 ms::ApplicationSession app_session(
127 std::make_shared<mtd::NullSnapshotStrategy>(),134 mt::fake_shared(surface_factory),
128 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));135 __LINE__,
136 "Foo",
137 std::make_shared<mtd::NullSnapshotStrategy>(),
138 std::make_shared<msh::NullSessionListener>(),
139 mt::fake_shared(sender));
129140
130141
131 msh::SurfaceCreationParameters params;142 msh::SurfaceCreationParameters params;
@@ -156,9 +167,13 @@
156 mtd::MockSurfaceFactory surface_factory;167 mtd::MockSurfaceFactory surface_factory;
157 ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault(Return(mock_surface));168 ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault(Return(mock_surface));
158169
159 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",170 ms::ApplicationSession app_session(
160 std::make_shared<mtd::NullSnapshotStrategy>(),171 mt::fake_shared(surface_factory),
161 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));172 __LINE__,
173 "Foo",
174 std::make_shared<mtd::NullSnapshotStrategy>(),
175 std::make_shared<msh::NullSessionListener>(),
176 mt::fake_shared(sender));
162177
163 EXPECT_CALL(surface_factory, create_surface(_, _, _, _));178 EXPECT_CALL(surface_factory, create_surface(_, _, _, _));
164179
@@ -177,15 +192,20 @@
177 app_session.destroy_surface(surf);192 app_session.destroy_surface(surf);
178}193}
179194
180TEST(Session, get_invalid_surface_throw_behavior)195TEST(ApplicationSession, get_invalid_surface_throw_behavior)
181{196{
182 using namespace ::testing;197 using namespace ::testing;
183198
184 mtd::NullEventSink sender;199 mtd::NullEventSink sender;
185 mtd::MockSurfaceFactory surface_factory;200 mtd::MockSurfaceFactory surface_factory;
186 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",201 ms::ApplicationSession app_session(
187 std::make_shared<mtd::NullSnapshotStrategy>(),202 mt::fake_shared(surface_factory),
188 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));203 __LINE__,
204 "Foo",
205 std::make_shared<mtd::NullSnapshotStrategy>(),
206 std::make_shared<msh::NullSessionListener>(),
207 mt::fake_shared(sender));
208
189 mf::SurfaceId invalid_surface_id(1);209 mf::SurfaceId invalid_surface_id(1);
190210
191 EXPECT_THROW({211 EXPECT_THROW({
@@ -193,15 +213,20 @@
193 }, std::runtime_error);213 }, std::runtime_error);
194}214}
195215
196TEST(Session, destroy_invalid_surface_throw_behavior)216TEST(ApplicationSession, destroy_invalid_surface_throw_behavior)
197{217{
198 using namespace ::testing;218 using namespace ::testing;
199219
200 mtd::NullEventSink sender;220 mtd::NullEventSink sender;
201 mtd::MockSurfaceFactory surface_factory;221 mtd::MockSurfaceFactory surface_factory;
202 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",222 ms::ApplicationSession app_session(
203 std::make_shared<mtd::NullSnapshotStrategy>(),223 mt::fake_shared(surface_factory),
204 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));224 __LINE__,
225 "Foo",
226 std::make_shared<mtd::NullSnapshotStrategy>(),
227 std::make_shared<msh::NullSessionListener>(),
228 mt::fake_shared(sender));
229
205 mf::SurfaceId invalid_surface_id(1);230 mf::SurfaceId invalid_surface_id(1);
206231
207 EXPECT_THROW({232 EXPECT_THROW({
@@ -209,7 +234,7 @@
209 }, std::runtime_error);234 }, std::runtime_error);
210}235}
211236
212TEST(Session, uses_snapshot_strategy)237TEST(ApplicationSession, uses_snapshot_strategy)
213{238{
214 using namespace ::testing;239 using namespace ::testing;
215240
@@ -226,9 +251,13 @@
226 auto snapshot_strategy = std::make_shared<MockSnapshotStrategy>();251 auto snapshot_strategy = std::make_shared<MockSnapshotStrategy>();
227 mtd::NullEventSink sender;252 mtd::NullEventSink sender;
228 mtd::MockSurfaceFactory surface_factory;253 mtd::MockSurfaceFactory surface_factory;
229 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",254 ms::ApplicationSession app_session(
230 snapshot_strategy,255 mt::fake_shared(surface_factory),
231 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));256 __LINE__,
257 "Foo",
258 snapshot_strategy,
259 std::make_shared<msh::NullSessionListener>(),
260 mt::fake_shared(sender));
232261
233 EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_));262 EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_));
234263
@@ -245,7 +274,7 @@
245 MOCK_METHOD1(handle_display_config_change, void(mir::graphics::DisplayConfiguration const&));274 MOCK_METHOD1(handle_display_config_change, void(mir::graphics::DisplayConfiguration const&));
246};275};
247}276}
248TEST(Session, display_config_sender)277TEST(ApplicationSession, display_config_sender)
249{278{
250 using namespace ::testing;279 using namespace ::testing;
251280
@@ -256,14 +285,18 @@
256 EXPECT_CALL(sender, handle_display_config_change(testing::Ref(stub_config)))285 EXPECT_CALL(sender, handle_display_config_change(testing::Ref(stub_config)))
257 .Times(1);286 .Times(1);
258287
259 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",288 ms::ApplicationSession app_session(
260 std::make_shared<mtd::NullSnapshotStrategy>(),289 mt::fake_shared(surface_factory),
261 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));290 __LINE__,
291 "Foo",
292 std::make_shared<mtd::NullSnapshotStrategy>(),
293 std::make_shared<msh::NullSessionListener>(),
294 mt::fake_shared(sender));
262295
263 app_session.send_display_config(stub_config);296 app_session.send_display_config(stub_config);
264}297}
265298
266TEST(Session, lifecycle_event_sender)299TEST(ApplicationSession, lifecycle_event_sender)
267{300{
268 using namespace ::testing;301 using namespace ::testing;
269302
@@ -271,11 +304,35 @@
271 mtd::MockSurfaceFactory surface_factory;304 mtd::MockSurfaceFactory surface_factory;
272 MockEventSink sender;305 MockEventSink sender;
273306
274 ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",307 ms::ApplicationSession app_session(
275 std::make_shared<mtd::NullSnapshotStrategy>(),308 mt::fake_shared(surface_factory),
276 std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));309 __LINE__,
310 "Foo",
311 std::make_shared<mtd::NullSnapshotStrategy>(),
312 std::make_shared<msh::NullSessionListener>(),
313 mt::fake_shared(sender));
277314
278 EXPECT_CALL(sender, handle_lifecycle_event(exp_state)).Times(1);315 EXPECT_CALL(sender, handle_lifecycle_event(exp_state)).Times(1);
279316
280 app_session.set_lifecycle_state(mir_lifecycle_state_will_suspend);317 app_session.set_lifecycle_state(mir_lifecycle_state_will_suspend);
281}318}
319
320TEST(ApplicationSession, process_id)
321{
322 using namespace ::testing;
323
324 pid_t const pid{__LINE__};
325
326 mtd::MockSurfaceFactory surface_factory;
327 MockEventSink sender;
328
329 ms::ApplicationSession app_session(
330 mt::fake_shared(surface_factory),
331 pid,
332 "Foo",
333 std::make_shared<mtd::NullSnapshotStrategy>(),
334 std::make_shared<msh::NullSessionListener>(),
335 mt::fake_shared(sender));
336
337 EXPECT_THAT(app_session.process_id(), Eq(pid));
338}
282339
=== modified file 'tests/unit-tests/scene/test_session_manager.cpp'
--- tests/unit-tests/scene/test_session_manager.cpp 2014-01-13 06:12:33 +0000
+++ tests/unit-tests/scene/test_session_manager.cpp 2014-02-07 14:29:43 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as5 * it under the terms of the GNU General Public License version 3 as
@@ -104,7 +104,7 @@
104 EXPECT_CALL(focus_setter, set_focus_to(_));104 EXPECT_CALL(focus_setter, set_focus_to(_));
105 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);105 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
106106
107 auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>());107 auto session = session_manager.open_session(__LINE__, "Visual Basic Studio", std::shared_ptr<mf::EventSink>());
108 session_manager.close_session(session);108 session_manager.close_session(session);
109}109}
110110
@@ -126,7 +126,7 @@
126 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1);126 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1);
127 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);127 EXPECT_CALL(focus_setter, set_focus_to(std::shared_ptr<msh::Session>())).Times(1);
128128
129 auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>());129 auto session = session_manager.open_session(__LINE__, "Visual Basic Studio", std::shared_ptr<mf::EventSink>());
130 session->create_surface(msh::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}));130 session->create_surface(msh::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}));
131131
132 session_manager.close_session(session);132 session_manager.close_session(session);
@@ -140,7 +140,7 @@
140 EXPECT_CALL(container, insert_session(_)).Times(1);140 EXPECT_CALL(container, insert_session(_)).Times(1);
141 EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session));141 EXPECT_CALL(focus_setter, set_focus_to(_)).WillOnce(SaveArg<0>(&new_session));
142142
143 auto session = session_manager.open_session("Visual Basic Studio", std::shared_ptr<mf::EventSink>());143 auto session = session_manager.open_session(__LINE__, "Visual Basic Studio", std::shared_ptr<mf::EventSink>());
144 EXPECT_EQ(session, new_session);144 EXPECT_EQ(session, new_session);
145}145}
146146
@@ -161,7 +161,7 @@
161 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation161 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation
162 }162 }
163163
164 auto session1 = session_manager.open_session("Weather Report", std::shared_ptr<mf::EventSink>());164 auto session1 = session_manager.open_session(__LINE__, "Weather Report", std::shared_ptr<mf::EventSink>());
165 session_manager.create_surface_for(session1, msh::a_surface());165 session_manager.create_surface_for(session1, msh::a_surface());
166}166}
167167
@@ -200,7 +200,7 @@
200 EXPECT_CALL(session_listener, stopping(_)).Times(1);200 EXPECT_CALL(session_listener, stopping(_)).Times(1);
201 EXPECT_CALL(session_listener, unfocused()).Times(1);201 EXPECT_CALL(session_listener, unfocused()).Times(1);
202202
203 auto session = session_manager.open_session("XPlane", std::shared_ptr<mf::EventSink>());203 auto session = session_manager.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>());
204 session_manager.close_session(session);204 session_manager.close_session(session);
205}205}
206206
@@ -237,8 +237,8 @@
237237
238 EXPECT_CALL(session_event_sink, handle_focus_change(_)).Times(2);238 EXPECT_CALL(session_event_sink, handle_focus_change(_)).Times(2);
239239
240 auto session = session_manager.open_session("XPlane", std::shared_ptr<mf::EventSink>());240 auto session = session_manager.open_session(__LINE__, "XPlane", std::shared_ptr<mf::EventSink>());
241 auto session1 = session_manager.open_session("Bla", std::shared_ptr<mf::EventSink>());241 auto session1 = session_manager.open_session(__LINE__, "Bla", std::shared_ptr<mf::EventSink>());
242242
243 Mock::VerifyAndClearExpectations(&session_event_sink);243 Mock::VerifyAndClearExpectations(&session_event_sink);
244244

Subscribers

People subscribed via source and target branches