37
struct MySurfaceCoordinator : msh::SurfaceCoordinatorWrapper
38
struct MyShell : msh::ShellWrapper
39
using msh::SurfaceCoordinatorWrapper::SurfaceCoordinatorWrapper;
40
MOCK_METHOD1(raise, void(std::weak_ptr<ms::Surface> const&));
40
using msh::ShellWrapper::ShellWrapper;
41
MOCK_METHOD1(handle_surface_created, void(std::shared_ptr<ms::Session> const&));
43
struct MySessionCoordinator : msh::SessionCoordinatorWrapper
44
struct MyCursorListener : mi::CursorListener
45
using msh::SessionCoordinatorWrapper::SessionCoordinatorWrapper;
47
MOCK_METHOD0(unset_focus, void());
46
MyCursorListener(std::shared_ptr<mi::CursorListener> const& wrapped) :
49
MOCK_METHOD2(cursor_moved_to, void(float abs_x, float abs_y));
51
std::shared_ptr<mi::CursorListener> const wrapped;
50
54
struct ServerConfigurationWrapping : mir_test_framework::HeadlessTest
52
56
void SetUp() override
54
server.wrap_surface_coordinator([]
55
(std::shared_ptr<ms::SurfaceCoordinator> const& wrapped)
59
(std::shared_ptr<msh::Shell> const& wrapped)
57
return std::make_shared<MySurfaceCoordinator>(wrapped);
61
return std::make_shared<MyShell>(wrapped);
60
server.wrap_session_coordinator([]
61
(std::shared_ptr<ms::SessionCoordinator> const& wrapped)
64
server.wrap_cursor_listener([]
65
(std::shared_ptr<mi::CursorListener> const& wrapped)
63
return std::make_shared<MySessionCoordinator>(wrapped);
67
return std::make_shared<MyCursorListener>(wrapped);
66
70
server.apply_settings();
68
surface_coordinator = server.the_surface_coordinator();
69
session_coordinator = server.the_session_coordinator();
72
shell = server.the_shell();
73
cursor_listener = server.the_cursor_listener();
72
std::shared_ptr<ms::SurfaceCoordinator> surface_coordinator;
73
std::shared_ptr<ms::SessionCoordinator> session_coordinator;
76
std::shared_ptr<msh::Shell> shell;
77
std::shared_ptr<mi::CursorListener> cursor_listener;
77
TEST_F(ServerConfigurationWrapping, surface_coordinator_is_of_wrapper_type)
79
auto const my_surface_coordinator = std::dynamic_pointer_cast<MySurfaceCoordinator>(surface_coordinator);
81
EXPECT_THAT(my_surface_coordinator, Ne(nullptr));
84
TEST_F(ServerConfigurationWrapping, can_override_surface_coordinator_methods)
86
auto const my_surface_coordinator = std::dynamic_pointer_cast<MySurfaceCoordinator>(surface_coordinator);
88
EXPECT_CALL(*my_surface_coordinator, raise(_)).Times(1);
89
surface_coordinator->raise({});
92
TEST_F(ServerConfigurationWrapping, returns_same_surface_coordinator_from_cache)
94
ASSERT_THAT(server.the_surface_coordinator(), Eq(surface_coordinator));
97
TEST_F(ServerConfigurationWrapping, session_coordinator_is_of_wrapper_type)
99
auto const my_session_coordinator = std::dynamic_pointer_cast<MySessionCoordinator>(session_coordinator);
101
EXPECT_THAT(my_session_coordinator, Ne(nullptr));
104
TEST_F(ServerConfigurationWrapping, can_override_session_coordinator_methods)
106
auto const my_session_coordinator = std::dynamic_pointer_cast<MySessionCoordinator>(session_coordinator);
108
EXPECT_CALL(*my_session_coordinator, unset_focus()).Times(1);
109
session_coordinator->unset_focus();
112
TEST_F(ServerConfigurationWrapping, returns_same_session_coordinator_from_cache)
114
ASSERT_THAT(server.the_session_coordinator(), Eq(session_coordinator));
81
TEST_F(ServerConfigurationWrapping, shell_is_of_wrapper_type)
83
auto const my_shell = std::dynamic_pointer_cast<MyShell>(shell);
85
EXPECT_THAT(my_shell, Ne(nullptr));
88
TEST_F(ServerConfigurationWrapping, can_override_shell_methods)
90
auto const my_shell = std::dynamic_pointer_cast<MyShell>(shell);
92
EXPECT_CALL(*my_shell, handle_surface_created(_)).Times(1);
93
shell->handle_surface_created({});
96
TEST_F(ServerConfigurationWrapping, returns_same_shell_from_cache)
98
ASSERT_THAT(server.the_shell(), Eq(shell));
101
TEST_F(ServerConfigurationWrapping, cursor_listener_is_of_wrapper_type)
103
auto const my_cursor_listener = std::dynamic_pointer_cast<MyCursorListener>(cursor_listener);
105
EXPECT_THAT(my_cursor_listener, Ne(nullptr));
108
TEST_F(ServerConfigurationWrapping, can_override_cursor_listener_methods)
110
float const abs_x{1};
111
float const abs_y(2);
113
auto const my_cursor_listener = std::dynamic_pointer_cast<MyCursorListener>(cursor_listener);
115
EXPECT_CALL(*my_cursor_listener, cursor_moved_to(abs_x, abs_y)).Times(1);
116
cursor_listener->cursor_moved_to(abs_x, abs_y);
119
TEST_F(ServerConfigurationWrapping, returns_same_cursor_listener_from_cache)
121
ASSERT_THAT(server.the_cursor_listener(), Eq(cursor_listener));