blob: 335f110916fa619c44932bb32e0dba8eed4e23a8 [file] [log] [blame]
Geoff Lang0ab41fa2018-03-14 11:03:30 -04001//
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
13namespace angle
14{
15
16class RequestExtensionTest : public ANGLETest
17{
18 protected:
19 RequestExtensionTest() { setExtensionsEnabled(false); }
20};
21
22// Test that a known requestable extension is disabled by default and make sure it can be requested
23// if possible
24TEST_P(RequestExtensionTest, ExtensionsDisabledByDefault)
25{
26 EXPECT_TRUE(eglDisplayExtensionEnabled(getEGLWindow()->getDisplay(),
27 "EGL_ANGLE_create_context_extensions_enabled"));
28 EXPECT_FALSE(extensionEnabled("GL_OES_rgb8_rgba8"));
29
30 if (extensionRequestable("GL_OES_rgb8_rgba8"))
31 {
32 glRequestExtensionANGLE("GL_OES_rgb8_rgba8");
33 EXPECT_TRUE(extensionEnabled("GL_OES_rgb8_rgba8"));
34 }
35}
36
Geoff Lang38f24ee2018-10-01 13:04:59 -040037// Test the queries for the requestable extension strings
38TEST_P(RequestExtensionTest, Queries)
39{
40 ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_request_extension"));
41
42 const GLubyte *requestableExtString = glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE);
43 EXPECT_GL_NO_ERROR();
44 EXPECT_NE(nullptr, requestableExtString);
45
46 if (getClientMajorVersion() >= 3)
47 {
48 GLint numExtensions = 0;
49 glGetIntegerv(GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE, &numExtensions);
50 EXPECT_GL_NO_ERROR();
51
52 for (GLint extIdx = 0; extIdx < numExtensions; extIdx++)
53 {
54 const GLubyte *requestableExtIndexedString =
55 glGetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, extIdx);
56 EXPECT_GL_NO_ERROR();
57 EXPECT_NE(nullptr, requestableExtIndexedString);
58 }
59
60 // Request beyond the end of the array
61 const GLubyte *requestableExtIndexedString =
62 glGetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, numExtensions);
63 EXPECT_GL_ERROR(GL_INVALID_VALUE);
64 EXPECT_EQ(nullptr, requestableExtIndexedString);
65 }
66}
67
Geoff Lang0ab41fa2018-03-14 11:03:30 -040068// Use this to select which configurations (e.g. which renderer, which GLES major version) these
69// tests should be run against.
70ANGLE_INSTANTIATE_TEST(RequestExtensionTest,
71 ES2_D3D11(),
Geoff Lang38f24ee2018-10-01 13:04:59 -040072 ES3_D3D11(),
Geoff Lang0ab41fa2018-03-14 11:03:30 -040073 ES2_OPENGL(),
Geoff Lang38f24ee2018-10-01 13:04:59 -040074 ES3_OPENGL(),
Geoff Lang0ab41fa2018-03-14 11:03:30 -040075 ES2_OPENGLES(),
Geoff Lang38f24ee2018-10-01 13:04:59 -040076 ES3_OPENGLES(),
Geoff Lang0ab41fa2018-03-14 11:03:30 -040077 ES2_VULKAN());
78
79} // namespace angle