1 // Copyright (C) 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "GLSnapshotTesting.h"
16 #include "OpenGLTestContext.h"
17
18 #include <gtest/gtest.h>
19
20 namespace emugl {
21
22 struct GlSampleCoverage {
23 GLclampf value;
24 GLboolean invert;
25 };
26
27 // Sample coverage settings to attempt
28 static const GlSampleCoverage kGLES2TestSampleCoverages[] = {{0.3, true},
29 {0, false}};
30
31 class SnapshotGlSampleCoverageTest
32 : public SnapshotSetValueTest<GlSampleCoverage>,
33 public ::testing::WithParamInterface<GlSampleCoverage> {
stateCheck(GlSampleCoverage expected)34 void stateCheck(GlSampleCoverage expected) {
35 EXPECT_TRUE(compareGlobalGlFloat(gl, GL_SAMPLE_COVERAGE_VALUE,
36 expected.value));
37 EXPECT_TRUE(compareGlobalGlBoolean(gl, GL_SAMPLE_COVERAGE_INVERT,
38 expected.invert));
39 }
stateChange()40 void stateChange() {
41 gl->glSampleCoverage(GetParam().value, GetParam().invert);
42 }
43 };
44
TEST_P(SnapshotGlSampleCoverageTest,SetSampleCoverage)45 TEST_P(SnapshotGlSampleCoverageTest, SetSampleCoverage) {
46 GlSampleCoverage defaultCoverage = {1.0f, false};
47 setExpectedValues(defaultCoverage, GetParam());
48 doCheckedSnapshot();
49 }
50
51 INSTANTIATE_TEST_SUITE_P(GLES2SnapshotMultisampling,
52 SnapshotGlSampleCoverageTest,
53 ::testing::ValuesIn(kGLES2TestSampleCoverages));
54
55 } // namespace emugl
56