Flutter Engine
egl_utils_test.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "gtest/gtest.h"
6 
7 #include "flutter/shell/platform/linux/egl_utils.h"
8 
9 TEST(EGLUtils, ErrorToString) {
10  const gchar* error_string = egl_error_to_string(EGL_SUCCESS);
11  EXPECT_STREQ(error_string, "Success");
12 }
13 
14 TEST(EGLUtils, ErrorToStringUnknown) {
15  const gchar* error_string = egl_error_to_string(0xffffffff);
16  EXPECT_STREQ(error_string, "Unknown Error");
17 }
18 
19 TEST(EGLUtils, ErrorToStringNegative) {
20  const gchar* error_string = egl_error_to_string(-1);
21  EXPECT_STREQ(error_string, "Unknown Error");
22 }
23 
24 TEST(EGLUtils, ConfigToString) {
25  EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
26  EXPECT_TRUE(eglInitialize(display, nullptr, nullptr));
27  EGLConfig config;
28  EXPECT_TRUE(eglChooseConfig(display, nullptr, &config, 1, nullptr));
29  g_autofree gchar* config_string = egl_config_to_string(display, config);
30  EXPECT_STREQ(
31  config_string,
32  "EGL_CONFIG_ID=1 EGL_BUFFER_SIZE=32 EGL_COLOR_BUFFER_TYPE=EGL_RGB_BUFFER "
33  "EGL_TRANSPARENT_TYPE=EGL_NONE EGL_LEVEL=1 EGL_RED_SIZE=8 "
34  "EGL_GREEN_SIZE=8 EGL_BLUE_SIZE=8 EGL_ALPHA_SIZE=0 EGL_DEPTH_SIZE=0 "
35  "EGL_STENCIL_SIZE=0 EGL_SAMPLES=0 EGL_SAMPLE_BUFFERS=0 "
36  "EGL_NATIVE_VISUAL_ID=0x1 EGL_NATIVE_VISUAL_TYPE=0x0 "
37  "EGL_NATIVE_RENDERABLE=EGL_TRUE EGL_CONFIG_CAVEAT=EGL_NONE "
38  "EGL_BIND_TO_TEXTURE_RGB=EGL_TRUE EGL_BIND_TO_TEXTURE_RGBA=EGL_FALSE "
39  "EGL_RENDERABLE_TYPE=EGL_OPENGL_ES2_BIT "
40  "EGL_CONFORMANT=EGL_OPENGL_ES2_BIT "
41  "EGL_SURFACE_TYPE=EGL_PBUFFER_BIT|EGL_WINDOW_BIT "
42  "EGL_MAX_PBUFFER_WIDTH=1024 EGL_MAX_PBUFFER_HEIGHT=1024 "
43  "EGL_MAX_PBUFFER_PIXELS=1048576 EGL_MIN_SWAP_INTERVAL=0 "
44  "EGL_MAX_SWAP_INTERVAL=1000");
45 }
46 
47 TEST(EGLUtils, ConfigToStringNullptr) {
48  EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
49  EXPECT_TRUE(eglInitialize(display, nullptr, nullptr));
50  EGLConfig config;
51  EXPECT_TRUE(eglChooseConfig(display, nullptr, &config, 1, nullptr));
52  g_autofree gchar* config_string1 = egl_config_to_string(nullptr, config);
53  EXPECT_STREQ(config_string1, "");
54  g_autofree gchar* config_string2 = egl_config_to_string(display, nullptr);
55  EXPECT_STREQ(config_string2, "");
56  g_autofree gchar* config_string3 = egl_config_to_string(nullptr, nullptr);
57  EXPECT_STREQ(config_string3, "");
58 }
TEST(EGLUtils, ErrorToString)
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
Definition: mock_egl.cc:263
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
Definition: mock_egl.cc:248
gchar * egl_config_to_string(EGLDisplay display, EGLConfig config)
Definition: egl_utils.cc:126
const gchar * egl_error_to_string(EGLint error)
Definition: egl_utils.cc:89
EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
Definition: mock_egl.cc:95