blob: d3c4a951f3a72b2e3ae9643e80c9fa8cd4aa6269 [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() :
38 mEglDisplay(EGL_NO_DISPLAY),
39 mEglSurface(EGL_NO_SURFACE),
40 mEglContext(EGL_NO_CONTEXT) {
41 }
42
43 virtual void SetUp();
44 virtual void TearDown();
45
46 virtual EGLint const* getConfigAttribs();
47 virtual EGLint const* getContextAttribs();
48 virtual EGLint getSurfaceWidth();
49 virtual EGLint getSurfaceHeight();
50 virtual EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config,
51 sp<ANativeWindow>& window) const;
52
53 ::testing::AssertionResult checkPixel(int x, int y,
54 int r, int g, int b, int a, int tolerance = 2);
55 ::testing::AssertionResult assertRectEq(const Rect &r1, const Rect &r2,
56 int tolerance = 1);
57
Dan Stozaf3730fb2013-11-26 15:10:10 -080058 int mDisplaySecs;
59 sp<SurfaceComposerClient> mComposerClient;
60 sp<SurfaceControl> mSurfaceControl;
61
62 EGLDisplay mEglDisplay;
63 EGLSurface mEglSurface;
64 EGLContext mEglContext;
65 EGLConfig mGlConfig;
66};
67
68} // namespace android
69
70#endif