~kgunn72/mir/dont-crash-when-shooting-invalid-surface

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths, Alexandros Frantzis, Daniel van Vugt, Kevin DuBois, Christopher James Halse Rogers, chris.gagnon, Mathieu Trudel-Lapierre, Robert Carr, Automatic PS uploader, Kevin Gunn, Daniel d'Andrada, Christopher James Halse Rogers, Michael Terry, Brandon Schaefer, Timo Jyrinki, Mir Team, Andreas Pokorny
  • Date: 2013-12-20 11:11:22 UTC
  • mfrom: (1169.1.1 version-0.1.3)
  • Revision ID: tarmac-20131220111122-h503fd1fnq7pn9za
Latest upstream release: Mir 0.1.3 (r1298).

Approved by Alan Griffiths, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "mir_test_framework/udev_environment.h"
25
25
 
26
 
#include "src/server/graphics/gbm/gbm_platform.h"
27
 
#include "src/server/graphics/gbm/gbm_buffer.h"
28
 
#include "src/server/graphics/gbm/gbm_buffer_allocator.h"
 
26
#include "src/platform/graphics/mesa/platform.h"
 
27
#include "src/platform/graphics/mesa/gbm_buffer.h"
 
28
#include "src/platform/graphics/mesa/buffer_allocator.h"
29
29
#include "mir/graphics/buffer_initializer.h"
30
30
#include "mir/graphics/buffer_properties.h"
31
31
#include "mir_test_doubles/null_virtual_terminal.h"
41
41
#include <stdexcept>
42
42
 
43
43
namespace mg=mir::graphics;
44
 
namespace mgg=mir::graphics::gbm;
 
44
namespace mgm=mir::graphics::mesa;
45
45
namespace geom=mir::geometry;
46
46
namespace mtd=mir::test::doubles;
47
47
namespace mtf=mir::mir_test_framework;
48
48
 
49
 
class GBMGraphicBufferBasic : public ::testing::Test
 
49
class GBMBufferTest : public ::testing::Test
50
50
{
51
51
protected:
52
52
    virtual void SetUp()
56
56
        fake_devices.add_standard_drm_devices();
57
57
 
58
58
        size = geom::Size{300, 200};
59
 
        pf = geom::PixelFormat::argb_8888;
 
59
        pf = mir_pixel_format_argb_8888;
60
60
        stride = geom::Stride{4 * size.width.as_uint32_t()};
61
61
        usage = mg::BufferUsage::hardware;
62
62
        buffer_properties = mg::BufferProperties{size, pf, usage};
73
73
        ON_CALL(mock_gbm, gbm_bo_get_stride(_))
74
74
        .WillByDefault(Return(stride.as_uint32_t()));
75
75
 
76
 
        platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>(),
77
 
                                                      std::make_shared<mtd::NullVirtualTerminal>());
 
76
        platform = std::make_shared<mgm::Platform>(
 
77
            std::make_shared<mg::NullDisplayReport>(),
 
78
            std::make_shared<mtd::NullVirtualTerminal>());
78
79
        null_init = std::make_shared<mg::NullBufferInitializer>();
79
 
        allocator.reset(new mgg::GBMBufferAllocator(platform->gbm.device, null_init));
 
80
        allocator.reset(new mgm::BufferAllocator(platform->gbm.device, null_init));
80
81
    }
81
82
 
82
83
    ::testing::NiceMock<mtd::MockDRM> mock_drm;
83
84
    ::testing::NiceMock<mtd::MockGBM> mock_gbm;
84
85
    ::testing::NiceMock<mtd::MockEGL> mock_egl;
85
86
    ::testing::NiceMock<mtd::MockGL>  mock_gl;
86
 
    std::shared_ptr<mgg::GBMPlatform> platform;
 
87
    std::shared_ptr<mgm::Platform> platform;
87
88
    std::shared_ptr<mg::NullBufferInitializer> null_init;
88
 
    std::unique_ptr<mgg::GBMBufferAllocator> allocator;
 
89
    std::unique_ptr<mgm::BufferAllocator> allocator;
89
90
 
90
91
    // Defaults
91
 
    geom::PixelFormat pf;
 
92
    MirPixelFormat pf;
92
93
    geom::Size size;
93
94
    geom::Stride stride;
94
95
    mg::BufferUsage usage;
97
98
    mtf::UdevEnvironment fake_devices;
98
99
};
99
100
 
100
 
TEST_F(GBMGraphicBufferBasic, dimensions_test)
 
101
TEST_F(GBMBufferTest, dimensions_test)
101
102
{
102
103
    using namespace testing;
103
104
 
108
109
    ASSERT_EQ(size, buffer->size());
109
110
}
110
111
 
111
 
TEST_F(GBMGraphicBufferBasic, buffer_has_expected_pixel_format)
 
112
TEST_F(GBMBufferTest, buffer_has_expected_pixel_format)
112
113
{
113
114
    using namespace testing;
114
115
 
119
120
    ASSERT_EQ(pf, buffer->pixel_format());
120
121
}
121
122
 
122
 
TEST_F(GBMGraphicBufferBasic, stride_has_sane_value)
 
123
TEST_F(GBMBufferTest, stride_has_sane_value)
123
124
{
124
125
    using namespace testing;
125
126
 
135
136
    ASSERT_LE(minimum, buffer->stride());
136
137
}
137
138
 
138
 
TEST_F(GBMGraphicBufferBasic, buffer_native_handle_has_correct_size)
 
139
TEST_F(GBMBufferTest, buffer_native_handle_has_correct_size)
139
140
{
140
141
    using namespace testing;
141
142
 
157
158
    flink->name = value;
158
159
}
159
160
 
160
 
TEST_F(GBMGraphicBufferBasic, buffer_native_handle_contains_correct_data)
 
161
TEST_F(GBMBufferTest, buffer_native_handle_contains_correct_data)
161
162
{
162
163
    using namespace testing;
163
164
 
179
180
    EXPECT_EQ(stride.as_uint32_t(), static_cast<unsigned int>(handle->stride));
180
181
}
181
182
 
182
 
TEST_F(GBMGraphicBufferBasic, buffer_creation_throws_on_prime_fd_failure)
 
183
TEST_F(GBMBufferTest, buffer_creation_throws_on_prime_fd_failure)
183
184
{
184
185
    using namespace testing;
185
186
 
192
193
    }, std::runtime_error);
193
194
}
194
195
 
195
 
TEST_F(GBMGraphicBufferBasic, bind_to_texture_egl_image_creation_failed)
 
196
TEST_F(GBMBufferTest, bind_to_texture_egl_image_creation_failed)
196
197
{
197
198
    using namespace testing;
198
199
 
205
206
    }, std::runtime_error);
206
207
}
207
208
 
208
 
TEST_F(GBMGraphicBufferBasic, bind_to_texture_uses_egl_image)
 
209
TEST_F(GBMBufferTest, bind_to_texture_uses_egl_image)
209
210
{
210
211
    using namespace testing;
211
212