Flutter Engine
The Flutter Engine
Functions | Variables
fl_renderer_test.cc File Reference
#include "gtest/gtest.h"
#include <epoxy/egl.h>
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/linux/fl_backing_store_provider.h"
#include "flutter/shell/platform/linux/testing/fl_test_gtk_logs.h"
#include "flutter/shell/platform/linux/testing/mock_renderer.h"

Go to the source code of this file.

Functions

 TEST (FlRendererTest, RestoresGLState)
 
static gdouble renderer_get_refresh_rate (FlRenderer *renderer)
 
 TEST (FlRendererTest, RefreshRate)
 

Variables

static constexpr double kExpectedRefreshRate = 120.0
 

Function Documentation

◆ renderer_get_refresh_rate()

static gdouble renderer_get_refresh_rate ( FlRenderer *  renderer)
static

Definition at line 56 of file fl_renderer_test.cc.

56 {
58}
static constexpr double kExpectedRefreshRate

◆ TEST() [1/2]

TEST ( FlRendererTest  ,
RefreshRate   
)

Definition at line 60 of file fl_renderer_test.cc.

60 {
62 g_autoptr(FlDartProject) project = fl_dart_project_new();
63 g_autoptr(FlMockRenderer) renderer =
65
66 gdouble result_refresh_rate =
68 EXPECT_DOUBLE_EQ(result_refresh_rate, kExpectedRefreshRate);
69}
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
gdouble fl_renderer_get_refresh_rate(FlRenderer *self)
Definition: fl_renderer.cc:156
static gdouble renderer_get_refresh_rate(FlRenderer *renderer)
FlMockRenderer * fl_mock_renderer_new(FlMockRendererGetRefreshRate get_refresh_rate)
void fl_ensure_gtk_init(GLogWriterFunc writer)
Ensures that GTK has been initialized and starts monitoring logs.

◆ TEST() [2/2]

TEST ( FlRendererTest  ,
RestoresGLState   
)

Definition at line 14 of file fl_renderer_test.cc.

14 {
15 constexpr int kWidth = 100;
16 constexpr int kHeight = 100;
17
19 g_autoptr(FlDartProject) project = fl_dart_project_new();
20 g_autoptr(FlView) view = fl_view_new(project);
21 g_autoptr(FlMockRenderer) renderer = fl_mock_renderer_new();
22 g_autoptr(FlBackingStoreProvider) backing_store_provider =
24
25 fl_renderer_start(FL_RENDERER(renderer), view);
27
28 FlutterBackingStore backing_store;
30 backing_store.open_gl.framebuffer.user_data = backing_store_provider;
31
32 FlutterLayer layer;
34 layer.backing_store = &backing_store;
35 layer.offset = {0, 0};
36 layer.size = {kWidth, kHeight};
37
38 std::array<const FlutterLayer*, 1> layers = {&layer};
39
40 constexpr GLuint kFakeTextureName = 123;
41 glBindTexture(GL_TEXTURE_2D, kFakeTextureName);
42
43 fl_renderer_present_layers(FL_RENDERER(renderer), layers.data(),
44 layers.size());
46
47 GLuint texture_2d_binding;
48 glGetIntegerv(GL_TEXTURE_BINDING_2D,
49 reinterpret_cast<GLint*>(&texture_2d_binding));
50 EXPECT_EQ(texture_2d_binding, kFakeTextureName);
51
52 g_object_ref_sink(view);
53}
@ kFlutterLayerContentTypeBackingStore
Definition: embedder.h:1793
@ kFlutterBackingStoreTypeOpenGL
Definition: embedder.h:1742
FlBackingStoreProvider * fl_backing_store_provider_new(int width, int height)
gboolean fl_renderer_present_layers(FlRenderer *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:226
gboolean fl_renderer_start(FlRenderer *self, FlView *view)
Definition: fl_renderer.cc:125
void fl_renderer_render(FlRenderer *self, int width, int height)
Definition: fl_renderer.cc:316
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:207
G_MODULE_EXPORT FlView * fl_view_new(FlDartProject *project)
Definition: fl_view.cc:830
FlutterBackingStoreType type
Specifies the type of backing store.
Definition: embedder.h:1762
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
Definition: embedder.h:1768
FlutterPoint offset
Definition: embedder.h:1835
FlutterLayerContentType type
Definition: embedder.h:1824
const FlutterBackingStore * backing_store
Definition: embedder.h:1828
FlutterSize size
The size of the layer (in physical pixels).
Definition: embedder.h:1837
FlutterOpenGLFramebuffer framebuffer
Definition: embedder.h:1616
void * user_data
User data to be returned on the invocation of the destruction callback.
Definition: embedder.h:399
constexpr size_t kHeight
constexpr size_t kWidth

Variable Documentation

◆ kExpectedRefreshRate

constexpr double kExpectedRefreshRate = 120.0
staticconstexpr

Definition at line 55 of file fl_renderer_test.cc.