Merge "Add a simple EGL test"
This commit is contained in:
commit
f915de4b2f
41
opengl/tests/EGLTest/Android.mk
Normal file
41
opengl/tests/EGLTest/Android.mk
Normal file
@ -0,0 +1,41 @@
|
||||
# Build the unit tests.
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifneq ($(TARGET_SIMULATOR),true)
|
||||
|
||||
LOCAL_MODULE := EGL_test
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
EGL_test.cpp \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libEGL \
|
||||
libcutils \
|
||||
libstlport \
|
||||
libutils \
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libgtest \
|
||||
libgtest_main \
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
bionic \
|
||||
bionic/libstdc++/include \
|
||||
external/gtest/include \
|
||||
external/stlport/stlport \
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
endif
|
||||
|
||||
# Include subdirectory makefiles
|
||||
# ============================================================
|
||||
|
||||
# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
|
||||
# team really wants is to build the stuff defined by this makefile.
|
||||
ifeq (,$(ONE_SHOT_MAKEFILE))
|
||||
include $(call first-makefiles-under,$(LOCAL_PATH))
|
||||
endif
|
129
opengl/tests/EGLTest/EGL_test.cpp
Normal file
129
opengl/tests/EGLTest/EGL_test.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class EGLTest : public ::testing::Test {
|
||||
protected:
|
||||
EGLDisplay mEglDisplay;
|
||||
|
||||
protected:
|
||||
EGLTest() :
|
||||
mEglDisplay(EGL_NO_DISPLAY) {
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
ASSERT_NE(EGL_NO_DISPLAY, mEglDisplay);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
|
||||
EGLint majorVersion;
|
||||
EGLint minorVersion;
|
||||
EXPECT_TRUE(eglInitialize(mEglDisplay, &majorVersion, &minorVersion));
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
RecordProperty("EglVersionMajor", majorVersion);
|
||||
RecordProperty("EglVersionMajor", minorVersion);
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
EGLBoolean success = eglTerminate(mEglDisplay);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EGLTest, DISABLED_EGLConfigEightBitFirst) {
|
||||
|
||||
EGLint numConfigs;
|
||||
EGLConfig config;
|
||||
EGLBoolean success;
|
||||
EGLint attrs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
ASSERT_GE(numConfigs, 1);
|
||||
|
||||
EGLint components[3];
|
||||
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
|
||||
EXPECT_GE(components[0], 8);
|
||||
EXPECT_GE(components[1], 8);
|
||||
EXPECT_GE(components[2], 8);
|
||||
}
|
||||
|
||||
TEST_F(EGLTest, EGLConfigRGBA8888First) {
|
||||
|
||||
EGLint numConfigs;
|
||||
EGLConfig config;
|
||||
EGLBoolean success;
|
||||
EGLint attrs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
success = eglChooseConfig(mEglDisplay, attrs, &config, 1, &numConfigs);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
ASSERT_GE(numConfigs, 1);
|
||||
|
||||
EGLint components[4];
|
||||
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_RED_SIZE, &components[0]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_GREEN_SIZE, &components[1]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_BLUE_SIZE, &components[2]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
success = eglGetConfigAttrib(mEglDisplay, config, EGL_ALPHA_SIZE, &components[3]);
|
||||
ASSERT_EQ(EGL_TRUE, success);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
|
||||
EXPECT_GE(components[0], 8);
|
||||
EXPECT_GE(components[1], 8);
|
||||
EXPECT_GE(components[2], 8);
|
||||
EXPECT_GE(components[3], 8);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user