~alan-griffiths/mir/revert-c2238

« back to all changes in this revision

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

  • Committer: Alan Griffiths
  • Date: 2015-01-22 14:26:25 UTC
  • Revision ID: alan@octopull.co.uk-20150122142625-xn7mti22rksa4cga
merge -r2238..2237 ..

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "mir/scene/surface.h"
22
22
#include "mir/shell/surface_coordinator_wrapper.h"
 
23
#include "mir/shell/focus_setter.h"
23
24
 
24
25
#include "mir_test_framework/connected_client_with_a_surface.h"
25
26
#include "mir_test/wait_condition.h"
39
40
 
40
41
namespace
41
42
{
 
43
 
42
44
class StoringSurfaceCoordinator : public msh::SurfaceCoordinatorWrapper
43
45
{
44
46
public:
58
60
        return surfaces[index].lock();
59
61
    }
60
62
 
61
 
    void raise(std::weak_ptr<ms::Surface> const& /*surface*/) override
62
 
    {
63
 
         // We get some racy "raise" requests from the DefaultFocusManagement
64
 
         // so we ignore any raise requests that we don't issue ourselves
65
 
    }
66
 
 
67
 
    void raise(int index)
68
 
    {
69
 
         msh::SurfaceCoordinatorWrapper::raise(surface(index));
70
 
    }
71
 
 
72
63
private:
73
64
    std::vector<std::weak_ptr<ms::Surface>> surfaces;
74
65
 
97
88
 
98
89
    void SetUp() override
99
90
    {
100
 
        server.wrap_surface_coordinator([&]
 
91
        server.wrap_surface_coordinator([]
101
92
            (std::shared_ptr<ms::SurfaceCoordinator> const& wrapped)
102
93
            {
103
 
                auto const result = std::make_shared<StoringSurfaceCoordinator>(wrapped);
104
 
                storing_surface_coordinator = result;
105
 
                return result;
 
94
                return std::make_shared<StoringSurfaceCoordinator>(wrapped);
 
95
            });
 
96
 
 
97
        /*
 
98
         * Use a null focus setter so that it doesn't change the surface
 
99
         * order and introduce races to our tests.
 
100
         */
 
101
        server.override_the_shell_focus_setter([]
 
102
            {
 
103
                struct NullFocusSetter : msh::FocusSetter
 
104
                {
 
105
                    void set_focus_to(std::shared_ptr<ms::Session> const&) override {}
 
106
                };
 
107
 
 
108
                return std::make_shared<NullFocusSetter>();
106
109
            });
107
110
 
108
111
        mtf::ConnectedClientWithASurface::SetUp();
134
137
    
135
138
        mir_surface_spec_release(spec);
136
139
 
137
 
        storing_surface_coordinator.lock()->raise(1);
 
140
        server.the_surface_coordinator()->raise(server_surface(1));
138
141
 
139
142
        mir_surface_swap_buffers_sync(second_surface);
140
143
    }
141
144
 
142
145
    std::shared_ptr<ms::Surface> server_surface(size_t index)
143
146
    {
144
 
        return storing_surface_coordinator.lock()->surface(index);
 
147
        auto const storing_surface_coordinator =
 
148
            std::dynamic_pointer_cast<StoringSurfaceCoordinator>(server.the_surface_coordinator());
 
149
 
 
150
        return storing_surface_coordinator->surface(index);
145
151
    }
146
152
 
147
153
    void move_surface_off_screen()
156
162
 
157
163
    void raise_surface_on_top()
158
164
    {
159
 
        storing_surface_coordinator.lock()->raise(0);
 
165
        server.the_surface_coordinator()->raise(server_surface(0));
160
166
    }
161
167
 
162
168
    void expect_surface_visibility_event_after(
184
190
 
185
191
    MirSurface* second_surface = nullptr;
186
192
    testing::NiceMock<MockVisibilityCallback> mock_visibility_callback;
187
 
    std::weak_ptr<StoringSurfaceCoordinator> storing_surface_coordinator;
188
193
};
189
194
 
190
195
}