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

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/test_client_surface_events.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:
1
1
/*
2
 
 * Copyright © 2014 Canonical Ltd.
 
2
 * Copyright © 2014-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License version 3 as
21
21
#include "mir_toolkit/mir_client_library.h"
22
22
#include "mir_toolkit/debug/surface.h"
23
23
 
24
 
#include "mir/shell/surface_coordinator_wrapper.h"
 
24
#include "mir/shell/shell_wrapper.h"
25
25
 
 
26
#include "mir/scene/session.h"
26
27
#include "mir/scene/surface.h"
27
28
#include "mir/scene/surface_creation_parameters.h"
28
29
 
36
37
#include <chrono>
37
38
#include <mutex>
38
39
 
 
40
namespace mf = mir::frontend;
39
41
namespace mtf = mir_test_framework;
40
42
namespace ms = mir::scene;
41
43
namespace msh = mir::shell;
44
46
 
45
47
namespace
46
48
{
47
 
struct MockSurfaceCoordinator : msh::SurfaceCoordinatorWrapper
 
49
struct MockShell : msh::ShellWrapper
48
50
{
49
 
    MockSurfaceCoordinator(std::shared_ptr<ms::SurfaceCoordinator> const& wrapped) :
50
 
        msh::SurfaceCoordinatorWrapper(wrapped)
51
 
    {
52
 
    }
 
51
    using msh::ShellWrapper::ShellWrapper;
53
52
 
54
 
    std::shared_ptr<ms::Surface> add_surface(
55
 
        ms::SurfaceCreationParameters const& params,
56
 
        ms::Session* session) override
 
53
    mf::SurfaceId create_surface(
 
54
        std::shared_ptr<ms::Session> const& session,
 
55
        ms::SurfaceCreationParameters const& params) override
57
56
    {
58
 
        latest_surface = wrapped->add_surface(params, session);
59
 
        return latest_surface;
 
57
        auto const surface = msh::ShellWrapper::create_surface(session, params);
 
58
        latest_surface = session->surface(surface);
 
59
        return surface;
60
60
    }
61
61
 
62
62
    std::shared_ptr<ms::Surface> latest_surface;
106
106
        last_event_surface = nullptr;
107
107
    }
108
108
 
109
 
    std::shared_ptr<MockSurfaceCoordinator> the_mock_surface_coordinator() const
 
109
    std::shared_ptr<MockShell> the_mock_shell() const
110
110
    {
111
 
        return mock_surface_coordinator.lock();
 
111
        return mock_shell.lock();
112
112
    }
113
113
 
114
114
    std::shared_ptr<ms::Surface> the_latest_surface() const
115
115
    {
116
 
        return the_mock_surface_coordinator()->latest_surface;
 
116
        return the_mock_shell()->latest_surface;
117
117
    }
118
118
 
119
119
    void SetUp() override
120
120
    {
121
 
        server.wrap_surface_coordinator([&](std::shared_ptr<ms::SurfaceCoordinator> const& wrapped)
122
 
            -> std::shared_ptr<ms::SurfaceCoordinator>
 
121
        server.wrap_shell([&](std::shared_ptr<msh::Shell> const& wrapped)
 
122
            -> std::shared_ptr<msh::Shell>
123
123
        {
124
 
            auto const msc = std::make_shared<MockSurfaceCoordinator>(wrapped);
125
 
            mock_surface_coordinator = msc;
 
124
            auto const msc = std::make_shared<MockShell>(wrapped);
 
125
            mock_shell = msc;
126
126
            return msc;
127
127
        });
128
128
 
146
146
        mtf::ConnectedClientWithASurface::TearDown();
147
147
    }
148
148
 
149
 
    std::weak_ptr<MockSurfaceCoordinator> mock_surface_coordinator;
 
149
    std::weak_ptr<MockShell> mock_shell;
150
150
};
151
151
}
152
152