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 // ShadeModelTest.cpp: Tests the shade model API.
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 ShadeModelTest : public ANGLETest<>
19 {
20 protected:
ShadeModelTest()21 ShadeModelTest()
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 // Checks that the initial state is correct.
TEST_P(ShadeModelTest,InitialState)34 TEST_P(ShadeModelTest, InitialState)
35 {
36 GLint shadeModel = 0;
37 glGetIntegerv(GL_SHADE_MODEL, &shadeModel);
38 EXPECT_GL_NO_ERROR();
39
40 EXPECT_GLENUM_EQ(GL_SMOOTH, shadeModel);
41 }
42
43 // Negative test for shade model.
TEST_P(ShadeModelTest,Negative)44 TEST_P(ShadeModelTest, Negative)
45 {
46 glShadeModel(GL_TEXTURE_2D);
47 EXPECT_GL_ERROR(GL_INVALID_ENUM);
48 }
49
50 // Checks that the state can be set.
TEST_P(ShadeModelTest,Set)51 TEST_P(ShadeModelTest, Set)
52 {
53 glShadeModel(GL_FLAT);
54 EXPECT_GL_NO_ERROR();
55
56 GLint shadeModel;
57 glGetIntegerv(GL_SHADE_MODEL, &shadeModel);
58 EXPECT_GL_NO_ERROR();
59
60 EXPECT_GLENUM_EQ(GL_FLAT, shadeModel);
61
62 glShadeModel(GL_SMOOTH);
63 EXPECT_GL_NO_ERROR();
64
65 glGetIntegerv(GL_SHADE_MODEL, &shadeModel);
66 EXPECT_GL_NO_ERROR();
67
68 EXPECT_GLENUM_EQ(GL_SMOOTH, shadeModel);
69 }
70
71 ANGLE_INSTANTIATE_TEST_ES1(ShadeModelTest);
72