blob: 4c957062029a0f6a4039fffc0fb91f9e8ef76c8e [file] [log] [blame]
Vladimir Levin70fb4792017-11-15 12:01:51 -08001/*
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 Phillips08ba0852019-05-22 20:23:43 +00008#include "include/core/SkTypes.h"
Vladimir Levin70fb4792017-11-15 12:01:51 -08009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/gpu/gl/GrGLExtensions.h"
11#include "src/gpu/gl/GrGLDefines.h"
12#include "tests/Test.h"
Vladimir Levin70fb4792017-11-15 12:01:51 -080013
John Rosascoa9b348f2019-11-08 13:18:15 -080014#ifdef SK_GL
15
Vladimir Levin70fb4792017-11-15 12:01:51 -080016const GrGLubyte* simpleGetString(GrGLenum name) {
17 return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : "");
18}
19
20void simpleGetIntegerv(GrGLenum name, GrGLint* params) {
21 if (name == GR_GL_NUM_EXTENSIONS) {
22 *params = 2;
23 } else {
24 *params = 0;
25 }
26}
27
28const 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
34DEF_TEST(GrGLExtensionsTest_remove, reporter) {
35 GrGLExtensions ext;
Kevin Lubick39026282019-03-28 12:46:40 -040036 ext.init(kGL_GrGLStandard,
Vladimir Levin70fb4792017-11-15 12:01:51 -080037 &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 Rosascoa9b348f2019-11-08 13:18:15 -080051
52#endif // SK_GL