Blender  V3.3
gpu_testing.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 
3 #include "testing/testing.h"
4 
5 #include "GHOST_C-api.h"
6 
7 struct GPUContext;
8 
9 namespace blender::gpu {
10 
11 /* Test class that setups a GPUContext for test cases.
12  *
13  * Usage:
14  * TEST_F(GPUTest, my_gpu_test) {
15  * ...
16  * }
17  */
18 class GPUTest : public ::testing::Test {
19  private:
21  GHOST_SystemHandle ghost_system;
22  GHOST_ContextHandle ghost_context;
23  struct GPUContext *context;
24 
25  protected:
26  GPUTest(GHOST_TDrawingContextType draw_context_type) : draw_context_type(draw_context_type)
27  {
28  }
29 
30  void SetUp() override;
31  void TearDown() override;
32 };
33 
34 class GPUOpenGLTest : public GPUTest {
35  public:
37  {
38  }
39 };
40 
41 #define GPU_TEST(test_name) \
42  TEST_F(GPUOpenGLTest, test_name) \
43  { \
44  test_##test_name(); \
45  }
46 
47 } // namespace blender::gpu
GHOST C-API function and type declarations.
GHOST_TDrawingContextType
Definition: GHOST_Types.h:148
@ GHOST_kDrawingContextTypeOpenGL
Definition: GHOST_Types.h:150
@ GHOST_kDrawingContextTypeNone
Definition: GHOST_Types.h:149
struct GPUContext GPUContext
Definition: GPU_context.h:27
GPUTest(GHOST_TDrawingContextType draw_context_type)
Definition: gpu_testing.hh:26
void TearDown() override
Definition: gpu_testing.cc:26
void SetUp() override
Definition: gpu_testing.cc:15