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 | |
| 8 | #include "SkTypes.h" |
| 9 | |
| 10 | // This test is a GPU-backend specific test. |
| 11 | #if SK_SUPPORT_GPU |
| 12 | |
| 13 | #include "gl/GrGLDefines.h" |
| 14 | #include "gl/GrGLExtensions.h" |
| 15 | #include "Test.h" |
| 16 | |
| 17 | const GrGLubyte* simpleGetString(GrGLenum name) { |
| 18 | return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : ""); |
| 19 | } |
| 20 | |
| 21 | void simpleGetIntegerv(GrGLenum name, GrGLint* params) { |
| 22 | if (name == GR_GL_NUM_EXTENSIONS) { |
| 23 | *params = 2; |
| 24 | } else { |
| 25 | *params = 0; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | const GrGLubyte* simpleGetStringi(GrGLenum name, GrGLuint index) { |
| 30 | if (name != GR_GL_EXTENSIONS || index >= 2) |
| 31 | return (const GrGLubyte*)""; |
| 32 | return (const GrGLubyte*)(index == 0 ? "test_extension_1" : "test_extension_2"); |
| 33 | } |
| 34 | |
| 35 | DEF_TEST(GrGLExtensionsTest_remove, reporter) { |
| 36 | GrGLExtensions ext; |
| 37 | ext.init(kNone_GrGLStandard, |
| 38 | &simpleGetString, |
| 39 | &simpleGetStringi, |
| 40 | &simpleGetIntegerv, |
| 41 | nullptr, |
| 42 | nullptr); |
| 43 | |
| 44 | REPORTER_ASSERT(reporter, ext.isInitialized()); |
| 45 | REPORTER_ASSERT(reporter, ext.has("test_extension_1")); |
| 46 | REPORTER_ASSERT(reporter, ext.has("test_extension_2")); |
| 47 | REPORTER_ASSERT(reporter, ext.remove("test_extension_2")); |
| 48 | REPORTER_ASSERT(reporter, !ext.has("test_extension_2")); |
| 49 | REPORTER_ASSERT(reporter, ext.remove("test_extension_1")); |
| 50 | REPORTER_ASSERT(reporter, !ext.has("test_extension_1")); |
| 51 | } |
| 52 | |
| 53 | #endif |