blob: 7b8ca6a9d2ed6f5c58e63c4c777a9a0a65f2aa2e [file] [log] [blame]
Lingfeng Yang0e6868f2020-11-03 12:32:59 -08001// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14#pragma once
15
16#include "OpenGLESDispatch/OpenGLDispatchLoader.h"
17
18// gtest has its own definitions for None and Bool
19#ifdef None
20 #undef None
21#endif
22#ifdef Bool
23 #undef Bool
24#endif
25#include <gtest/gtest.h>
26
27#include <EGL/egl.h>
28#include <GLES2/gl2.h>
29#include <GLES3/gl31.h>
30
Jason Macnaked0c9e62023-03-30 15:58:24 -070031namespace gfxstream {
32namespace gl {
Lingfeng Yang0e6868f2020-11-03 12:32:59 -080033
34// Dimensions for test surface
35static const int kTestSurfaceSize[] = {32, 32};
36
37EGLDisplay getDisplay();
38EGLConfig createConfig(EGLDisplay dpy, EGLint r, EGLint g, EGLint b, EGLint a, EGLint d, EGLint s, EGLint ms);
39EGLSurface pbufferSurface(EGLDisplay dpy, ::EGLConfig config, EGLint w, EGLint h);
40EGLContext createContext(EGLDisplay dpy, EGLConfig config, EGLint maj, EGLint min);
41void destroyContext(EGLDisplay dpy, EGLContext cxt);
42void destroySurface(EGLDisplay dpy, EGLSurface surface);
43void destroyDisplay(EGLDisplay dpy);
44
45class GLTest : public ::testing::Test {
46protected:
Joshua Duongd38ac302022-06-01 10:50:21 -070047 static void SetUpTestSuite();
Lingfeng Yang0e6868f2020-11-03 12:32:59 -080048 virtual void SetUp();
49 virtual void TearDown();
50
Doug Hornfb0ba202022-05-19 14:09:21 -070051 const GLESv1Dispatch* gles1;
Lingfeng Yang0e6868f2020-11-03 12:32:59 -080052 const GLESv2Dispatch* gl;
53 EGLDisplay m_display;
54 EGLConfig m_config;
55 EGLSurface m_surface;
56 EGLContext m_context;
57};
58
Hailin zhangb70bf5b2022-05-12 07:22:12 +000059
60#define EMUGL_SKIP_TEST_IF(COND) \
61 do \
62 { \
63 if (COND) \
64 { \
65 GTEST_SKIP() << "Test skipped: " #COND "."; \
66 return; \
67 } \
68 } while (0)
Jason Macnaked0c9e62023-03-30 15:58:24 -070069
70} // namespace gl
71} // namespace gfxstream