blob: f0d27a8a34657dbd13ca4e7a8addf30527b8f74e [file] [log] [blame]
Dan Stozacb1fcde2013-12-03 12:37:36 -08001/*
2 * Copyright 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Dan Stozaf3730fb2013-11-26 15:10:10 -080017#ifndef ANDROID_GL_TEST_H
18#define ANDROID_GL_TEST_H
19
20#include <gtest/gtest.h>
21
22#include <gui/SurfaceComposerClient.h>
23
24#include <EGL/egl.h>
25#include <GLES/gl.h>
26
27namespace android {
28
29class GLTest : public ::testing::Test {
Dan Stozacb1fcde2013-12-03 12:37:36 -080030public:
31 static void loadShader(GLenum shaderType, const char* pSource,
32 GLuint* outShader);
33 static void createProgram(const char* pVertexSource,
34 const char* pFragmentSource, GLuint* outPgm);
35
Dan Stozaf3730fb2013-11-26 15:10:10 -080036protected:
37 GLTest() :
Pablo Ceballos53390e12015-08-04 11:25:59 -070038 mDisplaySecs(0),
Dan Stozaf3730fb2013-11-26 15:10:10 -080039 mEglDisplay(EGL_NO_DISPLAY),
40 mEglSurface(EGL_NO_SURFACE),
Pablo Ceballos53390e12015-08-04 11:25:59 -070041 mEglContext(EGL_NO_CONTEXT),
42 mGlConfig(NULL) {
Dan Stozaf3730fb2013-11-26 15:10:10 -080043 }
44
45 virtual void SetUp();
46 virtual void TearDown();
47
48 virtual EGLint const* getConfigAttribs();
49 virtual EGLint const* getContextAttribs();
50 virtual EGLint getSurfaceWidth();
51 virtual EGLint getSurfaceHeight();
52 virtual EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config,
53 sp<ANativeWindow>& window) const;
54
55 ::testing::AssertionResult checkPixel(int x, int y,
56 int r, int g, int b, int a, int tolerance = 2);
57 ::testing::AssertionResult assertRectEq(const Rect &r1, const Rect &r2,
58 int tolerance = 1);
59
Dan Stozaf3730fb2013-11-26 15:10:10 -080060 int mDisplaySecs;
61 sp<SurfaceComposerClient> mComposerClient;
62 sp<SurfaceControl> mSurfaceControl;
63
64 EGLDisplay mEglDisplay;
65 EGLSurface mEglSurface;
66 EGLContext mEglContext;
67 EGLConfig mGlConfig;
68};
69
70} // namespace android
71
72#endif