GrGLExtensionsTest.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "include/core/SkTypes.h"
  8. #include "include/gpu/gl/GrGLExtensions.h"
  9. #include "src/gpu/gl/GrGLDefines.h"
  10. #include "tests/Test.h"
  11. const GrGLubyte* simpleGetString(GrGLenum name) {
  12. return (const GrGLubyte*)(name == GR_GL_VERSION ? "3.0" : "");
  13. }
  14. void simpleGetIntegerv(GrGLenum name, GrGLint* params) {
  15. if (name == GR_GL_NUM_EXTENSIONS) {
  16. *params = 2;
  17. } else {
  18. *params = 0;
  19. }
  20. }
  21. const GrGLubyte* simpleGetStringi(GrGLenum name, GrGLuint index) {
  22. if (name != GR_GL_EXTENSIONS || index >= 2)
  23. return (const GrGLubyte*)"";
  24. return (const GrGLubyte*)(index == 0 ? "test_extension_1" : "test_extension_2");
  25. }
  26. DEF_TEST(GrGLExtensionsTest_remove, reporter) {
  27. GrGLExtensions ext;
  28. ext.init(kGL_GrGLStandard,
  29. &simpleGetString,
  30. &simpleGetStringi,
  31. &simpleGetIntegerv,
  32. nullptr,
  33. nullptr);
  34. REPORTER_ASSERT(reporter, ext.isInitialized());
  35. REPORTER_ASSERT(reporter, ext.has("test_extension_1"));
  36. REPORTER_ASSERT(reporter, ext.has("test_extension_2"));
  37. REPORTER_ASSERT(reporter, ext.remove("test_extension_2"));
  38. REPORTER_ASSERT(reporter, !ext.has("test_extension_2"));
  39. REPORTER_ASSERT(reporter, ext.remove("test_extension_1"));
  40. REPORTER_ASSERT(reporter, !ext.has("test_extension_1"));
  41. }