Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 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 | namespace angle |
| 14 | { |
| 15 | |
| 16 | class 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 |
| 24 | TEST_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 Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame^] | 37 | // Test the queries for the requestable extension strings |
| 38 | TEST_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 Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 68 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these |
| 69 | // tests should be run against. |
| 70 | ANGLE_INSTANTIATE_TEST(RequestExtensionTest, |
| 71 | ES2_D3D11(), |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame^] | 72 | ES3_D3D11(), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 73 | ES2_OPENGL(), |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame^] | 74 | ES3_OPENGL(), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 75 | ES2_OPENGLES(), |
Geoff Lang | 38f24ee | 2018-10-01 13:04:59 -0400 | [diff] [blame^] | 76 | ES3_OPENGLES(), |
Geoff Lang | 0ab41fa | 2018-03-14 11:03:30 -0400 | [diff] [blame] | 77 | ES2_VULKAN()); |
| 78 | |
| 79 | } // namespace angle |