1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // EGLDeviceCGLTest.cpp: tests for the EGL_ANGLE_device_cgl extension.
7 //
8
9 #include "test_utils/ANGLETest.h"
10 #include "util/EGLWindow.h"
11 #include "util/OSWindow.h"
12 #include "util/gles_loader_autogen.h"
13
14 using namespace angle;
15
16 class EGLDeviceCGLQueryTest : public ANGLETest
17 {
18 protected:
EGLDeviceCGLQueryTest()19 EGLDeviceCGLQueryTest() {}
20
testSetUp()21 void testSetUp() override
22 {
23 const char *extensionString =
24 static_cast<const char *>(eglQueryString(getEGLWindow()->getDisplay(), EGL_EXTENSIONS));
25
26 if (!eglQueryDeviceStringEXT)
27 {
28 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceStringEXT was not "
29 "found";
30 }
31
32 if (!eglQueryDisplayAttribEXT)
33 {
34 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDisplayAttribEXT was "
35 "not found";
36 }
37
38 if (!eglQueryDeviceAttribEXT)
39 {
40 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceAttribEXT was not "
41 "found";
42 }
43
44 EGLAttrib angleDevice = 0;
45 EXPECT_EGL_TRUE(
46 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
47 extensionString = static_cast<const char *>(
48 eglQueryDeviceStringEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice), EGL_EXTENSIONS));
49 if (strstr(extensionString, "EGL_ANGLE_device_cgl") == nullptr)
50 {
51 FAIL() << "ANGLE extension EGL_ANGLE_device_cgl was not found";
52 }
53 }
54 };
55
56 // This test attempts to query the CGLContextObj and CGLPixelFormatObj from the
57 // EGLDevice associated with the display.
TEST_P(EGLDeviceCGLQueryTest,QueryDevice)58 TEST_P(EGLDeviceCGLQueryTest, QueryDevice)
59 {
60 EGLAttrib angleDevice = 0;
61 EXPECT_EGL_TRUE(
62 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
63 EGLAttrib contextAttrib = 0;
64 EGLAttrib pixelFormatAttrib = 0;
65 EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
66 EGL_CGL_CONTEXT_ANGLE, &contextAttrib));
67 EXPECT_TRUE(contextAttrib != 0);
68 EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
69 EGL_CGL_PIXEL_FORMAT_ANGLE, &pixelFormatAttrib));
70 EXPECT_TRUE(pixelFormatAttrib != 0);
71 }
72
73 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
74 // tests should be run against.
75 ANGLE_INSTANTIATE_TEST(EGLDeviceCGLQueryTest, ES2_OPENGL(), ES3_OPENGL());
76