• 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 "include/core/SkTypes.h"
9 
10 #include "include/gpu/gl/GrGLExtensions.h"
11 #include "src/gpu/gl/GrGLDefines.h"
12 #include "tests/Test.h"
13 
14 #ifdef SK_GL
15 
simpleGetString(GrGLenum name)16 const GrGLubyte* simpleGetString(GrGLenum name) {
17     return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : "");
18 }
19 
simpleGetIntegerv(GrGLenum name,GrGLint * params)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 
simpleGetStringi(GrGLenum name,GrGLuint index)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 
DEF_TEST(GrGLExtensionsTest_remove,reporter)34 DEF_TEST(GrGLExtensionsTest_remove, reporter) {
35     GrGLExtensions ext;
36     ext.init(kGL_GrGLStandard,
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 }
51 
52 #endif  // SK_GL
53