blob: 0c780814b160ae5e0cb4bad1b6460ef8c2337143 [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
8#include "SkTypes.h"
9
Vladimir Levin70fb4792017-11-15 12:01:51 -080010#include "gl/GrGLDefines.h"
11#include "gl/GrGLExtensions.h"
12#include "Test.h"
13
14const GrGLubyte* simpleGetString(GrGLenum name) {
15 return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : "");
16}
17
18void simpleGetIntegerv(GrGLenum name, GrGLint* params) {
19 if (name == GR_GL_NUM_EXTENSIONS) {
20 *params = 2;
21 } else {
22 *params = 0;
23 }
24}
25
26const 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
32DEF_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}