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 // MatrixModeTest.cpp: Tests basic usage of glMatrixMode.
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 MatrixModeTest : public ANGLETest<>
17 {
18 protected:
MatrixModeTest()19 MatrixModeTest()
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
31 // State query: Checks the initial state is correct.
TEST_P(MatrixModeTest,InitialState)32 TEST_P(MatrixModeTest, InitialState)
33 {
34 GLint matrixMode;
35 glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
36 EXPECT_GL_NO_ERROR();
37 EXPECT_GLENUM_EQ(GL_MODELVIEW, matrixMode);
38 }
39
40 // Checks for error-generating cases.
TEST_P(MatrixModeTest,Negative)41 TEST_P(MatrixModeTest, Negative)
42 {
43 glMatrixMode(0);
44 EXPECT_GL_ERROR(GL_INVALID_ENUM);
45 glMatrixMode(GL_TEXTURE_2D);
46 EXPECT_GL_ERROR(GL_INVALID_ENUM);
47 }
48
49 // Checks that matrix mode can be set.
TEST_P(MatrixModeTest,Set)50 TEST_P(MatrixModeTest, Set)
51 {
52 GLint matrixMode;
53
54 std::vector<GLenum> modes = {GL_PROJECTION, GL_MODELVIEW, GL_TEXTURE};
55
56 for (auto mode : modes)
57 {
58 glMatrixMode(mode);
59 EXPECT_GL_NO_ERROR();
60 glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
61 EXPECT_GLENUM_EQ(mode, matrixMode);
62 }
63 }
64
65 ANGLE_INSTANTIATE_TEST_ES1(MatrixModeTest);
66