~brandontschaefer/mir/first-round-deprecation

« back to all changes in this revision

Viewing changes to tests/unit-tests/client/test_connection_resource_map.cpp

  • Committer: Brandon Schaefer
  • Date: 2016-12-13 17:59:30 UTC
  • mfrom: (3787.1.93 development-branch)
  • Revision ID: brandon.schaefer@canonical.com-20161213175930-j9o7qn0b11n3kzlm
* Merge trunk, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "src/client/mir_surface.h"
21
21
#include "src/client/presentation_chain.h"
22
22
#include "src/client/render_surface.h"
23
 
#include "mir/test/doubles/mock_client_buffer_stream.h"
 
23
#include "mir/test/doubles/mock_mir_buffer_stream.h"
24
24
#include "mir/test/doubles/mock_protobuf_server.h"
25
25
#include <gtest/gtest.h>
26
26
 
38
38
{
39
39
    std::shared_ptr<MirWaitHandle> wh { std::make_shared<MirWaitHandle>() };
40
40
    std::shared_ptr<MirSurface> surface{std::make_shared<MirSurface>("a string", nullptr, mf::SurfaceId{2}, wh)};
41
 
    std::shared_ptr<mcl::ClientBufferStream> stream{ std::make_shared<mtd::MockClientBufferStream>() }; 
 
41
    std::shared_ptr<MirBufferStream> stream{ std::make_shared<mtd::MockMirBufferStream>() }; 
42
42
    std::shared_ptr<mcl::Buffer> buffer {
43
43
        std::make_shared<mcl::Buffer>(buffer_cb, nullptr, 0, nullptr, nullptr, mir_buffer_usage_software) };
44
44
    mtd::MockProtobufServer mock_server;
45
45
    std::shared_ptr<mcl::PresentationChain> chain{ std::make_shared<mcl::PresentationChain>(
46
46
        nullptr, 0, mock_server, nullptr, nullptr) };
47
47
    std::shared_ptr<MirRenderSurface> render_surface { std::make_shared<mcl::RenderSurface>(
48
 
        nullptr, nullptr, nullptr) };
 
48
        nullptr, nullptr, nullptr, nullptr, mir::geometry::Size{0, 0}) };
49
49
 
50
50
    mf::SurfaceId const surface_id{43};
51
51
    mf::BufferStreamId const stream_id{43};
56
56
TEST_F(ConnectionResourceMap, maps_surface_when_surface_inserted)
57
57
{
58
58
    using namespace testing;
59
 
    auto surface_called = false;
60
59
    mcl::ConnectionSurfaceMap map;
61
60
    map.insert(surface_id, surface);
62
 
    map.with_surface_do(surface_id, [&](MirSurface* surf) {
63
 
        EXPECT_THAT(surf, Eq(surface.get()));
64
 
        surface_called = true;
65
 
    });
66
 
 
67
 
    EXPECT_TRUE(surface_called);
 
61
    EXPECT_EQ(surface, map.surface(surface_id));
68
62
}
69
63
 
70
64
TEST_F(ConnectionResourceMap, removes_surface_when_surface_removed)
73
67
    mcl::ConnectionSurfaceMap map;
74
68
    map.insert(surface_id, surface);
75
69
    map.erase(surface_id);
76
 
    EXPECT_THROW({
77
 
        map.with_stream_do(stream_id, [](mcl::ClientBufferStream*){});
78
 
    }, std::runtime_error);
 
70
    EXPECT_FALSE(map.stream(stream_id));
79
71
}
80
72
 
81
73
TEST_F(ConnectionResourceMap, maps_streams)
82
74
{
83
75
    using namespace testing;
84
 
    auto stream_called = false;
85
76
    mcl::ConnectionSurfaceMap map;
86
77
    map.insert(stream_id, stream);
87
 
    map.with_stream_do(stream_id, [&](mcl::ClientBufferStream* str) {
88
 
        EXPECT_THAT(str, Eq(stream.get()));
89
 
        stream_called = true;
90
 
    });
91
 
    EXPECT_TRUE(stream_called);
 
78
    EXPECT_EQ(stream, map.stream(stream_id));
92
79
    map.erase(stream_id);
93
80
}
94
81
 
126
113
    mcl::ConnectionSurfaceMap map;
127
114
    map.insert(buffer_id, buffer);
128
115
    map.insert(surface_id, surface);
129
 
 
130
 
    map.with_surface_do(surface_id,
131
 
        [this, &map](auto) {
132
 
            EXPECT_THAT(map.buffer(buffer_id), Eq(buffer));
133
 
        });
 
116
    EXPECT_EQ(buffer, map.buffer(buffer_id));
134
117
}
135
118
 
136
119
TEST_F(ConnectionResourceMap, can_insert_retrieve_erase_render_surface)