Path: blob/main_old/src/tests/egl_tests/EGLDeviceCGLTest.cpp
1693 views
//1// Copyright 2019 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// EGLDeviceCGLTest.cpp: tests for the EGL_ANGLE_device_cgl extension.6//78#include "test_utils/ANGLETest.h"9#include "util/EGLWindow.h"10#include "util/OSWindow.h"11#include "util/gles_loader_autogen.h"1213using namespace angle;1415class EGLDeviceCGLQueryTest : public ANGLETest16{17protected:18EGLDeviceCGLQueryTest() {}1920void testSetUp() override21{22const char *extensionString =23static_cast<const char *>(eglQueryString(getEGLWindow()->getDisplay(), EGL_EXTENSIONS));2425if (!eglQueryDeviceStringEXT)26{27FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceStringEXT was not "28"found";29}3031if (!eglQueryDisplayAttribEXT)32{33FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDisplayAttribEXT was "34"not found";35}3637if (!eglQueryDeviceAttribEXT)38{39FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceAttribEXT was not "40"found";41}4243EGLAttrib angleDevice = 0;44EXPECT_EGL_TRUE(45eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));46extensionString = static_cast<const char *>(47eglQueryDeviceStringEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice), EGL_EXTENSIONS));48if (strstr(extensionString, "EGL_ANGLE_device_cgl") == nullptr)49{50FAIL() << "ANGLE extension EGL_ANGLE_device_cgl was not found";51}52}53};5455// This test attempts to query the CGLContextObj and CGLPixelFormatObj from the56// EGLDevice associated with the display.57TEST_P(EGLDeviceCGLQueryTest, QueryDevice)58{59EGLAttrib angleDevice = 0;60EXPECT_EGL_TRUE(61eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));62EGLAttrib contextAttrib = 0;63EGLAttrib pixelFormatAttrib = 0;64EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),65EGL_CGL_CONTEXT_ANGLE, &contextAttrib));66EXPECT_TRUE(contextAttrib != 0);67EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),68EGL_CGL_PIXEL_FORMAT_ANGLE, &pixelFormatAttrib));69EXPECT_TRUE(pixelFormatAttrib != 0);70}7172// Use this to select which configurations (e.g. which renderer, which GLES major version) these73// tests should be run against.74ANGLE_INSTANTIATE_TEST(EGLDeviceCGLQueryTest, ES2_OPENGL(), ES3_OPENGL());757677