~albaguirre/mir/backport-fixes-to-0.11

« back to all changes in this revision

Viewing changes to tests/integration-tests/client/test_mirsurface.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2015-01-28 20:21:34 UTC
  • mfrom: (2257.1.31 mir3)
  • Revision ID: tarmac-20150128202134-dn97lf8gwk0xcqbc
shell, frontend: Provide a mir::shell::Shell customization point.

Approved by PS Jenkins bot, Kevin DuBois, Alexandros Frantzis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "mir/scene/surface.h"
25
25
#include "mir/scene/surface_creation_parameters.h"
26
 
#include "mir/shell/surface_coordinator_wrapper.h"
 
26
#include "mir/shell/shell_wrapper.h"
27
27
#include "src/client/mir_surface.h"
28
28
#include "src/include/common/mir/raii.h"
29
29
 
41
41
 
42
42
namespace
43
43
{
44
 
struct MockSurfaceCoordinator : msh::SurfaceCoordinatorWrapper
 
44
struct MockShell : msh::ShellWrapper
45
45
{
46
 
    using msh::SurfaceCoordinatorWrapper::SurfaceCoordinatorWrapper;
47
 
    MOCK_METHOD2(add_surface, std::shared_ptr<ms::Surface>(ms::SurfaceCreationParameters const&, ms::Session*));
 
46
    using msh::ShellWrapper::ShellWrapper;
 
47
    MOCK_METHOD2(create_surface, mf::SurfaceId(std::shared_ptr<ms::Session> const&, ms::SurfaceCreationParameters const&));
48
48
};
49
49
 
50
50
bool parent_field_matches(ms::SurfaceCreationParameters const& params,
120
120
{
121
121
    void SetUp() override
122
122
    {
123
 
        server.wrap_surface_coordinator([this]
124
 
            (std::shared_ptr<ms::SurfaceCoordinator> const& wrapped)
 
123
        server.wrap_shell([this]
 
124
            (std::shared_ptr<msh::Shell> const& wrapped)
125
125
            {
126
 
                wrapped_coord = wrapped;
127
 
                auto const msc = std::make_shared<MockSurfaceCoordinator>(wrapped);
128
 
                mock_surface_coordinator = msc;
 
126
                wrapped_shell = wrapped;
 
127
                auto const msc = std::make_shared<MockShell>(wrapped);
 
128
                mock_shell = msc;
129
129
                return msc;
130
130
            });
131
131
        mtf::ConnectedClientHeadlessServer::SetUp();
132
132
 
133
133
        server.the_surface_coordinator();
134
134
 
135
 
        ON_CALL(*mock_surface_coordinator, add_surface(_, _))
136
 
            .WillByDefault(Invoke(wrapped_coord.get(), &ms::SurfaceCoordinator::add_surface));
 
135
        ON_CALL(*mock_shell, create_surface(_, _))
 
136
            .WillByDefault(Invoke(wrapped_shell.get(), &msh::Shell::create_surface));
137
137
 
138
138
        spec.connection = connection;
139
139
        spec.buffer_usage = mir_buffer_usage_software;
150
150
    }
151
151
 
152
152
    MirSurfaceSpec spec{nullptr, 640, 480, mir_pixel_format_abgr_8888};
153
 
    std::shared_ptr<ms::SurfaceCoordinator> wrapped_coord;
154
 
    std::shared_ptr<MockSurfaceCoordinator> mock_surface_coordinator;
 
153
    std::shared_ptr<msh::Shell> wrapped_shell;
 
154
    std::shared_ptr<MockShell> mock_shell;
155
155
};
156
156
 
157
157
TEST_F(ClientMirSurface, sends_optional_params)
158
158
{
159
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(AllOf(MatchesRequired(&spec), MatchesOptional(&spec)),_));
 
159
    EXPECT_CALL(*mock_shell, create_surface(_,AllOf(MatchesRequired(&spec), MatchesOptional(&spec))));
160
160
 
161
161
    auto surf = create_surface(&spec);
162
162
 
164
164
    ASSERT_THAT(surf.get(), IsValid());
165
165
    spec.parent = surf.get();
166
166
 
167
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(MatchesOptional(&spec),_));
 
167
    EXPECT_CALL(*mock_shell, create_surface(_, MatchesOptional(&spec)));
168
168
    create_surface(&spec);
169
169
}
170
170
 
171
171
TEST_F(ClientMirSurface, as_menu_sends_correct_params)
172
172
{
173
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(_,_));
 
173
    EXPECT_CALL(*mock_shell, create_surface(_,_));
174
174
    auto parent = create_surface(&spec);
175
175
    ASSERT_THAT(parent.get(), IsValid());
176
176
 
187
187
 
188
188
    ASSERT_THAT(menu_spec, NotNull());
189
189
 
190
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(AllOf(IsAMenu(),
191
 
        HasParent(parent.get()), MatchesAuxRect(attachment_rect), MatchesEdge(edge)),_));
 
190
    EXPECT_CALL(*mock_shell, create_surface(_, AllOf(IsAMenu(),
 
191
        HasParent(parent.get()), MatchesAuxRect(attachment_rect), MatchesEdge(edge))));
192
192
    create_surface(menu_spec.get());
193
193
}
194
194
 
195
195
TEST_F(ClientMirSurface, as_tooltip_sends_correct_params)
196
196
{
197
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(_,_));
 
197
    EXPECT_CALL(*mock_shell, create_surface(_,_));
198
198
    auto parent = create_surface(&spec);
199
199
    ASSERT_THAT(parent.get(), IsValid());
200
200
 
209
209
 
210
210
    ASSERT_THAT(tooltip_spec, NotNull());
211
211
 
212
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(AllOf(IsATooltip(),
213
 
        HasParent(parent.get()), MatchesAuxRect(target_zone_rect)),_));
 
212
    EXPECT_CALL(*mock_shell, create_surface(_, AllOf(IsATooltip(),
 
213
        HasParent(parent.get()), MatchesAuxRect(target_zone_rect))));
214
214
    create_surface(tooltip_spec.get());
215
215
}
216
216
 
224
224
 
225
225
    ASSERT_THAT(dialog_spec, NotNull());
226
226
 
227
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(AllOf(IsADialog(),
228
 
        NoParentSet()),_));
 
227
    EXPECT_CALL(*mock_shell, create_surface(_, AllOf(IsADialog(), NoParentSet())));
229
228
    create_surface(dialog_spec.get());
230
229
}
231
230
 
232
231
TEST_F(ClientMirSurface, as_modal_dialog_sends_correct_params)
233
232
{
234
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(_,_));
 
233
    EXPECT_CALL(*mock_shell, create_surface(_,_));
235
234
    auto parent = create_surface(&spec);
236
235
    ASSERT_THAT(parent.get(), IsValid());
237
236
 
244
243
 
245
244
    ASSERT_THAT(dialog_spec, NotNull());
246
245
 
247
 
    EXPECT_CALL(*mock_surface_coordinator, add_surface(AllOf(IsADialog(),
248
 
        HasParent(parent.get())),_));
 
246
    EXPECT_CALL(*mock_shell, create_surface(_, AllOf(IsADialog(), HasParent(parent.get()))));
249
247
    create_surface(dialog_spec.get());
250
248
}