Flutter Linux Embedder
fl_subsurface_egl_test.cc File Reference
#include "gtest/gtest.h"
#include "flutter/shell/platform/linux/fl_opengl_manager.h"
#include "flutter/shell/platform/linux/fl_subsurface_egl.h"
#include "flutter/shell/platform/linux/fl_wayland_display.h"
#include "flutter/shell/platform/linux/testing/mock_epoxy.h"
#include "flutter/shell/platform/linux/testing/wayland_test.h"
#include <epoxy/egl.h>
#include <wayland-client.h>

Go to the source code of this file.

Classes

class  FlSubsurfaceEGLTest
 

Functions

 TEST_F (FlSubsurfaceEGLTest, Create)
 
 TEST_F (FlSubsurfaceEGLTest, CreateFailure)
 
 TEST_F (FlSubsurfaceEGLTest, HoldsSubsurface)
 
 TEST_F (FlSubsurfaceEGLTest, Resize)
 
 TEST_F (FlSubsurfaceEGLTest, Present)
 
 TEST_F (FlSubsurfaceEGLTest, PresentResizes)
 
 TEST_F (FlSubsurfaceEGLTest, PresentWithoutBlit)
 
 TEST_F (FlSubsurfaceEGLTest, PresentMatchingBuffer)
 
 TEST_F (FlSubsurfaceEGLTest, PresentDifferentSizeSwapsStaleBuffer)
 
 TEST_F (FlSubsurfaceEGLTest, PresentDifferentSizeWritesWholeFrame)
 
 TEST_F (FlSubsurfaceEGLTest, PresentDifferentSizeWithoutBlit)
 
 TEST_F (FlSubsurfaceEGLTest, PresentAfterResizeSwapsStaleBuffer)
 
 TEST_F (FlSubsurfaceEGLTest, PresentSecondFrameOfNewSize)
 
 TEST_F (FlSubsurfaceEGLTest, PresentRoundsUpToBufferScale)
 
 TEST_F (FlSubsurfaceEGLTest, PresentRoundedFrameWritesAtTopOfBuffer)
 
 TEST_F (FlSubsurfaceEGLTest, ResizeRoundsUpToBufferScale)
 
 TEST_F (FlSubsurfaceEGLTest, Destroy)
 

Variables

constexpr size_t kWidth = 100
 
constexpr size_t kHeight = 200
 
constexpr gint kScale = 2
 
constexpr size_t kBufferWidth = kWidth * kScale
 
constexpr size_t kBufferHeight = kHeight * kScale
 

Function Documentation

◆ TEST_F() [1/17]

TEST_F ( FlSubsurfaceEGLTest  ,
Create   
)

Definition at line 69 of file fl_subsurface_egl_test.cc.

69  {
70  EXPECT_CALL(wayland, EGLWindowCreate(kWidth * kScale, kHeight * kScale));
71  EXPECT_CALL(wayland, Request(::testing::StrEq("wl_surface"),
72  WL_SURFACE_SET_BUFFER_SCALE));
73 
74  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
75  EXPECT_NE(egl, nullptr);
76  EXPECT_FALSE(HasReceivedLogLevel(G_LOG_LEVEL_WARNING));
77 }
g_autoptr(FlEngine) engine
constexpr size_t kHeight
constexpr size_t kWidth
constexpr gint kScale

References g_autoptr(), kHeight, kScale, and kWidth.

◆ TEST_F() [2/17]

TEST_F ( FlSubsurfaceEGLTest  ,
CreateFailure   
)

Definition at line 81 of file fl_subsurface_egl_test.cc.

81  {
82  wayland.egl_window_create_fails = true;
83 
84  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
85  EXPECT_NE(egl, nullptr);
86  EXPECT_TRUE(HasReceivedLogLevel(G_LOG_LEVEL_WARNING));
87 }

References g_autoptr().

◆ TEST_F() [3/17]

TEST_F ( FlSubsurfaceEGLTest  ,
Destroy   
)

Definition at line 274 of file fl_subsurface_egl_test.cc.

274  {
275  FlSubsurfaceEGL* egl = CreateEGL();
276  ASSERT_NE(egl, nullptr);
277 
278  EXPECT_CALL(wayland, EGLWindowDestroy());
279 
280  g_object_unref(egl);
281 }

◆ TEST_F() [4/17]

TEST_F ( FlSubsurfaceEGLTest  ,
HoldsSubsurface   
)

Definition at line 91 of file fl_subsurface_egl_test.cc.

91  {
92  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
93  ASSERT_NE(egl, nullptr);
94 
95  // Drop the reference held by the test; the EGL object keeps it alive.
96  FlSubsurface* s = subsurface;
97  subsurface = nullptr;
98  gpointer weak_subsurface = s;
99  g_object_add_weak_pointer(G_OBJECT(s), &weak_subsurface);
100  g_object_unref(s);
101  EXPECT_NE(weak_subsurface, nullptr);
102  g_object_remove_weak_pointer(G_OBJECT(s), &weak_subsurface);
103 }
G_BEGIN_DECLS FlSubsurface * subsurface

References g_autoptr(), and subsurface.

◆ TEST_F() [5/17]

TEST_F ( FlSubsurfaceEGLTest  ,
Present   
)

Definition at line 115 of file fl_subsurface_egl_test.cc.

115  {
116  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
117  ASSERT_NE(egl, nullptr);
118 
119  EXPECT_CALL(epoxy, glBlitFramebuffer);
120 
121  fl_subsurface_egl_present(egl, 1, kWidth, kHeight, nullptr);
122 }
void fl_subsurface_egl_present(FlSubsurfaceEGL *self, GLuint texture_id, size_t width, size_t height, FlGLFence *fence)

References fl_subsurface_egl_present(), g_autoptr(), kHeight, and kWidth.

◆ TEST_F() [6/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentAfterResizeSwapsStaleBuffer   
)

Definition at line 210 of file fl_subsurface_egl_test.cc.

210  {
211  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
212  ASSERT_NE(egl, nullptr);
213 
215 
216  EXPECT_CALL(wayland, EGLWindowResize).Times(0);
217  EXPECT_CALL(epoxy, eglSwapBuffers).Times(2);
218 
220  nullptr);
221 }
void fl_subsurface_egl_resize(FlSubsurfaceEGL *self, size_t width, size_t height)
constexpr size_t kBufferWidth
constexpr size_t kBufferHeight

References fl_subsurface_egl_present(), fl_subsurface_egl_resize(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [7/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentDifferentSizeSwapsStaleBuffer   
)

Definition at line 168 of file fl_subsurface_egl_test.cc.

168  {
169  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
170  ASSERT_NE(egl, nullptr);
171 
172  EXPECT_CALL(epoxy, eglSwapBuffers).Times(2);
173 
175  nullptr);
176 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [8/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentDifferentSizeWithoutBlit   
)

Definition at line 194 of file fl_subsurface_egl_test.cc.

194  {
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));
198 
199  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
200  ASSERT_NE(egl, nullptr);
201 
202  EXPECT_CALL(epoxy, glViewport(0, 0, kBufferWidth + 50, kBufferHeight + 50));
203 
205  nullptr);
206 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [9/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentDifferentSizeWritesWholeFrame   
)

Definition at line 180 of file fl_subsurface_egl_test.cc.

180  {
181  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
182  ASSERT_NE(egl, nullptr);
183 
184  EXPECT_CALL(epoxy,
185  glBlitFramebuffer(0, 0, kBufferWidth + 50, kBufferHeight + 50, 0,
186  0, kBufferWidth + 50, kBufferHeight + 50,
187  ::testing::_, ::testing::_));
188 
190  nullptr);
191 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [10/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentMatchingBuffer   
)

Definition at line 152 of file fl_subsurface_egl_test.cc.

152  {
153  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
154  ASSERT_NE(egl, nullptr);
155 
156  EXPECT_CALL(epoxy, glBlitFramebuffer(0, 0, kBufferWidth, kBufferHeight, 0, 0,
158  ::testing::_, ::testing::_));
159  EXPECT_CALL(epoxy, eglSwapBuffers).Times(1);
160 
162 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [11/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentResizes   
)

Definition at line 126 of file fl_subsurface_egl_test.cc.

126  {
127  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
128  ASSERT_NE(egl, nullptr);
129 
130  EXPECT_CALL(wayland, EGLWindowResize(kBufferWidth + 50, kBufferHeight + 50));
131 
133  nullptr);
134 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [12/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentRoundedFrameWritesAtTopOfBuffer   
)

Definition at line 253 of file fl_subsurface_egl_test.cc.

253  {
254  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
255  ASSERT_NE(egl, nullptr);
256 
257  EXPECT_CALL(epoxy, glBlitFramebuffer(0, 0, 1, 1, 0, kScale - 1, 1, kScale,
258  ::testing::_, ::testing::_));
259 
260  fl_subsurface_egl_present(egl, 1, 1, 1, nullptr);
261 }

References fl_subsurface_egl_present(), g_autoptr(), and kScale.

◆ TEST_F() [13/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentRoundsUpToBufferScale   
)

Definition at line 241 of file fl_subsurface_egl_test.cc.

241  {
242  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
243  ASSERT_NE(egl, nullptr);
244 
245  EXPECT_CALL(wayland, EGLWindowResize(kScale, kScale));
246 
247  fl_subsurface_egl_present(egl, 1, 1, 1, nullptr);
248 }

References fl_subsurface_egl_present(), g_autoptr(), and kScale.

◆ TEST_F() [14/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentSecondFrameOfNewSize   
)

Definition at line 225 of file fl_subsurface_egl_test.cc.

225  {
226  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
227  ASSERT_NE(egl, nullptr);
228 
230  nullptr);
231 
232  EXPECT_CALL(epoxy, eglSwapBuffers).Times(1);
233 
235  nullptr);
236 }

References fl_subsurface_egl_present(), g_autoptr(), kBufferHeight, and kBufferWidth.

◆ TEST_F() [15/17]

TEST_F ( FlSubsurfaceEGLTest  ,
PresentWithoutBlit   
)

Definition at line 137 of file fl_subsurface_egl_test.cc.

137  {
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));
141 
142  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
143  ASSERT_NE(egl, nullptr);
144 
145  EXPECT_CALL(epoxy, glBlitFramebuffer).Times(0);
146 
147  fl_subsurface_egl_present(egl, 1, kWidth, kHeight, nullptr);
148 }

References fl_subsurface_egl_present(), g_autoptr(), kHeight, and kWidth.

◆ TEST_F() [16/17]

TEST_F ( FlSubsurfaceEGLTest  ,
Resize   
)

Definition at line 105 of file fl_subsurface_egl_test.cc.

105  {
106  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
107  ASSERT_NE(egl, nullptr);
108 
109  EXPECT_CALL(wayland, EGLWindowResize(300, 400));
110 
111  fl_subsurface_egl_resize(egl, 300, 400);
112 }

References fl_subsurface_egl_resize(), and g_autoptr().

◆ TEST_F() [17/17]

TEST_F ( FlSubsurfaceEGLTest  ,
ResizeRoundsUpToBufferScale   
)

Definition at line 264 of file fl_subsurface_egl_test.cc.

264  {
265  g_autoptr(FlSubsurfaceEGL) egl = CreateEGL();
266  ASSERT_NE(egl, nullptr);
267 
268  EXPECT_CALL(wayland, EGLWindowResize(kScale, kScale));
269 
270  fl_subsurface_egl_resize(egl, 1, 1);
271 }

References fl_subsurface_egl_resize(), g_autoptr(), and kScale.

Variable Documentation

◆ kBufferHeight

constexpr size_t kBufferHeight = kHeight * kScale
constexpr

Definition at line 27 of file fl_subsurface_egl_test.cc.

Referenced by TEST_F().

◆ kBufferWidth

constexpr size_t kBufferWidth = kWidth * kScale
constexpr

Definition at line 26 of file fl_subsurface_egl_test.cc.

Referenced by TEST_F().

◆ kHeight

constexpr size_t kHeight = 200
constexpr

Definition at line 21 of file fl_subsurface_egl_test.cc.

Referenced by FlSubsurfaceEGLTest::CreateEGL(), and TEST_F().

◆ kScale

constexpr gint kScale = 2
constexpr

Definition at line 22 of file fl_subsurface_egl_test.cc.

Referenced by FlSubsurfaceEGLTest::CreateEGL(), and TEST_F().

◆ kWidth

constexpr size_t kWidth = 100
constexpr

Definition at line 20 of file fl_subsurface_egl_test.cc.

Referenced by FlSubsurfaceEGLTest::CreateEGL(), and TEST_F().