Vladimir Levin | 70fb479 | 2017-11-15 12:01:51 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Robert Phillips | 08ba085 | 2019-05-22 20:23:43 +0000 | [diff] [blame] | 8 | #include "include/core/SkTypes.h" |
Vladimir Levin | 70fb479 | 2017-11-15 12:01:51 -0800 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/gpu/gl/GrGLExtensions.h" |
| 11 | #include "src/gpu/gl/GrGLDefines.h" |
| 12 | #include "tests/Test.h" |
Vladimir Levin | 70fb479 | 2017-11-15 12:01:51 -0800 | [diff] [blame] | 13 | |
John Rosasco | a9b348f | 2019-11-08 13:18:15 -0800 | [diff] [blame] | 14 | #ifdef SK_GL |
| 15 | |
Vladimir Levin | 70fb479 | 2017-11-15 12:01:51 -0800 | [diff] [blame] | 16 | const GrGLubyte* simpleGetString(GrGLenum name) { |
| 17 | return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : ""); |
| 18 | } |
| 19 | |
| 20 | void simpleGetIntegerv(GrGLenum name, GrGLint* params) { |
| 21 | if (name == GR_GL_NUM_EXTENSIONS) { |
| 22 | *params = 2; |
| 23 | } else { |
| 24 | *params = 0; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | const GrGLubyte* simpleGetStringi(GrGLenum name, GrGLuint index) { |
| 29 | if (name != GR_GL_EXTENSIONS || index >= 2) |
| 30 | return (const GrGLubyte*)""; |
| 31 | return (const GrGLubyte*)(index == 0 ? "test_extension_1" : "test_extension_2"); |
| 32 | } |
| 33 | |
| 34 | DEF_TEST(GrGLExtensionsTest_remove, reporter) { |
| 35 | GrGLExtensions ext; |
Kevin Lubick | 3902628 | 2019-03-28 12:46:40 -0400 | [diff] [blame] | 36 | ext.init(kGL_GrGLStandard, |
Vladimir Levin | 70fb479 | 2017-11-15 12:01:51 -0800 | [diff] [blame] | 37 | &simpleGetString, |
| 38 | &simpleGetStringi, |
| 39 | &simpleGetIntegerv, |
| 40 | nullptr, |
| 41 | nullptr); |
| 42 | |
| 43 | REPORTER_ASSERT(reporter, ext.isInitialized()); |
| 44 | REPORTER_ASSERT(reporter, ext.has("test_extension_1")); |
| 45 | REPORTER_ASSERT(reporter, ext.has("test_extension_2")); |
| 46 | REPORTER_ASSERT(reporter, ext.remove("test_extension_2")); |
| 47 | REPORTER_ASSERT(reporter, !ext.has("test_extension_2")); |
| 48 | REPORTER_ASSERT(reporter, ext.remove("test_extension_1")); |
| 49 | REPORTER_ASSERT(reporter, !ext.has("test_extension_1")); |
| 50 | } |
John Rosasco | a9b348f | 2019-11-08 13:18:15 -0800 | [diff] [blame] | 51 | |
| 52 | #endif // SK_GL |