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 // RequestExtensionTest:
7 // Tests that extensions can be requested and are disabled by default when using
8 // EGL_ANGLE_request_extension
9 //
10
11 #include "test_utils/ANGLETest.h"
12
13 #include "util/EGLWindow.h"
14
15 namespace angle
16 {
17
18 class RequestExtensionTest : public ANGLETest
19 {
20 protected:
RequestExtensionTest()21 RequestExtensionTest() { setExtensionsEnabled(false); }
22 };
23
24 // Test that a known requestable extension is disabled by default and make sure it can be requested
25 // if possible
TEST_P(RequestExtensionTest,ExtensionsDisabledByDefault)26 TEST_P(RequestExtensionTest, ExtensionsDisabledByDefault)
27 {
28 EXPECT_TRUE(IsEGLDisplayExtensionEnabled(getEGLWindow()->getDisplay(),
29 "EGL_ANGLE_create_context_extensions_enabled"));
30 EXPECT_FALSE(IsGLExtensionEnabled("GL_OES_rgb8_rgba8"));
31
32 if (IsGLExtensionRequestable("GL_OES_rgb8_rgba8"))
33 {
34 glRequestExtensionANGLE("GL_OES_rgb8_rgba8");
35 EXPECT_TRUE(IsGLExtensionEnabled("GL_OES_rgb8_rgba8"));
36 }
37 }
38
39 // Test the queries for the requestable extension strings
TEST_P(RequestExtensionTest,Queries)40 TEST_P(RequestExtensionTest, Queries)
41 {
42 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_request_extension"));
43
44 const GLubyte *requestableExtString = glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE);
45 EXPECT_GL_NO_ERROR();
46 EXPECT_NE(nullptr, requestableExtString);
47
48 if (getClientMajorVersion() >= 3)
49 {
50 GLint numExtensions = 0;
51 glGetIntegerv(GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE, &numExtensions);
52 EXPECT_GL_NO_ERROR();
53
54 for (GLint extIdx = 0; extIdx < numExtensions; extIdx++)
55 {
56 const GLubyte *requestableExtIndexedString =
57 glGetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, extIdx);
58 EXPECT_GL_NO_ERROR();
59 EXPECT_NE(nullptr, requestableExtIndexedString);
60 }
61
62 // Request beyond the end of the array
63 const GLubyte *requestableExtIndexedString =
64 glGetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, numExtensions);
65 EXPECT_GL_ERROR(GL_INVALID_VALUE);
66 EXPECT_EQ(nullptr, requestableExtIndexedString);
67 }
68 }
69
70 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
71 // tests should be run against.
72 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(RequestExtensionTest);
73
74 } // namespace angle
75