~alan-griffiths/mir/fix-1654023

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/test_debug_api.cpp

  • Committer: Daniel van Vugt
  • Date: 2015-04-28 07:54:10 UTC
  • mfrom: (2517 development-branch)
  • mto: This revision was merged to the branch mainline in revision 2673.
  • Revision ID: daniel.van.vugt@canonical.com-20150428075410-rwskshfuar7voesp
Merge latest trunk and fix conflicts.

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
16
16
 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17
17
 */
18
18
 
 
19
#include "mir/scene/session.h"
 
20
#include "mir/scene/surface.h"
19
21
#include "mir/scene/surface_creation_parameters.h"
20
 
#include "mir/scene/placement_strategy.h"
 
22
#include "mir/shell/shell_wrapper.h"
21
23
 
22
24
#include "mir_test_framework/headless_test.h"
23
25
#include "mir_test_framework/any_surface.h"
29
31
#include <gmock/gmock.h>
30
32
 
31
33
namespace ms = mir::scene;
 
34
namespace msh = mir::shell;
32
35
 
33
36
namespace mtf = mir_test_framework;
34
37
 
35
38
namespace
36
39
{
37
 
class SimpleConfigurablePlacementStrategy : public ms::PlacementStrategy
 
40
class SimpleConfigurablePlacementShell : public msh::ShellWrapper
38
41
{
39
42
public:
40
 
    ms::SurfaceCreationParameters place(ms::Session const& /*session*/,
41
 
                                        ms::SurfaceCreationParameters const& request_parameters) override
 
43
    using msh::ShellWrapper::ShellWrapper;
 
44
 
 
45
    mir::frontend::SurfaceId create_surface(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)
42
46
    {
43
 
        return ms::SurfaceCreationParameters(request_parameters)
44
 
            .of_position(placement.top_left)
45
 
            .of_size(placement.size);
 
47
        auto const result = msh::ShellWrapper::create_surface(session, params);
 
48
        auto const surface = session->surface(result);
 
49
 
 
50
        surface->move_to(placement.top_left);
 
51
        surface->resize(placement.size);
 
52
 
 
53
        return result;
46
54
    }
47
55
 
48
56
    mir::geometry::Rectangle placement{{0, 0}, {100, 100}};
62
70
    {
63
71
        add_to_environment("MIR_SERVER_NO_FILE", "");
64
72
 
65
 
        server.override_the_placement_strategy([&]{ return placement_strategy; });
 
73
        server.wrap_shell([&](std::shared_ptr<msh::Shell> const& wrapped)
 
74
        {
 
75
            return placement_strategy =
 
76
                std::make_shared<SimpleConfigurablePlacementShell>(wrapped);
 
77
        });
 
78
 
66
79
        mtf::HeadlessTest::SetUp();
67
80
    }
68
81
 
107
120
    MirConnection* connection{nullptr};
108
121
 
109
122
private:
110
 
    std::shared_ptr<SimpleConfigurablePlacementStrategy> const placement_strategy
111
 
        {std::make_shared<SimpleConfigurablePlacementStrategy>()};
 
123
    std::shared_ptr<SimpleConfigurablePlacementShell> placement_strategy;
112
124
};
113
125
}
114
126