5 #include "gtest/gtest.h"
10 #include "flutter/shell/platform/linux/testing/mock_epoxy.h"
11 #include "flutter/shell/platform/linux/testing/wayland_test.h"
13 #include <epoxy/egl.h>
14 #include <wayland-client.h>
16 using flutter::testing::fl_mock_wayland_free_surface;
17 using flutter::testing::fl_mock_wayland_get_display;
18 using flutter::testing::fl_mock_wayland_get_surface;
34 ON_CALL(
epoxy, glGetString(GL_VENDOR))
36 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"Intel")));
37 ON_CALL(
epoxy, epoxy_is_desktop_gl).WillByDefault(::testing::Return(
true));
38 ON_CALL(
epoxy, epoxy_gl_version).WillByDefault(::testing::Return(30));
60 ::testing::NiceMock<flutter::testing::MockEpoxy>
epoxy;
71 EXPECT_CALL(wayland, Request(::testing::StrEq(
"wl_surface"),
72 WL_SURFACE_SET_BUFFER_SCALE));
74 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
75 EXPECT_NE(egl,
nullptr);
76 EXPECT_FALSE(HasReceivedLogLevel(G_LOG_LEVEL_WARNING));
82 wayland.egl_window_create_fails =
true;
84 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
85 EXPECT_NE(egl,
nullptr);
86 EXPECT_TRUE(HasReceivedLogLevel(G_LOG_LEVEL_WARNING));
92 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
93 ASSERT_NE(egl,
nullptr);
98 gpointer weak_subsurface = s;
99 g_object_add_weak_pointer(G_OBJECT(s), &weak_subsurface);
101 EXPECT_NE(weak_subsurface,
nullptr);
102 g_object_remove_weak_pointer(G_OBJECT(s), &weak_subsurface);
106 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
107 ASSERT_NE(egl,
nullptr);
109 EXPECT_CALL(wayland, EGLWindowResize(300, 400));
116 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
117 ASSERT_NE(egl,
nullptr);
119 EXPECT_CALL(epoxy, glBlitFramebuffer);
127 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
128 ASSERT_NE(egl,
nullptr);
138 EXPECT_CALL(epoxy, epoxy_gl_version).WillRepeatedly(::testing::Return(20));
139 EXPECT_CALL(epoxy, epoxy_has_gl_extension(::testing::_))
140 .WillRepeatedly(::testing::Return(
false));
142 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
143 ASSERT_NE(egl,
nullptr);
145 EXPECT_CALL(epoxy, glBlitFramebuffer).Times(0);
153 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
154 ASSERT_NE(egl,
nullptr);
158 ::testing::_, ::testing::_));
159 EXPECT_CALL(epoxy, eglSwapBuffers).Times(1);
169 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
170 ASSERT_NE(egl,
nullptr);
172 EXPECT_CALL(epoxy, eglSwapBuffers).Times(2);
181 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
182 ASSERT_NE(egl,
nullptr);
187 ::testing::_, ::testing::_));
195 EXPECT_CALL(epoxy, epoxy_gl_version).WillRepeatedly(::testing::Return(20));
196 EXPECT_CALL(epoxy, epoxy_has_gl_extension(::testing::_))
197 .WillRepeatedly(::testing::Return(
false));
199 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
200 ASSERT_NE(egl,
nullptr);
211 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
212 ASSERT_NE(egl,
nullptr);
216 EXPECT_CALL(wayland, EGLWindowResize).Times(0);
217 EXPECT_CALL(epoxy, eglSwapBuffers).Times(2);
226 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
227 ASSERT_NE(egl,
nullptr);
232 EXPECT_CALL(epoxy, eglSwapBuffers).Times(1);
242 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
243 ASSERT_NE(egl,
nullptr);
254 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
255 ASSERT_NE(egl,
nullptr);
257 EXPECT_CALL(epoxy, glBlitFramebuffer(0, 0, 1, 1, 0,
kScale - 1, 1,
kScale,
258 ::testing::_, ::testing::_));
265 g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
266 ASSERT_NE(egl,
nullptr);
275 FlSubsurfaceEGL* egl = CreateEGL();
276 ASSERT_NE(egl,
nullptr);
278 EXPECT_CALL(wayland, EGLWindowDestroy());
struct wl_surface * parent_surface
::testing::NiceMock< flutter::testing::MockEpoxy > epoxy
FlSubsurfaceEGL * CreateEGL()
FlSubsurface * subsurface
FlOpenGLManager * opengl_manager
FlWaylandDisplay * display
g_autoptr(FlEngine) engine
FlOpenGLManager * fl_opengl_manager_new()
FlSubsurfaceEGL * fl_subsurface_egl_new(FlOpenGLManager *opengl_manager, FlSubsurface *subsurface, size_t width, size_t height, gint scale)
void fl_subsurface_egl_present(FlSubsurfaceEGL *self, GLuint texture_id, size_t width, size_t height, FlGLFence *fence)
void fl_subsurface_egl_resize(FlSubsurfaceEGL *self, size_t width, size_t height)
G_BEGIN_DECLS FlSubsurface * subsurface
constexpr size_t kBufferWidth
TEST_F(FlSubsurfaceEGLTest, Create)
constexpr size_t kBufferHeight
FlSubsurface * fl_wayland_display_create_subsurface(FlWaylandDisplay *self, struct wl_surface *parent_surface)
FlWaylandDisplay * fl_wayland_display_open(struct wl_display *wl_display)