1 // 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 31 namespace gfxstream { 32 namespace gl { 33 34 // Dimensions for test surface 35 static const int kTestSurfaceSize[] = {32, 32}; 36 37 EGLDisplay getDisplay(); 38 EGLConfig createConfig(EGLDisplay dpy, EGLint r, EGLint g, EGLint b, EGLint a, EGLint d, EGLint s, EGLint ms); 39 EGLSurface pbufferSurface(EGLDisplay dpy, ::EGLConfig config, EGLint w, EGLint h); 40 EGLContext createContext(EGLDisplay dpy, EGLConfig config, EGLint maj, EGLint min); 41 void destroyContext(EGLDisplay dpy, EGLContext cxt); 42 void destroySurface(EGLDisplay dpy, EGLSurface surface); 43 void destroyDisplay(EGLDisplay dpy); 44 45 class GLTest : public ::testing::Test { 46 protected: 47 static void SetUpTestSuite(); 48 virtual void SetUp(); 49 virtual void TearDown(); 50 51 const GLESv1Dispatch* gles1; 52 const GLESv2Dispatch* gl; 53 EGLDisplay m_display; 54 EGLConfig m_config; 55 EGLSurface m_surface; 56 EGLContext m_context; 57 }; 58 59 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) 69 70 } // namespace gl 71 } // namespace gfxstream 72