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