• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // EGLRecordableTest.cpp:
7 //   Tests of EGL_ANDROID_recordable extension
8 
9 #include <gtest/gtest.h>
10 
11 #include "test_utils/ANGLETest.h"
12 #include "test_utils/angle_test_configs.h"
13 #include "util/EGLWindow.h"
14 
15 using namespace angle;
16 
17 namespace angle
18 {
19 class EGLRecordableTest : public ANGLETest
20 {
21   protected:
EGLRecordableTest()22     EGLRecordableTest() {}
23 };
24 
25 // Test that the extension is always available (it is implemented in ANGLE's frontend).
TEST_P(EGLRecordableTest,ExtensionAlwaysAvailable)26 TEST_P(EGLRecordableTest, ExtensionAlwaysAvailable)
27 {
28     EGLDisplay display = getEGLWindow()->getDisplay();
29     ASSERT_TRUE(IsEGLDisplayExtensionEnabled(display, "EGL_ANDROID_recordable"));
30 }
31 
32 // Check that the default message filters and callbacks are correct
TEST_P(EGLRecordableTest,CheckAllContexts)33 TEST_P(EGLRecordableTest, CheckAllContexts)
34 {
35     EGLDisplay display = getEGLWindow()->getDisplay();
36     ANGLE_SKIP_TEST_IF(!IsEGLDisplayExtensionEnabled(display, "EGL_ANDROID_recordable"));
37 
38     int nConfigs = 0;
39     ASSERT_EGL_TRUE(eglGetConfigs(display, nullptr, 0, &nConfigs));
40     ASSERT_NE(nConfigs, 0);
41 
42     int nReturnedConfigs = 0;
43     std::vector<EGLConfig> configs(nConfigs);
44     ASSERT_EGL_TRUE(eglGetConfigs(display, configs.data(), nConfigs, &nReturnedConfigs));
45     ASSERT_EQ(nConfigs, nReturnedConfigs);
46 
47     for (EGLConfig config : configs)
48     {
49         EGLint isRecordable;
50         eglGetConfigAttrib(display, config, EGL_RECORDABLE_ANDROID, &isRecordable);
51         ASSERT_EGL_FALSE(isRecordable);
52     }
53 
54     const EGLint configAttributes[] = {
55         EGL_RED_SIZE,     EGL_DONT_CARE,  EGL_GREEN_SIZE,         EGL_DONT_CARE,  EGL_BLUE_SIZE,
56         EGL_DONT_CARE,    EGL_ALPHA_SIZE, EGL_DONT_CARE,          EGL_DEPTH_SIZE, EGL_DONT_CARE,
57         EGL_STENCIL_SIZE, EGL_DONT_CARE,  EGL_RECORDABLE_ANDROID, EGL_FALSE,      EGL_NONE};
58     EGLint configCount;
59     ASSERT_EGL_TRUE(
60         eglChooseConfig(display, configAttributes, configs.data(), configs.size(), &configCount));
61     ASSERT_EGL_SUCCESS();
62 }
63 
64 }  // namespace angle
65 
66 ANGLE_INSTANTIATE_TEST_ES2(EGLRecordableTest);
67