• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 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 // GetTexLevelParameterTest.cpp : Tests of the GL_ANGLE_get_tex_level_parameter extension.
8 
9 #include "test_utils/ANGLETest.h"
10 
11 #include "test_utils/gl_raii.h"
12 
13 namespace angle
14 {
15 
16 class GetTexLevelParameterTest : public ANGLETest
17 {
18   protected:
GetTexLevelParameterTest()19     GetTexLevelParameterTest()
20     {
21         setWindowWidth(128);
22         setWindowHeight(128);
23         setConfigRedBits(8);
24         setConfigGreenBits(8);
25         setConfigBlueBits(8);
26         setConfigAlphaBits(8);
27         setExtensionsEnabled(false);
28     }
29 };
30 
31 // Extension is requestable so it should be disabled by default.
TEST_P(GetTexLevelParameterTest,ExtensionStringExposed)32 TEST_P(GetTexLevelParameterTest, ExtensionStringExposed)
33 {
34     EXPECT_FALSE(IsGLExtensionEnabled("GL_ANGLE_get_tex_level_parameter"));
35 
36     if (IsGLExtensionRequestable("GL_ANGLE_get_tex_level_parameter"))
37     {
38         glRequestExtensionANGLE("GL_ANGLE_get_tex_level_parameter");
39         EXPECT_GL_NO_ERROR();
40 
41         EXPECT_TRUE(IsGLExtensionEnabled("GL_ANGLE_get_tex_level_parameter"));
42     }
43 }
44 
45 // Test various queries exposed by GL_ANGLE_get_tex_level_parameter
TEST_P(GetTexLevelParameterTest,Queries)46 TEST_P(GetTexLevelParameterTest, Queries)
47 {
48     ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_ANGLE_get_tex_level_parameter"));
49 
50     GLTexture texture;
51     glBindTexture(GL_TEXTURE_2D, texture);
52     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
53 
54     {
55         GLint width = 0;
56         glGetTexLevelParameterivANGLE(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
57         EXPECT_GL_NO_ERROR();
58         EXPECT_EQ(1, width);
59     }
60 
61     {
62         GLint height = 0;
63         glGetTexLevelParameterivANGLE(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
64         EXPECT_GL_NO_ERROR();
65         EXPECT_EQ(2, height);
66     }
67 
68     {
69         GLint internalFormat = 0;
70         glGetTexLevelParameterivANGLE(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT,
71                                       &internalFormat);
72         EXPECT_GL_NO_ERROR();
73         EXPECT_GLENUM_EQ(GL_RGBA, internalFormat);
74     }
75 }
76 
77 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
78 // tests should be run against.
79 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(GetTexLevelParameterTest);
80 }  // namespace angle
81