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 // ClientActiveTextureTest.cpp: Tests basic usage of glClientActiveTexture.
8
9 #include "test_utils/ANGLETest.h"
10 #include "test_utils/gl_raii.h"
11
12 #include "util/random_utils.h"
13
14 #include <stdint.h>
15
16 using namespace angle;
17
18 class ClientActiveTextureTest : public ANGLETest<>
19 {
20 protected:
ClientActiveTextureTest()21 ClientActiveTextureTest()
22 {
23 setWindowWidth(32);
24 setWindowHeight(32);
25 setConfigRedBits(8);
26 setConfigGreenBits(8);
27 setConfigBlueBits(8);
28 setConfigAlphaBits(8);
29 setConfigDepthBits(24);
30 }
31 };
32
33 // State query: Checks the initial state is correct.
TEST_P(ClientActiveTextureTest,InitialState)34 TEST_P(ClientActiveTextureTest, InitialState)
35 {
36 GLint clientActiveTexture = 0;
37 glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &clientActiveTexture);
38 EXPECT_GL_NO_ERROR();
39 EXPECT_GLENUM_EQ(GL_TEXTURE0, clientActiveTexture);
40 }
41
42 // Negative test: Checks against invalid use of glClientActiveTexture.
TEST_P(ClientActiveTextureTest,Negative)43 TEST_P(ClientActiveTextureTest, Negative)
44 {
45 glClientActiveTexture(0);
46 EXPECT_GL_ERROR(GL_INVALID_ENUM);
47
48 GLint maxTextureUnits = 0;
49 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
50
51 glClientActiveTexture(GL_TEXTURE0 + maxTextureUnits);
52 EXPECT_GL_ERROR(GL_INVALID_ENUM);
53 }
54
55 // Checks that the number of multitexturing units is above spec minimum.
TEST_P(ClientActiveTextureTest,Limits)56 TEST_P(ClientActiveTextureTest, Limits)
57 {
58 GLint maxTextureUnits = 0;
59 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
60 EXPECT_GE(maxTextureUnits, 2);
61 }
62
63 // Set test: Checks that GL_TEXTURE0..GL_TEXTURE[GL_MAX_TEXTURE_UNITS-1] can be set.
TEST_P(ClientActiveTextureTest,Set)64 TEST_P(ClientActiveTextureTest, Set)
65 {
66 GLint maxTextureUnits = 0;
67 glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
68
69 for (GLint i = 0; i < maxTextureUnits; i++)
70 {
71 glClientActiveTexture(GL_TEXTURE0 + i);
72 EXPECT_GL_NO_ERROR();
73 GLint clientActiveTexture = 0;
74 glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, (GLint *)&clientActiveTexture);
75 EXPECT_GL_NO_ERROR();
76 EXPECT_GLENUM_EQ(GL_TEXTURE0 + i, clientActiveTexture);
77 }
78 }
79
80 ANGLE_INSTANTIATE_TEST_ES1(ClientActiveTextureTest);
81