xref: /aosp_15_r20/external/angle/src/tests/gl_tests/gles1/ClientStateEnable.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // ClientStateEnable.cpp: Tests basic usage of gl(Enable|Disable)ClientState.
8 
9 #include "test_utils/ANGLETest.h"
10 #include "test_utils/gl_raii.h"
11 
12 #include <vector>
13 
14 using namespace angle;
15 
16 class ClientStateEnable : public ANGLETest<>
17 {
18   protected:
ClientStateEnable()19     ClientStateEnable()
20     {
21         setWindowWidth(32);
22         setWindowHeight(32);
23         setConfigRedBits(8);
24         setConfigGreenBits(8);
25         setConfigBlueBits(8);
26         setConfigAlphaBits(8);
27         setConfigDepthBits(24);
28     }
29 
30     std::vector<GLenum> mClientStates = {
31         GL_VERTEX_ARRAY,         GL_NORMAL_ARRAY,        GL_COLOR_ARRAY,
32         GL_POINT_SIZE_ARRAY_OES, GL_TEXTURE_COORD_ARRAY,
33     };
34 };
35 
36 // Checks that all client vertex array states are disabled to start with.
TEST_P(ClientStateEnable,InitialState)37 TEST_P(ClientStateEnable, InitialState)
38 {
39     for (auto clientState : mClientStates)
40     {
41         EXPECT_GL_FALSE(glIsEnabled(clientState));
42         EXPECT_GL_NO_ERROR();
43     }
44 }
45 
46 // Checks that glEnableClientState sets the state to be enabled,
47 // and glDisableClientState sets the state to be disabled.
TEST_P(ClientStateEnable,EnableState)48 TEST_P(ClientStateEnable, EnableState)
49 {
50     for (auto clientState : mClientStates)
51     {
52         EXPECT_GL_FALSE(glIsEnabled(clientState));
53         glEnableClientState(clientState);
54         EXPECT_GL_NO_ERROR();
55         EXPECT_GL_TRUE(glIsEnabled(clientState));
56         glDisableClientState(clientState);
57         EXPECT_GL_NO_ERROR();
58         EXPECT_GL_FALSE(glIsEnabled(clientState));
59     }
60 }
61 
62 // Negative test: Checks that invalid enums for client state generate the proper GL error.
TEST_P(ClientStateEnable,Negative)63 TEST_P(ClientStateEnable, Negative)
64 {
65     glEnableClientState(0);
66     EXPECT_GL_ERROR(GL_INVALID_ENUM);
67 }
68 
69 // Checks that enable/disable states are different if we are in different client texture unit
70 // states.
TEST_P(ClientStateEnable,TextureUnit)71 TEST_P(ClientStateEnable, TextureUnit)
72 {
73     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
74 
75     // Spec minimum lets us assume 2 multitexturing units.
76     glClientActiveTexture(GL_TEXTURE1);
77     EXPECT_GL_FALSE(glIsEnabled(GL_TEXTURE_COORD_ARRAY));
78 
79     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
80     EXPECT_GL_TRUE(glIsEnabled(GL_TEXTURE_COORD_ARRAY));
81 
82     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
83     EXPECT_GL_FALSE(glIsEnabled(GL_TEXTURE_COORD_ARRAY));
84 
85     glClientActiveTexture(GL_TEXTURE0);
86     EXPECT_GL_TRUE(glIsEnabled(GL_TEXTURE_COORD_ARRAY));
87 
88     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
89     EXPECT_GL_FALSE(glIsEnabled(GL_TEXTURE_COORD_ARRAY));
90 }
91 
92 ANGLE_INSTANTIATE_TEST_ES1(ClientStateEnable);
93