7 #include <gtest/gtest.h>
12 typedef std::array
<GLenum
, 2> Params
;
14 class OSMesaRenderTestFixture
: public testing::TestWithParam
<Params
> {};
17 name_params(const testing::TestParamInfo
<Params
> params
) {
18 auto p
= params
.param
;
19 std::string first
, second
;
39 case GL_UNSIGNED_SHORT
:
40 second
= "unsigned_short";
42 case GL_UNSIGNED_BYTE
:
43 second
= "unsigned_byte";
48 case GL_UNSIGNED_SHORT_5_6_5
:
49 second
= "unisgned_short_565";
53 return first
+ "_" + second
;
56 TEST_P(OSMesaRenderTestFixture
, Render
)
58 auto params
= GetParam();
60 uint32_t expected
; // This should be green for the given color model
63 std::unique_ptr
<osmesa_context
, decltype(&OSMesaDestroyContext
)> ctx
{
64 OSMesaCreateContext(params
[0], NULL
), &OSMesaDestroyContext
};
67 auto ret
= OSMesaMakeCurrent(ctx
.get(), &pixel
, params
[1], w
, h
);
68 ASSERT_EQ(ret
, GL_TRUE
);
75 glClearColor(0, 1, 0, 0);
79 glClearColor(0, 1, 0, 0);
82 expected
= 0xff << 24;
83 glClearColor(0, 0, 1, 0);
86 glClear(GL_COLOR_BUFFER_BIT
);
89 ASSERT_EQ(expected
, pixel
);
92 INSTANTIATE_TEST_CASE_P(
94 OSMesaRenderTestFixture
,
96 Params
{ OSMESA_RGBA
, GL_UNSIGNED_BYTE
}