2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <gtest/gtest.h>
19 #include <utils/String8.h>
25 class EGLTest : public ::testing::Test {
27 EGLDisplay mEglDisplay;
31 mEglDisplay(EGL_NO_DISPLAY) {
34 virtual void SetUp() {
35 mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
36 ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
37 ASSERT_EQ(EGL_SUCCESS, eglGetError());
41 EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
42 ASSERT_EQ(EGL_SUCCESS, eglGetError());
43 RecordProperty("EglVersionMajor", majorVersion);
44 RecordProperty("EglVersionMajor", minorVersion);
47 virtual void TearDown() {
48 EGLBoolean success = eglTerminate(mEglDisplay);
49 ASSERT_EQ(EGL_TRUE, success);
50 ASSERT_EQ(EGL_SUCCESS, eglGetError());
54 TEST_F(EGLTest, DISABLED_EGLConfigEightBitFirst) {
60 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
61 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
65 success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs);
66 ASSERT_EQ(EGL_TRUE, success);
67 ASSERT_EQ(EGL_SUCCESS, eglGetError());
68 ASSERT_GE(numConfigs, 1);
72 success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]);
73 ASSERT_EQ(EGL_TRUE, success);
74 ASSERT_EQ(EGL_SUCCESS, eglGetError());
75 success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]);
76 ASSERT_EQ(EGL_TRUE, success);
77 ASSERT_EQ(EGL_SUCCESS, eglGetError());
78 success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]);
79 ASSERT_EQ(EGL_TRUE, success);
80 ASSERT_EQ(EGL_SUCCESS, eglGetError());
82 EXPECT_GE(components[0], 8);
83 EXPECT_GE(components[1], 8);
84 EXPECT_GE(components[2], 8);
87 TEST_F(EGLTest, EGLConfigRGBA8888First) {
93 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
94 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
102 success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs);
103 ASSERT_EQ(EGL_TRUE, success);
104 ASSERT_EQ(EGL_SUCCESS, eglGetError());
105 ASSERT_GE(numConfigs, 1);
107 EGLint components[4];
109 success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]);
110 ASSERT_EQ(EGL_TRUE, success);
111 ASSERT_EQ(EGL_SUCCESS, eglGetError());
112 success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]);
113 ASSERT_EQ(EGL_TRUE, success);
114 ASSERT_EQ(EGL_SUCCESS, eglGetError());
115 success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]);
116 ASSERT_EQ(EGL_TRUE, success);
117 ASSERT_EQ(EGL_SUCCESS, eglGetError());
118 success = eglGetConfigAttrib(mEglDisplay, config, EGL_ALPHA_SIZE, &components[3]);
119 ASSERT_EQ(EGL_TRUE, success);
120 ASSERT_EQ(EGL_SUCCESS, eglGetError());
122 EXPECT_GE(components[0], 8);
123 EXPECT_GE(components[1], 8);
124 EXPECT_GE(components[2], 8);
125 EXPECT_GE(components[3], 8);