• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 gfxstream {
21 namespace gl {
22 namespace {
23 
TEST_F(SnapshotTest,InitDestroy)24 TEST_F(SnapshotTest, InitDestroy) {}
25 
26 class SnapshotGlEnableTest : public SnapshotPreserveTest,
27                              public ::testing::WithParamInterface<GLenum> {
defaultStateCheck()28     void defaultStateCheck() override {
29         EXPECT_FALSE(gl->glIsEnabled(GetParam()));
30     }
changedStateCheck()31     void changedStateCheck() override {
32         EXPECT_TRUE(gl->glIsEnabled(GetParam()));
33     }
stateChange()34     void stateChange() override { gl->glEnable(GetParam()); }
35 };
36 
TEST_P(SnapshotGlEnableTest,PreserveEnable)37 TEST_P(SnapshotGlEnableTest, PreserveEnable) {
38     doCheckedSnapshot();
39 }
40 
41 INSTANTIATE_TEST_SUITE_P(GLES2SnapshotCapability,
42                          SnapshotGlEnableTest,
43                          ::testing::ValuesIn(kGLES2CanBeEnabled));
44 
45 class SnapshotGlDisableTest : public SnapshotPreserveTest,
46                               public ::testing::WithParamInterface<GLenum> {
defaultStateCheck()47     void defaultStateCheck() override {
48         EXPECT_TRUE(gl->glIsEnabled(GetParam()));
49     }
changedStateCheck()50     void changedStateCheck() override {
51         EXPECT_FALSE(gl->glIsEnabled(GetParam()));
52     }
stateChange()53     void stateChange() override { gl->glDisable(GetParam()); }
54 };
55 
TEST_P(SnapshotGlDisableTest,PreserveDisable)56 TEST_P(SnapshotGlDisableTest, PreserveDisable) {
57     doCheckedSnapshot();
58 }
59 
60 INSTANTIATE_TEST_SUITE_P(GLES2SnapshotCapability,
61                          SnapshotGlDisableTest,
62                          ::testing::ValuesIn(kGLES2CanBeDisabled));
63 
64 class SnapshotGlMipmapHintTest : public SnapshotSetValueTest<GLenum>,
65                                  public ::testing::WithParamInterface<GLenum> {
stateCheck(GLenum expected)66     void stateCheck(GLenum expected) override {
67         EXPECT_TRUE(compareGlobalGlInt(gl, GL_GENERATE_MIPMAP_HINT, expected));
68     }
stateChange()69     void stateChange() override {
70         gl->glHint(GL_GENERATE_MIPMAP_HINT, *m_changed_value);
71     }
72 };
73 
TEST_P(SnapshotGlMipmapHintTest,DISABLED_PreserveHint)74 TEST_P(SnapshotGlMipmapHintTest, DISABLED_PreserveHint) {
75     setExpectedValues(GL_DONT_CARE, GetParam());
76     doCheckedSnapshot();
77 }
78 
79 INSTANTIATE_TEST_SUITE_P(GLES2SnapshotHints,
80                          SnapshotGlMipmapHintTest,
81                          ::testing::ValuesIn(kGLES2GenerateMipmapHints));
82 
83 }  // namespace
84 }  // namespace gl
85 }  // namespace gfxstream
86