egl_mock.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This file implements mock EGL Interface for unit testing. The interface
  5. // corresponds to the set of functionally distinct EGL functions defined in
  6. // generate_bindings.py.
  7. #ifndef UI_GL_EGL_MOCK_H_
  8. #define UI_GL_EGL_MOCK_H_
  9. #include "testing/gmock/include/gmock/gmock.h"
  10. #include "ui/gl/gl_bindings.h"
  11. namespace gl {
  12. using GLFunctionPointerType = void (*)();
  13. class MockEGLInterface {
  14. public:
  15. MockEGLInterface();
  16. virtual ~MockEGLInterface();
  17. // Set the functions called from the mock EGL implementation for the purposes
  18. // of testing.
  19. static void SetEGLInterface(MockEGLInterface* egl_interface);
  20. // Find an entry point to the mock GL implementation.
  21. static GLFunctionPointerType GL_BINDING_CALL
  22. GetGLProcAddress(const char* name);
  23. // Include the auto-generated parts of this class. We split this because
  24. // it means we can easily edit the non-auto generated parts right here in
  25. // this file instead of having to edit some template or the code generator.
  26. // Member functions
  27. #include "gl_mock_autogen_egl.h"
  28. private:
  29. static MockEGLInterface* interface_;
  30. // Static mock functions that invoke the member functions of interface_.
  31. #include "egl_bindings_autogen_mock.h"
  32. };
  33. } // namespace gl
  34. #endif // UI_GL_EGL_MOCK_H_