1222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian/* 2222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * Copyright (C) 2011 The Android Open Source Project 3222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * 4222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * you may not use this file except in compliance with the License. 6222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * You may obtain a copy of the License at 7222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * 8222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * 10222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * Unless required by applicable law or agreed to in writing, software 11222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * See the License for the specific language governing permissions and 14222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian * limitations under the License. 15222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian */ 16222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 17222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian#include <gtest/gtest.h> 18222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 19222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian#include <utils/String8.h> 20222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 21222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian#include <EGL/egl.h> 22222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 23222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopiannamespace android { 24222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 25222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopianclass EGLTest : public ::testing::Test { 26222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopianprotected: 27222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLDisplay mEglDisplay; 28222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 29222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopianprotected: 30222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLTest() : 31222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian mEglDisplay(EGL_NO_DISPLAY) { 32222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian } 33222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 34222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian virtual void SetUp() { 35222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); 36222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay); 37222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 38222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 39222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint majorVersion; 40222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint minorVersion; 41222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion)); 42222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 43222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian RecordProperty("EglVersionMajor", majorVersion); 44222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian RecordProperty("EglVersionMajor", minorVersion); 45222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian } 46222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 47222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian virtual void TearDown() { 48222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLBoolean success = eglTerminate(mEglDisplay); 49222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 50222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 51222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian } 52222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian}; 53222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 54222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias AgopianTEST_F(EGLTest, DISABLED_EGLConfigEightBitFirst) { 55222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 56222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint numConfigs; 57222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLConfig config; 58222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLBoolean success; 59222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint attrs[] = { 60222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 61222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 62222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_NONE 63222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian }; 64222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 65222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs); 66222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 67222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 68222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_GE(numConfigs, 1); 69222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 70222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint components[3]; 71222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 72222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]); 73222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 74222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 75222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]); 76222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 77222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 78222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]); 79222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 80222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 81222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 82222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[0], 8); 83222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[1], 8); 84222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[2], 8); 85222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian} 86222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 87222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias AgopianTEST_F(EGLTest, EGLConfigRGBA8888First) { 88222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 89222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint numConfigs; 90222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLConfig config; 91222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLBoolean success; 92222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint attrs[] = { 93222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 94222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 95222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_RED_SIZE, 8, 96222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_GREEN_SIZE, 8, 97222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_BLUE_SIZE, 8, 98222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_ALPHA_SIZE, 8, 99222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGL_NONE 100222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian }; 101222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 102222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs); 103222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 104222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 105222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_GE(numConfigs, 1); 106222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 107222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EGLint components[4]; 108222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 109222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]); 110222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 111222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 112222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]); 113222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 114222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 115222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]); 116222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 117222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 118222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian success = eglGetConfigAttrib(mEglDisplay, config, EGL_ALPHA_SIZE, &components[3]); 119222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_TRUE, success); 120222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian ASSERT_EQ(EGL_SUCCESS, eglGetError()); 121222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 122222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[0], 8); 123222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[1], 8); 124222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[2], 8); 125222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian EXPECT_GE(components[3], 8); 126222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian} 127222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 128222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian 129222b466d5a9fae0b11282fb128f87c491a0ccc7fMathias Agopian} 130