Mir

Merge lp:~kdub/mir/platform-operations into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 2060
Proposed branch: lp:~kdub/mir/platform-operations
Merge into: lp:mir
Diff against target: 1122 lines (+248/-334)
26 files modified
benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp (+5/-0)
include/platform/mir/graphics/platform_ipc_operations.h (+10/-1)
include/platform/mir/graphics/platform_ipc_package.h (+0/-1)
platform-ABI-sha1sums (+2/-2)
server-ABI-sha1sums (+2/-2)
src/platform/graphics/android/ipc_operations.cpp (+8/-0)
src/platform/graphics/android/ipc_operations.h (+2/-0)
src/platform/graphics/mesa/ipc_operations.cpp (+12/-0)
src/platform/graphics/mesa/ipc_operations.h (+3/-0)
src/server/frontend/default_configuration.cpp (+2/-1)
src/server/frontend/default_ipc_factory.cpp (+5/-5)
src/server/frontend/default_ipc_factory.h (+4/-4)
src/server/frontend/session_mediator.cpp (+15/-17)
src/server/frontend/session_mediator.h (+1/-4)
src/server/graphics/nested/nested_platform.cpp (+7/-0)
tests/include/mir_test_doubles/null_platform_ipc_operations.h (+5/-0)
tests/integration-tests/test_drm_auth_magic.cpp (+35/-9)
tests/integration-tests/test_exchange_buffer.cpp (+6/-0)
tests/mir_test_framework/stubbed_graphics_platform.cpp (+6/-0)
tests/unit-tests/frontend/CMakeLists.txt (+0/-10)
tests/unit-tests/frontend/test_session_mediator.cpp (+57/-38)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+0/-95)
tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+0/-141)
tests/unit-tests/graphics/android/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/android/test_ipc_operations.cpp (+50/-0)
tests/unit-tests/graphics/mesa/test_platform.cpp (+10/-4)
To merge this branch: bzr merge lp:~kdub/mir/platform-operations
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Cemil Azizoglu (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Review via email: mp+241563@code.launchpad.net

Commit message

platform: Allow for use of platform operations in the platform interfaces. This currently abstracts the drm auth magic request for the mesa platform. (the protocol still needs the drm magic stuff weeded out)

Description of the change

platform: Allow for use of platform operations in the platform interfaces. This currently abstracts the drm auth magic request for the mesa platform. (the protocol still needs the drm magic stuff weeded out)

This is a branch that sprung from the discussion started here:
https://lists.ubuntu.com/archives/mir-devel/2014-October/000923.html

I opted to put an opcode in the signature (Alan suggested on the chain that an opcode/type of operation is not necessary, it could just be part of the "DataAndFds"), mostly because all platform requests will need an opcode to distinguish what is to be done.

This benefits SessionMediator in that we don't have to cast to figure out whether we're dealing with the mesa platform or not. We also no longer need mg::Platform in SessionMediator, just mg::PlatformIpcOperations (which is defined by what SessionMediator has to do)

note: This branch has been rattling around my computer for a bit, now that I'm attempting to clean up the platform a bit and split out the nested/offscreen into actual platforms, seemed like a good time to propose.

note2: There's another cleanup coming that should also have a negative diff... but I figured ~1100 was a good review size.

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
Kevin DuBois (kdub) wrote :

doesnt look related retriggered.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Looks sensible to me. A bunch of spurious frontend:: → mf:: diff, but that's managable :)

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

> doesnt look related retriggered.

filed as lp:1392256

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

Nit I suspect that this:

    170 + the_graphics_platform()->make_ipc_operations(),

should be:

    170 + the_ipc_operations(),

With the_ipc_operations() having the obvious definition (but not belonging in frontend).

LGTM

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> virtual void platform_operation(
> PlatformIPCPackage& response, unsigned int const opcode, PlatformIPCPackage const& package) = 0;

The other option is:

virtual PlatformIPCPackage platform_operation(unsigned int opcode, PlatformIPCPackage const& package) = 0

PlatformIPCPackage is movable so even if (N)RVO doesn't kick in, returning the package should be cheap.

Weak "Needs Fixing", I prefer it with the return value, but I am not fussed.

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

I think my [weak] reason for having an out parameter was that I could forward-declare the PlatformIPCPackage type in the platform_ipc.h header... but I do like returning the response package a bit better.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

This makes the arch a whole lot cleaner. Looking forward to the IPC part of the cleanup.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I think my [weak] reason for having an out parameter was that I could forward-declare the PlatformIPCPackage type in the platform_ipc.h header...

It's allowed to declare functions that return (or accept) incomplete types, so we can still forward-declare PlatformIPCPackage in this case if we want.

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

24 +#include "platform_ipc_package.h"
...
32 -struct PlatformIPCPackage;

Not needed - the declaration was enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp'
--- benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2014-10-26 00:41:36 +0000
+++ benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2014-11-13 16:42:20 +0000
@@ -61,6 +61,11 @@
61 {61 {
62 return std::make_shared<mg::PlatformIPCPackage>();62 return std::make_shared<mg::PlatformIPCPackage>();
63 }63 }
64
65 mg::PlatformIPCPackage platform_operation(unsigned int const, mg::PlatformIPCPackage const&) override
66 {
67 return mg::PlatformIPCPackage();
68 }
64};69};
6570
66struct StubDisplayBuffer : mtd::StubDisplayBuffer71struct StubDisplayBuffer : mtd::StubDisplayBuffer
6772
=== modified file 'include/platform/mir/graphics/platform_ipc_operations.h'
--- include/platform/mir/graphics/platform_ipc_operations.h 2014-10-06 03:02:44 +0000
+++ include/platform/mir/graphics/platform_ipc_operations.h 2014-11-13 16:42:20 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_19#ifndef MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_
20#define MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_20#define MIR_GRAPHICS_PLATFORM_IPC_OPERATIONS_H_
2121
22#include "platform_ipc_package.h"
22#include <memory>23#include <memory>
2324
24namespace mir25namespace mir
@@ -32,7 +33,6 @@
32};33};
33class Buffer;34class Buffer;
34class BufferIpcMessage;35class BufferIpcMessage;
35struct PlatformIPCPackage;
3636
37class PlatformIpcOperations37class PlatformIpcOperations
38{38{
@@ -68,6 +68,15 @@
68 */68 */
69 virtual std::shared_ptr<PlatformIPCPackage> connection_ipc_package() = 0;69 virtual std::shared_ptr<PlatformIPCPackage> connection_ipc_package() = 0;
7070
71
72 /**
73 * Arranges a platform specific operation triggered by an IPC call
74 * \returns the response that will be sent to the client
75 * \param [in] opcode the opcode that indicates the action to be performed
76 * \param [in] request the message that was sent to the server
77 */
78 virtual PlatformIPCPackage platform_operation(unsigned int const opcode, PlatformIPCPackage const& package) = 0;
79
71protected:80protected:
72 PlatformIpcOperations() = default;81 PlatformIpcOperations() = default;
73 PlatformIpcOperations(PlatformIpcOperations const&) = delete;82 PlatformIpcOperations(PlatformIpcOperations const&) = delete;
7483
=== modified file 'include/platform/mir/graphics/platform_ipc_package.h'
--- include/platform/mir/graphics/platform_ipc_package.h 2014-10-21 16:21:14 +0000
+++ include/platform/mir/graphics/platform_ipc_package.h 2014-11-13 16:42:20 +0000
@@ -32,7 +32,6 @@
32 */32 */
33struct PlatformIPCPackage33struct PlatformIPCPackage
34{34{
35 virtual ~PlatformIPCPackage() {}
36 std::vector<int32_t> ipc_data;35 std::vector<int32_t> ipc_data;
37 std::vector<int32_t> ipc_fds;36 std::vector<int32_t> ipc_fds;
38};37};
3938
=== modified file 'platform-ABI-sha1sums'
--- platform-ABI-sha1sums 2014-11-11 07:34:31 +0000
+++ platform-ABI-sha1sums 2014-11-13 16:42:20 +0000
@@ -37,8 +37,8 @@
37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h
38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h
39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h403b3463d2513f4c3985f2400496dab333518f9a13 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h411b77fb3290af00dc7d1c11dcc5388972dacb9ec3 include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h
4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
4545
=== modified file 'server-ABI-sha1sums'
--- server-ABI-sha1sums 2014-11-13 15:24:33 +0000
+++ server-ABI-sha1sums 2014-11-13 16:42:20 +0000
@@ -37,8 +37,8 @@
37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h
38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h
39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h403b3463d2513f4c3985f2400496dab333518f9a13 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h411b77fb3290af00dc7d1c11dcc5388972dacb9ec3 include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h43b19329d35a55f640edd72c0a953908995211d97e include/platform/mir/options/configuration.h
4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h4447007c783c174f8e94d332c4b13c6b01358b48fb include/platform/mir/options/default_configuration.h
4545
=== modified file 'src/platform/graphics/android/ipc_operations.cpp'
--- src/platform/graphics/android/ipc_operations.cpp 2014-10-16 19:07:47 +0000
+++ src/platform/graphics/android/ipc_operations.cpp 2014-11-13 16:42:20 +0000
@@ -21,6 +21,8 @@
21#include "mir/graphics/buffer_ipc_message.h"21#include "mir/graphics/buffer_ipc_message.h"
22#include "mir/graphics/android/android_native_buffer.h"22#include "mir/graphics/android/android_native_buffer.h"
23#include "ipc_operations.h"23#include "ipc_operations.h"
24#include <stdexcept>
25#include <boost/throw_exception.hpp>
2426
25namespace mg = mir::graphics;27namespace mg = mir::graphics;
26namespace mga = mir::graphics::android;28namespace mga = mir::graphics::android;
@@ -67,3 +69,9 @@
67{69{
68 return std::make_shared<mg::PlatformIPCPackage>();70 return std::make_shared<mg::PlatformIPCPackage>();
69}71}
72
73mg::PlatformIPCPackage mga::IpcOperations::platform_operation(
74 unsigned int const, mg::PlatformIPCPackage const&)
75{
76 BOOST_THROW_EXCEPTION(std::invalid_argument("android platform does not support any platform operations"));
77}
7078
=== modified file 'src/platform/graphics/android/ipc_operations.h'
--- src/platform/graphics/android/ipc_operations.h 2014-09-03 12:24:33 +0000
+++ src/platform/graphics/android/ipc_operations.h 2014-11-13 16:42:20 +0000
@@ -33,6 +33,8 @@
33 void pack_buffer(BufferIpcMessage&, Buffer const&, BufferIpcMsgType) const override;33 void pack_buffer(BufferIpcMessage&, Buffer const&, BufferIpcMsgType) const override;
34 void unpack_buffer(BufferIpcMessage&, Buffer const&) const override;34 void unpack_buffer(BufferIpcMessage&, Buffer const&) const override;
35 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;35 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;
36 PlatformIPCPackage platform_operation(
37 unsigned int const opcode, PlatformIPCPackage const& package) override;
36};38};
37}39}
38}40}
3941
=== modified file 'src/platform/graphics/mesa/ipc_operations.cpp'
--- src/platform/graphics/mesa/ipc_operations.cpp 2014-09-03 12:24:33 +0000
+++ src/platform/graphics/mesa/ipc_operations.cpp 2014-11-13 16:42:20 +0000
@@ -77,3 +77,15 @@
77void mgm::IpcOperations::unpack_buffer(BufferIpcMessage&, Buffer const&) const77void mgm::IpcOperations::unpack_buffer(BufferIpcMessage&, Buffer const&) const
78{78{
79}79}
80
81mg::PlatformIPCPackage mgm::IpcOperations::platform_operation(
82 unsigned int const, mg::PlatformIPCPackage const& request)
83{
84 int magic{0};
85 if (request.ipc_data.size() > 0)
86 magic = request.ipc_data[0];
87
88 drm->auth_magic(magic);
89
90 return mg::PlatformIPCPackage{{0},{}};
91}
8092
=== modified file 'src/platform/graphics/mesa/ipc_operations.h'
--- src/platform/graphics/mesa/ipc_operations.h 2014-09-03 12:24:33 +0000
+++ src/platform/graphics/mesa/ipc_operations.h 2014-11-13 16:42:20 +0000
@@ -37,6 +37,9 @@
37 void pack_buffer(BufferIpcMessage& message, Buffer const& buffer, BufferIpcMsgType msg_type) const override;37 void pack_buffer(BufferIpcMessage& message, Buffer const& buffer, BufferIpcMsgType msg_type) const override;
38 void unpack_buffer(BufferIpcMessage& message, Buffer const& buffer) const override;38 void unpack_buffer(BufferIpcMessage& message, Buffer const& buffer) const override;
39 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;39 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;
40 PlatformIPCPackage platform_operation(
41 unsigned int const opcode,
42 PlatformIPCPackage const& package) override;
40private:43private:
41 std::shared_ptr<helpers::DRMHelper> const drm;44 std::shared_ptr<helpers::DRMHelper> const drm;
42};45};
4346
=== modified file 'src/server/frontend/default_configuration.cpp'
--- src/server/frontend/default_configuration.cpp 2014-10-27 22:31:16 +0000
+++ src/server/frontend/default_configuration.cpp 2014-11-13 16:42:20 +0000
@@ -24,6 +24,7 @@
2424
25#include "unsupported_coordinate_translator.h"25#include "unsupported_coordinate_translator.h"
2626
27#include "mir/graphics/platform.h"
27#include "mir/frontend/protobuf_connection_creator.h"28#include "mir/frontend/protobuf_connection_creator.h"
28#include "mir/frontend/session_authorizer.h"29#include "mir/frontend/session_authorizer.h"
29#include "mir/options/configuration.h"30#include "mir/options/configuration.h"
@@ -152,7 +153,7 @@
152 return std::make_shared<mf::DefaultIpcFactory>(153 return std::make_shared<mf::DefaultIpcFactory>(
153 the_frontend_shell(),154 the_frontend_shell(),
154 the_session_mediator_report(),155 the_session_mediator_report(),
155 the_graphics_platform(),156 the_graphics_platform()->make_ipc_operations(),
156 the_frontend_display_changer(),157 the_frontend_display_changer(),
157 the_buffer_allocator(),158 the_buffer_allocator(),
158 the_screencast(),159 the_screencast(),
159160
=== modified file 'src/server/frontend/default_ipc_factory.cpp'
--- src/server/frontend/default_ipc_factory.cpp 2014-10-27 22:31:16 +0000
+++ src/server/frontend/default_ipc_factory.cpp 2014-11-13 16:42:20 +0000
@@ -33,7 +33,7 @@
33mf::DefaultIpcFactory::DefaultIpcFactory(33mf::DefaultIpcFactory::DefaultIpcFactory(
34 std::shared_ptr<Shell> const& shell,34 std::shared_ptr<Shell> const& shell,
35 std::shared_ptr<SessionMediatorReport> const& sm_report,35 std::shared_ptr<SessionMediatorReport> const& sm_report,
36 std::shared_ptr<mg::Platform> const& graphics_platform,36 std::shared_ptr<mg::PlatformIpcOperations> const& platform_ipc_operations,
37 std::shared_ptr<DisplayChanger> const& display_changer,37 std::shared_ptr<DisplayChanger> const& display_changer,
38 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,38 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,
39 std::shared_ptr<Screencast> const& screencast,39 std::shared_ptr<Screencast> const& screencast,
@@ -44,7 +44,7 @@
44 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),44 no_prompt_shell(std::make_shared<NoPromptShell>(shell)),
45 sm_report(sm_report),45 sm_report(sm_report),
46 cache(std::make_shared<ResourceCache>()),46 cache(std::make_shared<ResourceCache>()),
47 graphics_platform(graphics_platform),47 platform_ipc_operations(platform_ipc_operations),
48 display_changer(display_changer),48 display_changer(display_changer),
49 buffer_allocator(buffer_allocator),49 buffer_allocator(buffer_allocator),
50 screencast(screencast),50 screencast(screencast),
@@ -87,7 +87,7 @@
8787
88 return make_mediator(88 return make_mediator(
89 effective_shell,89 effective_shell,
90 graphics_platform,90 platform_ipc_operations,
91 changer,91 changer,
92 buffer_allocator,92 buffer_allocator,
93 sm_report,93 sm_report,
@@ -103,7 +103,7 @@
103103
104std::shared_ptr<mf::detail::DisplayServer> mf::DefaultIpcFactory::make_mediator(104std::shared_ptr<mf::detail::DisplayServer> mf::DefaultIpcFactory::make_mediator(
105 std::shared_ptr<Shell> const& shell,105 std::shared_ptr<Shell> const& shell,
106 std::shared_ptr<mg::Platform> const& graphics_platform,106 std::shared_ptr<mg::PlatformIpcOperations> const& platform_ipc_operations,
107 std::shared_ptr<DisplayChanger> const& changer,107 std::shared_ptr<DisplayChanger> const& changer,
108 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,108 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,
109 std::shared_ptr<SessionMediatorReport> const& sm_report,109 std::shared_ptr<SessionMediatorReport> const& sm_report,
@@ -114,7 +114,7 @@
114{114{
115 return std::make_shared<SessionMediator>(115 return std::make_shared<SessionMediator>(
116 shell,116 shell,
117 graphics_platform,117 platform_ipc_operations,
118 changer,118 changer,
119 buffer_allocator->supported_pixel_formats(),119 buffer_allocator->supported_pixel_formats(),
120 sm_report,120 sm_report,
121121
=== modified file 'src/server/frontend/default_ipc_factory.h'
--- src/server/frontend/default_ipc_factory.h 2014-10-27 22:31:16 +0000
+++ src/server/frontend/default_ipc_factory.h 2014-11-13 16:42:20 +0000
@@ -25,7 +25,7 @@
25{25{
26namespace graphics26namespace graphics
27{27{
28class Platform;28class PlatformIpcOperations;
29class GraphicBufferAllocator;29class GraphicBufferAllocator;
30}30}
31namespace input31namespace input
@@ -52,7 +52,7 @@
52 explicit DefaultIpcFactory(52 explicit DefaultIpcFactory(
53 std::shared_ptr<Shell> const& shell,53 std::shared_ptr<Shell> const& shell,
54 std::shared_ptr<SessionMediatorReport> const& sm_report,54 std::shared_ptr<SessionMediatorReport> const& sm_report,
55 std::shared_ptr<graphics::Platform> const& graphics_platform,55 std::shared_ptr<graphics::PlatformIpcOperations> const& platform_ipc_operations,
56 std::shared_ptr<DisplayChanger> const& display_changer,56 std::shared_ptr<DisplayChanger> const& display_changer,
57 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,57 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
58 std::shared_ptr<Screencast> const& screencast,58 std::shared_ptr<Screencast> const& screencast,
@@ -69,7 +69,7 @@
6969
70 virtual std::shared_ptr<detail::DisplayServer> make_mediator(70 virtual std::shared_ptr<detail::DisplayServer> make_mediator(
71 std::shared_ptr<Shell> const& shell,71 std::shared_ptr<Shell> const& shell,
72 std::shared_ptr<graphics::Platform> const& graphics_platform,72 std::shared_ptr<graphics::PlatformIpcOperations> const& platform_ipc_operations,
73 std::shared_ptr<DisplayChanger> const& changer,73 std::shared_ptr<DisplayChanger> const& changer,
74 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,74 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
75 std::shared_ptr<SessionMediatorReport> const& sm_report,75 std::shared_ptr<SessionMediatorReport> const& sm_report,
@@ -83,7 +83,7 @@
83 std::shared_ptr<Shell> const no_prompt_shell;83 std::shared_ptr<Shell> const no_prompt_shell;
84 std::shared_ptr<SessionMediatorReport> const sm_report;84 std::shared_ptr<SessionMediatorReport> const sm_report;
85 std::shared_ptr<ResourceCache> const cache;85 std::shared_ptr<ResourceCache> const cache;
86 std::shared_ptr<graphics::Platform> const graphics_platform;86 std::shared_ptr<graphics::PlatformIpcOperations> const platform_ipc_operations;
87 std::shared_ptr<DisplayChanger> const display_changer;87 std::shared_ptr<DisplayChanger> const display_changer;
88 std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;88 std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;
89 std::shared_ptr<Screencast> const screencast;89 std::shared_ptr<Screencast> const screencast;
9090
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2014-10-30 18:37:11 +0000
+++ src/server/frontend/session_mediator.cpp 2014-11-13 16:42:20 +0000
@@ -35,6 +35,7 @@
35#include "mir/frontend/display_changer.h"35#include "mir/frontend/display_changer.h"
36#include "mir/graphics/display_configuration.h"36#include "mir/graphics/display_configuration.h"
37#include "mir/graphics/pixel_format_utils.h"37#include "mir/graphics/pixel_format_utils.h"
38#include "mir/graphics/platform_ipc_operations.h"
38#include "mir/graphics/platform_ipc_package.h"39#include "mir/graphics/platform_ipc_package.h"
39#include "mir/graphics/drm_authenticator.h"40#include "mir/graphics/drm_authenticator.h"
40#include "mir/frontend/client_constants.h"41#include "mir/frontend/client_constants.h"
@@ -64,8 +65,8 @@
64namespace geom = mir::geometry;65namespace geom = mir::geometry;
6566
66mf::SessionMediator::SessionMediator(67mf::SessionMediator::SessionMediator(
67 std::shared_ptr<frontend::Shell> const& shell,68 std::shared_ptr<mf::Shell> const& shell,
68 std::shared_ptr<graphics::Platform> const & graphics_platform,69 std::shared_ptr<mg::PlatformIpcOperations> const& ipc_operations,
69 std::shared_ptr<mf::DisplayChanger> const& display_changer,70 std::shared_ptr<mf::DisplayChanger> const& display_changer,
70 std::vector<MirPixelFormat> const& surface_pixel_formats,71 std::vector<MirPixelFormat> const& surface_pixel_formats,
71 std::shared_ptr<SessionMediatorReport> const& report,72 std::shared_ptr<SessionMediatorReport> const& report,
@@ -77,8 +78,7 @@
77 std::shared_ptr<scene::CoordinateTranslator> const& translator) :78 std::shared_ptr<scene::CoordinateTranslator> const& translator) :
78 client_pid_(0),79 client_pid_(0),
79 shell(shell),80 shell(shell),
80 graphics_platform(graphics_platform),81 ipc_operations(ipc_operations),
81 ipc_operations(graphics_platform->make_ipc_operations()),
82 surface_pixel_formats(surface_pixel_formats),82 surface_pixel_formats(surface_pixel_formats),
83 display_changer(display_changer),83 display_changer(display_changer),
84 report(report),84 report(report),
@@ -357,7 +357,7 @@
357357
358 report->session_configure_surface_called(session->name());358 report->session_configure_surface_called(session->name());
359359
360 auto const id = frontend::SurfaceId(request->surfaceid().value());360 auto const id = mf::SurfaceId(request->surfaceid().value());
361 int value = request->ivalue();361 int value = request->ivalue();
362 auto const surface = session->get_surface(id);362 auto const surface = session->get_surface(id);
363 int newvalue = surface->configure(attrib, value);363 int newvalue = surface->configure(attrib, value);
@@ -474,7 +474,7 @@
474474
475std::function<void(std::shared_ptr<mf::Session> const&)> mf::SessionMediator::prompt_session_connect_handler() const475std::function<void(std::shared_ptr<mf::Session> const&)> mf::SessionMediator::prompt_session_connect_handler() const
476{476{
477 return [this](std::shared_ptr<frontend::Session> const& session)477 return [this](std::shared_ptr<mf::Session> const& session)
478 {478 {
479 auto prompt_session = weak_prompt_session.lock();479 auto prompt_session = weak_prompt_session.lock();
480 if (prompt_session.get() == nullptr)480 if (prompt_session.get() == nullptr)
@@ -500,7 +500,7 @@
500500
501 report->session_configure_surface_cursor_called(session->name());501 report->session_configure_surface_cursor_called(session->name());
502502
503 auto const id = frontend::SurfaceId(cursor_request->surfaceid().value());503 auto const id = mf::SurfaceId(cursor_request->surfaceid().value());
504 auto const surface = session->get_surface(id);504 auto const surface = session->get_surface(id);
505505
506 if (cursor_request->has_name())506 if (cursor_request->has_name())
@@ -548,7 +548,7 @@
548 done->Run();548 done->Run();
549}549}
550550
551void mir::frontend::SessionMediator::translate_surface_to_screen(551void mf::SessionMediator::translate_surface_to_screen(
552 ::google::protobuf::RpcController* ,552 ::google::protobuf::RpcController* ,
553 ::mir::protobuf::CoordinateTranslationRequest const* request,553 ::mir::protobuf::CoordinateTranslationRequest const* request,
554 ::mir::protobuf::CoordinateTranslationResponse* response,554 ::mir::protobuf::CoordinateTranslationResponse* response,
@@ -562,7 +562,7 @@
562 if (session.get() == nullptr)562 if (session.get() == nullptr)
563 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));563 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));
564564
565 auto const id = frontend::SurfaceId(request->surfaceid().value());565 auto const id = mf::SurfaceId(request->surfaceid().value());
566566
567 auto const coords = translator->surface_to_screen(session->get_surface(id),567 auto const coords = translator->surface_to_screen(session->get_surface(id),
568 request->x(),568 request->x(),
@@ -590,16 +590,14 @@
590 report->session_drm_auth_magic_called(session->name());590 report->session_drm_auth_magic_called(session->name());
591 }591 }
592592
593 auto const magic = static_cast<unsigned int>(request->magic());593 //TODO: the opcode should be provided as part of the request, and should be opaque to the server code.
594 //FIXME: don't dynamic cast like this drm_auth_magic should be a part of PlatformIpcOperations 594 unsigned int const made_up_opcode{0};
595 auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(graphics_platform);595 mg::PlatformIPCPackage platform_request{{static_cast<int32_t>(request->magic())},{}};
596 if (!authenticator)
597 BOOST_THROW_EXCEPTION(std::logic_error("drm_auth_magic request not supported by the active platform"));
598
599 try596 try
600 {597 {
601 authenticator->drm_auth_magic(magic);598 auto platform_response = ipc_operations->platform_operation(made_up_opcode, platform_request);
602 response->set_status_code(0);599 if (platform_response.ipc_data.size() > 0)
600 response->set_status_code(platform_response.ipc_data[0]);
603 }601 }
604 catch (std::exception const& e)602 catch (std::exception const& e)
605 {603 {
606604
=== modified file 'src/server/frontend/session_mediator.h'
--- src/server/frontend/session_mediator.h 2014-11-03 06:51:26 +0000
+++ src/server/frontend/session_mediator.h 2014-11-13 16:42:20 +0000
@@ -22,7 +22,6 @@
22#include "display_server.h"22#include "display_server.h"
23#include "mir/frontend/connection_context.h"23#include "mir/frontend/connection_context.h"
24#include "mir/frontend/surface_id.h"24#include "mir/frontend/surface_id.h"
25#include "mir/graphics/platform.h"
26#include "mir/graphics/platform_ipc_operations.h"25#include "mir/graphics/platform_ipc_operations.h"
27#include "mir_toolkit/common.h"26#include "mir_toolkit/common.h"
28#include "surface_tracker.h"27#include "surface_tracker.h"
@@ -37,7 +36,6 @@
37namespace graphics36namespace graphics
38{37{
39class Buffer;38class Buffer;
40class Platform;
41class Display;39class Display;
42class GraphicBufferAllocator;40class GraphicBufferAllocator;
43}41}
@@ -73,7 +71,7 @@
7371
74 SessionMediator(72 SessionMediator(
75 std::shared_ptr<Shell> const& shell,73 std::shared_ptr<Shell> const& shell,
76 std::shared_ptr<graphics::Platform> const& graphics_platform,74 std::shared_ptr<graphics::PlatformIpcOperations> const& ipc_operations,
77 std::shared_ptr<frontend::DisplayChanger> const& display_changer,75 std::shared_ptr<frontend::DisplayChanger> const& display_changer,
78 std::vector<MirPixelFormat> const& surface_pixel_formats,76 std::vector<MirPixelFormat> const& surface_pixel_formats,
79 std::shared_ptr<SessionMediatorReport> const& report,77 std::shared_ptr<SessionMediatorReport> const& report,
@@ -194,7 +192,6 @@
194192
195 pid_t client_pid_;193 pid_t client_pid_;
196 std::shared_ptr<Shell> const shell;194 std::shared_ptr<Shell> const shell;
197 std::shared_ptr<graphics::Platform> const graphics_platform;
198 std::shared_ptr<graphics::PlatformIpcOperations> const ipc_operations;195 std::shared_ptr<graphics::PlatformIpcOperations> const ipc_operations;
199196
200 std::vector<MirPixelFormat> const surface_pixel_formats;197 std::vector<MirPixelFormat> const surface_pixel_formats;
201198
=== modified file 'src/server/graphics/nested/nested_platform.cpp'
--- src/server/graphics/nested/nested_platform.cpp 2014-10-27 13:06:48 +0000
+++ src/server/graphics/nested/nested_platform.cpp 2014-11-13 16:42:20 +0000
@@ -111,12 +111,19 @@
111 {111 {
112 native_platform->fill_buffer_package(&message, &buffer, msg_type);112 native_platform->fill_buffer_package(&message, &buffer, msg_type);
113 }113 }
114
114 void unpack_buffer(mg::BufferIpcMessage&, mg::Buffer const&) const {}115 void unpack_buffer(mg::BufferIpcMessage&, mg::Buffer const&) const {}
115116
116 std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package()117 std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package()
117 {118 {
118 return native_platform->connection_ipc_package();119 return native_platform->connection_ipc_package();
119 }120 }
121
122 mg::PlatformIPCPackage platform_operation(unsigned int const, mg::PlatformIPCPackage const&) override
123 {
124 return mg::PlatformIPCPackage();
125 }
126
120private:127private:
121 std::shared_ptr<mg::NativePlatform> const native_platform;128 std::shared_ptr<mg::NativePlatform> const native_platform;
122};129};
123130
=== modified file 'tests/include/mir_test_doubles/null_platform_ipc_operations.h'
--- tests/include/mir_test_doubles/null_platform_ipc_operations.h 2014-09-03 12:24:33 +0000
+++ tests/include/mir_test_doubles/null_platform_ipc_operations.h 2014-11-13 16:42:20 +0000
@@ -40,6 +40,11 @@
40 {40 {
41 return std::make_shared<graphics::PlatformIPCPackage>();41 return std::make_shared<graphics::PlatformIPCPackage>();
42 }42 }
43 graphics::PlatformIPCPackage platform_operation(
44 unsigned int const, graphics::PlatformIPCPackage const&) override
45 {
46 return graphics::PlatformIPCPackage();
47 }
43};48};
44}49}
45}50}
4651
=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
--- tests/integration-tests/test_drm_auth_magic.cpp 2014-10-16 11:53:01 +0000
+++ tests/integration-tests/test_drm_auth_magic.cpp 2014-11-13 16:42:20 +0000
@@ -19,6 +19,7 @@
19#include "mir/graphics/display.h"19#include "mir/graphics/display.h"
20#include "mir/graphics/drm_authenticator.h"20#include "mir/graphics/drm_authenticator.h"
21#include "mir/graphics/platform_ipc_package.h"21#include "mir/graphics/platform_ipc_package.h"
22#include "mir/graphics/buffer_ipc_message.h"
22#include "mir/graphics/buffer_basic.h"23#include "mir/graphics/buffer_basic.h"
2324
24#include <boost/exception/errinfo_errno.hpp>25#include <boost/exception/errinfo_errno.hpp>
@@ -44,15 +45,34 @@
4445
45char const* const mir_test_socket = mtf::test_socket_file().c_str();46char const* const mir_test_socket = mtf::test_socket_file().c_str();
4647
47class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator48struct MockAuthenticatingIpcOps : public mg::PlatformIpcOperations
49{
50 MOCK_CONST_METHOD3(pack_buffer, void(mg::BufferIpcMessage&, mg::Buffer const&, mg::BufferIpcMsgType));
51 MOCK_CONST_METHOD2(unpack_buffer, void(mg::BufferIpcMessage&, mg::Buffer const&));
52 MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>());
53 MOCK_METHOD2(platform_operation, mg::PlatformIPCPackage(
54 unsigned int const, mg::PlatformIPCPackage const&));
55};
56
57class StubAuthenticatingPlatform : public mtd::NullPlatform
48{58{
49public:59public:
60 StubAuthenticatingPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ops) :
61 ops{ops}
62 {
63 }
64
50 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override65 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
51 {66 {
52 return std::make_shared<mtd::StubBufferAllocator>();67 return std::make_shared<mtd::StubBufferAllocator>();
53 }68 }
69 std::shared_ptr<mg::PlatformIpcOperations> make_ipc_operations() const override
70 {
71 return ops;
72 }
5473
55 MOCK_METHOD1(drm_auth_magic, void(unsigned int));74private:
75 std::shared_ptr<mg::PlatformIpcOperations> const ops;
56};76};
5777
58void connection_callback(MirConnection* connection, void* context)78void connection_callback(MirConnection* connection, void* context)
@@ -80,15 +100,20 @@
80 using namespace testing;100 using namespace testing;
81 if (!platform)101 if (!platform)
82 {102 {
83 platform = std::make_shared<MockAuthenticatingPlatform>();103 mg::PlatformIPCPackage pkg{{0},{}};
84 EXPECT_CALL(*platform, drm_auth_magic(magic))104 auto ipc_ops = std::make_shared<NiceMock<MockAuthenticatingIpcOps>>();
85 .Times(1);105 EXPECT_CALL(*ipc_ops, platform_operation(_,_))
106 .Times(1)
107 .WillRepeatedly(Return(pkg));
108 ON_CALL(*ipc_ops, connection_ipc_package())
109 .WillByDefault(Return(std::make_shared<mg::PlatformIPCPackage>()));
110 platform = std::make_shared<StubAuthenticatingPlatform>(ipc_ops);
86 }111 }
87112
88 return platform;113 return platform;
89 }114 }
90115
91 std::shared_ptr<MockAuthenticatingPlatform> platform;116 std::shared_ptr<StubAuthenticatingPlatform> platform;
92 } server_config;117 } server_config;
93118
94 launch_server_process(server_config);119 launch_server_process(server_config);
@@ -130,16 +155,17 @@
130 using namespace testing;155 using namespace testing;
131 if (!platform)156 if (!platform)
132 {157 {
133 platform = std::make_shared<MockAuthenticatingPlatform>();158 auto ipc_ops = std::make_shared<NiceMock<MockAuthenticatingIpcOps>>();
134 EXPECT_CALL(*platform, drm_auth_magic(magic))159 EXPECT_CALL(*ipc_ops, platform_operation(_,_))
135 .WillOnce(Throw(::boost::enable_error_info(std::exception())160 .WillOnce(Throw(::boost::enable_error_info(std::exception())
136 << boost::errinfo_errno(auth_magic_error)));161 << boost::errinfo_errno(auth_magic_error)));
162 platform = std::make_shared<StubAuthenticatingPlatform>(ipc_ops);
137 }163 }
138164
139 return platform;165 return platform;
140 }166 }
141167
142 std::shared_ptr<MockAuthenticatingPlatform> platform;168 std::shared_ptr<StubAuthenticatingPlatform> platform;
143 } server_config;169 } server_config;
144170
145 launch_server_process(server_config);171 launch_server_process(server_config);
146172
=== modified file 'tests/integration-tests/test_exchange_buffer.cpp'
--- tests/integration-tests/test_exchange_buffer.cpp 2014-10-27 20:15:54 +0000
+++ tests/integration-tests/test_exchange_buffer.cpp 2014-11-13 16:42:20 +0000
@@ -130,6 +130,12 @@
130 {130 {
131 return last_fd;131 return last_fd;
132 }132 }
133
134 mg::PlatformIPCPackage platform_operation(
135 unsigned int const, mg::PlatformIPCPackage const&) override
136 {
137 return mg::PlatformIPCPackage();
138 }
133private:139private:
134 mir::Fd mutable last_fd;140 mir::Fd mutable last_fd;
135};141};
136142
=== modified file 'tests/mir_test_framework/stubbed_graphics_platform.cpp'
--- tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-10-22 12:46:08 +0000
+++ tests/mir_test_framework/stubbed_graphics_platform.cpp 2014-11-13 16:42:20 +0000
@@ -147,6 +147,12 @@
147 {147 {
148 return std::make_shared<mg::PlatformIPCPackage>();148 return std::make_shared<mg::PlatformIPCPackage>();
149 }149 }
150
151 mg::PlatformIPCPackage platform_operation(
152 unsigned int const, mg::PlatformIPCPackage const&) override
153 {
154 return mg::PlatformIPCPackage();
155 }
150};156};
151}157}
152158
153159
=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
--- tests/unit-tests/frontend/CMakeLists.txt 2014-10-27 22:31:16 +0000
+++ tests/unit-tests/frontend/CMakeLists.txt 2014-11-13 16:42:20 +0000
@@ -14,16 +14,6 @@
14 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_message_processor.cpp14 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_message_processor.cpp
15)15)
1616
17if (MIR_TEST_PLATFORM STREQUAL "android")
18 list(APPEND UNIT_TEST_SOURCES
19 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator_android.cpp
20 )
21elseif (MIR_TEST_PLATFORM STREQUAL "mesa")
22 list(APPEND UNIT_TEST_SOURCES
23 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator_mesa.cpp
24 )
25endif()
26
27set(17set(
28 UNIT_TEST_SOURCES18 UNIT_TEST_SOURCES
29 ${UNIT_TEST_SOURCES}19 ${UNIT_TEST_SOURCES}
3020
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-30 18:37:11 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-11-13 16:42:20 +0000
@@ -50,6 +50,8 @@
50#include "mir/frontend/event_sink.h"50#include "mir/frontend/event_sink.h"
5151
52#include "gmock_set_arg.h"52#include "gmock_set_arg.h"
53#include <boost/exception/errinfo_errno.hpp>
54#include <boost/throw_exception.hpp>
53#include <gtest/gtest.h>55#include <gtest/gtest.h>
54#include <gmock/gmock.h>56#include <gmock/gmock.h>
5557
@@ -124,6 +126,7 @@
124 MOCK_CONST_METHOD2(unpack_buffer,126 MOCK_CONST_METHOD2(unpack_buffer,
125 void(mg::BufferIpcMessage&, mg::Buffer const&));127 void(mg::BufferIpcMessage&, mg::Buffer const&));
126 MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>());128 MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>());
129 MOCK_METHOD2(platform_operation, mg::PlatformIPCPackage(unsigned int const, mg::PlatformIPCPackage const&));
127};130};
128131
129class StubbedSession : public mtd::StubSession132class StubbedSession : public mtd::StubSession
@@ -202,36 +205,6 @@
202 MOCK_METHOD0(supported_pixel_formats, std::vector<MirPixelFormat>());205 MOCK_METHOD0(supported_pixel_formats, std::vector<MirPixelFormat>());
203};206};
204207
205
206class MockPlatform : public mg::Platform
207{
208 public:
209 MockPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ipc_ops)
210 {
211 using namespace testing;
212 ON_CALL(*this, create_buffer_allocator())
213 .WillByDefault(Return(std::shared_ptr<mg::GraphicBufferAllocator>()));
214 ON_CALL(*this, create_display(_,_,_))
215 .WillByDefault(Return(std::make_shared<mtd::NullDisplay>()));
216 ON_CALL(*this, connection_ipc_package())
217 .WillByDefault(Return(std::make_shared<mg::PlatformIPCPackage>()));
218 ON_CALL(*this, make_ipc_operations())
219 .WillByDefault(Return(ipc_ops));
220 }
221
222 MOCK_METHOD0(create_buffer_allocator, std::shared_ptr<mg::GraphicBufferAllocator>());
223 MOCK_METHOD3(create_display,
224 std::shared_ptr<mg::Display>(
225 std::shared_ptr<mg::DisplayConfigurationPolicy> const&,
226 std::shared_ptr<mg::GLProgramFactory> const&,
227 std::shared_ptr<mg::GLConfig> const&));
228 MOCK_METHOD0(connection_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>());
229 MOCK_METHOD0(create_internal_client, std::shared_ptr<mg::InternalClient>());
230 MOCK_CONST_METHOD0(make_ipc_operations, std::shared_ptr<mg::PlatformIpcOperations>());
231 MOCK_CONST_METHOD0(egl_native_display, EGLNativeDisplayType());
232 MOCK_METHOD0(make_buffer_writer, std::shared_ptr<mg::BufferWriter>());
233};
234
235struct StubScreencast : mtd::NullScreencast208struct StubScreencast : mtd::NullScreencast
236{209{
237 std::shared_ptr<mg::Buffer> capture(mf::ScreencastSessionId)210 std::shared_ptr<mg::Buffer> capture(mf::ScreencastSessionId)
@@ -246,8 +219,6 @@
246{219{
247 SessionMediator()220 SessionMediator()
248 : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()},221 : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()},
249 graphics_platform{
250 std::make_shared<testing::NiceMock<MockPlatform>>(mt::fake_shared(mock_ipc_operations))},
251 graphics_changer{std::make_shared<mtd::NullDisplayChanger>()},222 graphics_changer{std::make_shared<mtd::NullDisplayChanger>()},
252 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},223 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},
253 report{mr::null_session_mediator_report()},224 report{mr::null_session_mediator_report()},
@@ -256,7 +227,7 @@
256 stubbed_session{std::make_shared<StubbedSession>()},227 stubbed_session{std::make_shared<StubbedSession>()},
257 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)},228 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)},
258 mediator{229 mediator{
259 shell, graphics_platform, graphics_changer,230 shell, mt::fake_shared(mock_ipc_operations), graphics_changer,
260 surface_pixel_formats, report,231 surface_pixel_formats, report,
261 std::make_shared<mtd::NullEventSink>(),232 std::make_shared<mtd::NullEventSink>(),
262 resource_cache, stub_screencast, &connector, nullptr, nullptr}233 resource_cache, stub_screencast, &connector, nullptr, nullptr}
@@ -269,7 +240,6 @@
269 MockConnector connector;240 MockConnector connector;
270 testing::NiceMock<MockBufferPacker> mock_ipc_operations;241 testing::NiceMock<MockBufferPacker> mock_ipc_operations;
271 std::shared_ptr<testing::NiceMock<mtd::MockShell>> const shell;242 std::shared_ptr<testing::NiceMock<mtd::MockShell>> const shell;
272 std::shared_ptr<MockPlatform> const graphics_platform;
273 std::shared_ptr<mf::DisplayChanger> const graphics_changer;243 std::shared_ptr<mf::DisplayChanger> const graphics_changer;
274 std::vector<MirPixelFormat> const surface_pixel_formats;244 std::vector<MirPixelFormat> const surface_pixel_formats;
275 std::shared_ptr<mf::SessionMediatorReport> const report;245 std::shared_ptr<mf::SessionMediatorReport> const report;
@@ -313,7 +283,7 @@
313 };283 };
314284
315 mf::SessionMediator mediator{285 mf::SessionMediator mediator{
316 shell, graphics_platform, graphics_changer,286 shell, mt::fake_shared(mock_ipc_operations), graphics_changer,
317 surface_pixel_formats, report,287 surface_pixel_formats, report,
318 std::make_shared<mtd::NullEventSink>(),288 std::make_shared<mtd::NullEventSink>(),
319 resource_cache, stub_screencast, context, nullptr, nullptr};289 resource_cache, stub_screencast, context, nullptr, nullptr};
@@ -417,7 +387,7 @@
417 .WillByDefault(Return(mt::fake_shared(config)));387 .WillByDefault(Return(mt::fake_shared(config)));
418388
419 mf::SessionMediator mediator(389 mf::SessionMediator mediator(
420 shell, graphics_platform, mock_display,390 shell, mt::fake_shared(mock_ipc_operations), mock_display,
421 surface_pixel_formats, report,391 surface_pixel_formats, report,
422 std::make_shared<mtd::NullEventSink>(),392 std::make_shared<mtd::NullEventSink>(),
423 resource_cache, std::make_shared<mtd::NullScreencast>(),393 resource_cache, std::make_shared<mtd::NullScreencast>(),
@@ -619,7 +589,7 @@
619 .WillOnce(Return(mt::fake_shared(stub_display_config)));589 .WillOnce(Return(mt::fake_shared(stub_display_config)));
620590
621 mf::SessionMediator mediator{591 mf::SessionMediator mediator{
622 shell, graphics_platform, mock_display_selector,592 shell, mt::fake_shared(mock_ipc_operations), mock_display_selector,
623 surface_pixel_formats, report,593 surface_pixel_formats, report,
624 std::make_shared<mtd::NullEventSink>(), resource_cache,594 std::make_shared<mtd::NullEventSink>(), resource_cache,
625 std::make_shared<mtd::NullScreencast>(),595 std::make_shared<mtd::NullScreencast>(),
@@ -873,7 +843,7 @@
873 EXPECT_CALL(mock_cache, save_fd(_,fake_fd2));843 EXPECT_CALL(mock_cache, save_fd(_,fake_fd2));
874844
875 mf::SessionMediator mediator{845 mf::SessionMediator mediator{
876 shell, graphics_platform, graphics_changer,846 shell, mt::fake_shared(mock_ipc_operations), graphics_changer,
877 surface_pixel_formats, report,847 surface_pixel_formats, report,
878 std::make_shared<mtd::NullEventSink>(),848 std::make_shared<mtd::NullEventSink>(),
879 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr};849 mt::fake_shared(mock_cache), stub_screencast, &connector, nullptr, nullptr};
@@ -891,3 +861,52 @@
891 buffer_request.mutable_buffer()->set_buffer_id(exchanged_buffer.buffer_id());861 buffer_request.mutable_buffer()->set_buffer_id(exchanged_buffer.buffer_id());
892 buffer_request.mutable_buffer()->clear_fd();862 buffer_request.mutable_buffer()->clear_fd();
893}863}
864
865//FIXME: we have an platform specific request in the protocol!
866TEST_F(SessionMediator, drm_auth_magic_calls_platform_operation_abstraction)
867{
868 using namespace testing;
869
870 int magic{0x3248};
871 int test_response{4};
872 mg::PlatformIPCPackage response{{test_response}, {}};
873 mg::PlatformIPCPackage request;
874 drm_request.set_magic(magic);
875
876 EXPECT_CALL(mock_ipc_operations, platform_operation(_, _))
877 .Times(1)
878 .WillOnce(DoAll(SaveArg<1>(&request), Return(response)));
879
880 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
881 mediator.drm_auth_magic(nullptr, &drm_request, &drm_response, null_callback.get());
882 mediator.disconnect(nullptr, nullptr, nullptr, null_callback.get());
883
884 ASSERT_THAT(request.ipc_data.size(), Eq(1));
885 EXPECT_THAT(request.ipc_data[0], Eq(magic));
886 EXPECT_THAT(drm_response.status_code(), Eq(test_response));
887}
888
889TEST_F(SessionMediator, drm_auth_magic_sets_status_code_on_error)
890{
891 using namespace testing;
892
893 mp::ConnectParameters connect_parameters;
894 mp::Connection connection;
895
896 unsigned int const drm_magic{0x10111213};
897 int const error_number{667};
898
899 EXPECT_CALL(mock_ipc_operations, platform_operation(_, _))
900 .WillOnce(Throw(::boost::enable_error_info(std::exception())
901 << boost::errinfo_errno(error_number)));
902
903 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
904
905 mp::DRMMagic magic;
906 mp::DRMAuthMagicStatus status;
907 magic.set_magic(drm_magic);
908
909 mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get());
910
911 EXPECT_EQ(error_number, status.status_code());
912}
894913
=== removed file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2014-10-27 22:31:16 +0000
+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * 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 as
6 * 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#include "mir/frontend/session_mediator_report.h"
20#include "src/server/frontend/session_mediator.h"
21#include "src/server/frontend/resource_cache.h"
22#include "src/server/scene/application_session.h"
23#include "src/server/report/null_report_factory.h"
24#include "mir/frontend/shell.h"
25#include "mir/scene/surface_creation_parameters.h"
26#include "mir/graphics/display.h"
27#include "mir/graphics/platform.h"
28#include "mir/graphics/platform_ipc_package.h"
29
30#include "mir_test_doubles/null_display_changer.h"
31#include "mir_test_doubles/mock_session.h"
32#include "mir_test_doubles/stub_shell.h"
33#include "mir_test_doubles/null_platform.h"
34#include "mir_test_doubles/null_event_sink.h"
35#include "mir_test_doubles/stub_buffer_allocator.h"
36#include "mir_test_doubles/null_screencast.h"
37
38#include <gtest/gtest.h>
39
40#include <stdexcept>
41
42namespace mf = mir::frontend;
43namespace mg = mir::graphics;
44namespace geom = mir::geometry;
45namespace mp = mir::protobuf;
46namespace mtd = mir::test::doubles;
47namespace mr = mir::report;
48
49namespace
50{
51
52struct SessionMediatorAndroidTest : public ::testing::Test
53{
54 SessionMediatorAndroidTest()
55 : shell{std::make_shared<mtd::StubShell>()},
56 graphics_platform{std::make_shared<mtd::NullPlatform>()},
57 display_changer{std::make_shared<mtd::NullDisplayChanger>()},
58 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},
59 report{mr::null_session_mediator_report()},
60 resource_cache{std::make_shared<mf::ResourceCache>()},
61 mediator{shell, graphics_platform, display_changer,
62 surface_pixel_formats, report,
63 std::make_shared<mtd::NullEventSink>(),
64 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr, nullptr},
65 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
66 {
67 }
68
69 std::shared_ptr<mtd::StubShell> const shell;
70 std::shared_ptr<mtd::NullPlatform> const graphics_platform;
71 std::shared_ptr<mf::DisplayChanger> const display_changer;
72 std::vector<MirPixelFormat> const surface_pixel_formats;
73 std::shared_ptr<mf::SessionMediatorReport> const report;
74 std::shared_ptr<mf::ResourceCache> const resource_cache;
75 mf::SessionMediator mediator;
76
77 std::unique_ptr<google::protobuf::Closure> null_callback;
78};
79
80}
81
82TEST_F(SessionMediatorAndroidTest, drm_auth_magic_throws)
83{
84 mp::ConnectParameters connect_parameters;
85 mp::Connection connection;
86
87 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
88
89 mp::DRMMagic magic;
90 magic.set_magic(0x10111213);
91
92 EXPECT_THROW({
93 mediator.drm_auth_magic(nullptr, &magic, nullptr, null_callback.get());
94 }, std::logic_error);
95}
960
=== removed file 'tests/unit-tests/frontend/test_session_mediator_mesa.cpp'
--- tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-10-27 22:31:16 +0000
+++ tests/unit-tests/frontend/test_session_mediator_mesa.cpp 1970-01-01 00:00:00 +0000
@@ -1,141 +0,0 @@
1/*
2 * Copyright © 2012-2014 Canonical Ltd.
3 *
4 * 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 as
6 * 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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#include "mir/frontend/session_mediator_report.h"
20#include "src/server/frontend/session_mediator.h"
21#include "src/server/frontend/resource_cache.h"
22#include "src/server/scene/application_session.h"
23#include "src/server/frontend/session_mediator.h"
24#include "src/server/report/null_report_factory.h"
25#include "mir/frontend/shell.h"
26#include "mir/graphics/display.h"
27#include "mir/graphics/drm_authenticator.h"
28#include "mir/frontend/event_sink.h"
29
30#include <boost/exception/errinfo_errno.hpp>
31#include <boost/throw_exception.hpp>
32
33#include "mir_test_doubles/null_display.h"
34#include "mir_test_doubles/null_event_sink.h"
35#include "mir_test_doubles/null_display_changer.h"
36#include "mir_test_doubles/null_platform.h"
37#include "mir_test_doubles/mock_session.h"
38#include "mir_test_doubles/stub_shell.h"
39#include "mir_test_doubles/null_screencast.h"
40
41#include <gtest/gtest.h>
42#include <gmock/gmock.h>
43
44namespace mf = mir::frontend;
45namespace mg = mir::graphics;
46namespace geom = mir::geometry;
47namespace mp = mir::protobuf;
48namespace mtd = mir::test::doubles;
49namespace mr = mir::report;
50
51namespace
52{
53
54class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator
55{
56 public:
57 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
58 {
59 return std::shared_ptr<mg::GraphicBufferAllocator>();
60 }
61
62 MOCK_METHOD1(drm_auth_magic, void(unsigned int));
63};
64
65struct SessionMediatorMesaTest : public ::testing::Test
66{
67 SessionMediatorMesaTest()
68 : shell{std::make_shared<mtd::StubShell>()},
69 mock_platform{std::make_shared<MockAuthenticatingPlatform>()},
70 display_changer{std::make_shared<mtd::NullDisplayChanger>()},
71 surface_pixel_formats{mir_pixel_format_argb_8888, mir_pixel_format_xrgb_8888},
72 report{mr::null_session_mediator_report()},
73 resource_cache{std::make_shared<mf::ResourceCache>()},
74 mediator{shell, mock_platform, display_changer,
75 surface_pixel_formats, report,
76 std::make_shared<mtd::NullEventSink>(),
77 resource_cache, std::make_shared<mtd::NullScreencast>(), nullptr, nullptr,
78 nullptr},
79 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
80 {
81 }
82
83 std::shared_ptr<mtd::StubShell> const shell;
84 std::shared_ptr<MockAuthenticatingPlatform> const mock_platform;
85 std::shared_ptr<mf::DisplayChanger> const display_changer;
86 std::vector<MirPixelFormat> const surface_pixel_formats;
87 std::shared_ptr<mf::SessionMediatorReport> const report;
88 std::shared_ptr<mf::ResourceCache> const resource_cache;
89 mf::SessionMediator mediator;
90
91 std::unique_ptr<google::protobuf::Closure> null_callback;
92};
93
94}
95
96TEST_F(SessionMediatorMesaTest, drm_auth_magic_uses_drm_authenticator)
97{
98 mp::ConnectParameters connect_parameters;
99 mp::Connection connection;
100
101 unsigned int const drm_magic{0x10111213};
102 int const no_error{0};
103
104 EXPECT_CALL(*mock_platform, drm_auth_magic(drm_magic))
105 .Times(1);
106
107 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
108
109 mp::DRMMagic magic;
110 mp::DRMAuthMagicStatus status;
111 magic.set_magic(drm_magic);
112
113 mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get());
114
115 EXPECT_EQ(no_error, status.status_code());
116}
117
118TEST_F(SessionMediatorMesaTest, drm_auth_magic_sets_status_code_on_error)
119{
120 using namespace testing;
121
122 mp::ConnectParameters connect_parameters;
123 mp::Connection connection;
124
125 unsigned int const drm_magic{0x10111213};
126 int const error_number{667};
127
128 EXPECT_CALL(*mock_platform, drm_auth_magic(drm_magic))
129 .WillOnce(Throw(::boost::enable_error_info(std::exception())
130 << boost::errinfo_errno(error_number)));
131
132 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
133
134 mp::DRMMagic magic;
135 mp::DRMAuthMagicStatus status;
136 magic.set_magic(drm_magic);
137
138 mediator.drm_auth_magic(nullptr, &magic, &status, null_callback.get());
139
140 EXPECT_EQ(error_number, status.status_code());
141}
1420
=== modified file 'tests/unit-tests/graphics/android/CMakeLists.txt'
--- tests/unit-tests/graphics/android/CMakeLists.txt 2014-10-01 06:25:56 +0000
+++ tests/unit-tests/graphics/android/CMakeLists.txt 2014-11-13 16:42:20 +0000
@@ -13,6 +13,7 @@
13 ${CMAKE_CURRENT_SOURCE_DIR}/test_display_buffer.cpp13 ${CMAKE_CURRENT_SOURCE_DIR}/test_display_buffer.cpp
14 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client_interpreter.cpp14 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client_interpreter.cpp
15 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp15 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp
16 ${CMAKE_CURRENT_SOURCE_DIR}/test_ipc_operations.cpp
16 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_factory.cpp17 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_factory.cpp
17 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp18 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp
18 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp19 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp
1920
=== added file 'tests/unit-tests/graphics/android/test_ipc_operations.cpp'
--- tests/unit-tests/graphics/android/test_ipc_operations.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/android/test_ipc_operations.cpp 2014-11-13 16:42:20 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * 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 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "src/platform/graphics/android/ipc_operations.h"
20#include "mir/graphics/platform_ipc_package.h"
21#include <gtest/gtest.h>
22
23namespace mg = mir::graphics;
24namespace mga = mir::graphics::android;
25
26struct IpcOperations : public ::testing::Test
27{
28 mga::IpcOperations ipc_operations;
29};
30
31/* ipc packaging tests */
32TEST_F(IpcOperations, test_ipc_data_packed_correctly_for_full_ipc)
33{
34 //android has no valid operations platform specific operations yet, expect throw
35 mg::PlatformIPCPackage package{
36 std::vector<int32_t>{2,4,8,16,32},
37 std::vector<int32_t>{fileno(tmpfile()), fileno(tmpfile())}
38 };
39
40 EXPECT_THROW({
41 ipc_operations.platform_operation(0u, package);
42 }, std::invalid_argument);
43
44 EXPECT_THROW({
45 ipc_operations.platform_operation(1u, package);
46 }, std::invalid_argument);
47
48 for (auto fd : package.ipc_fds)
49 close(fd);
50}
051
=== modified file 'tests/unit-tests/graphics/mesa/test_platform.cpp'
--- tests/unit-tests/graphics/mesa/test_platform.cpp 2014-10-27 13:06:48 +0000
+++ tests/unit-tests/graphics/mesa/test_platform.cpp 2014-11-13 16:42:20 +0000
@@ -200,9 +200,13 @@
200 EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic))200 EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic))
201 .WillOnce(Return(0));201 .WillOnce(Return(0));
202202
203 mg::PlatformIPCPackage magic_pkg{{magic}, {}};
204 int drm_opcode{44};
203 auto platform = create_platform();205 auto platform = create_platform();
204 auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform);206 auto ipc_ops = platform->make_ipc_operations();
205 authenticator->drm_auth_magic(magic);207 auto response_pkg = ipc_ops->platform_operation(drm_opcode, magic_pkg);
208 ASSERT_THAT(response_pkg.ipc_data.size(), Eq(1));
209 EXPECT_THAT(response_pkg.ipc_data[0], Eq(0));
206}210}
207211
208TEST_F(MesaGraphicsPlatform, drm_auth_magic_throws_if_drm_function_fails)212TEST_F(MesaGraphicsPlatform, drm_auth_magic_throws_if_drm_function_fails)
@@ -214,11 +218,13 @@
214 EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic))218 EXPECT_CALL(mock_drm, drmAuthMagic(mock_drm.fake_drm.fd(),magic))
215 .WillOnce(Return(-1));219 .WillOnce(Return(-1));
216220
221 int drm_opcode{44};
217 auto platform = create_platform();222 auto platform = create_platform();
218 auto authenticator = std::dynamic_pointer_cast<mg::DRMAuthenticator>(platform);223 auto ipc_ops = platform->make_ipc_operations();
224 mg::PlatformIPCPackage magic_pkg{{magic}, {}};
219225
220 EXPECT_THROW({226 EXPECT_THROW({
221 authenticator->drm_auth_magic(magic);227 ipc_ops->platform_operation(drm_opcode, magic_pkg);
222 }, std::runtime_error);228 }, std::runtime_error);
223}229}
224230

Subscribers

People subscribed via source and target branches