| Flutter Linux Embedder |

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 {
57 return kExpectedRefreshRate;
58 }

References kExpectedRefreshRate.

Referenced by TEST().

## ◆ TEST() [1/2]

TEST | ( | FlRendererTest | ,
|  | RefreshRate |
| ) |  |

Definition at line 60 of file fl_renderer_test.cc.

60 {
61 flutter::testing::fl_ensure_gtk_init();
62 g_autoptr(FlDartProject) project = fl_dart_project_new();
63 g_autoptr(FlMockRenderer) renderer =
64 fl_mock_renderer_new(&renderer_get_refresh_rate);
65
66 gdouble result_refresh_rate =
67 fl_renderer_get_refresh_rate(FL_RENDERER(renderer));
68 EXPECT_DOUBLE_EQ(result_refresh_rate, kExpectedRefreshRate);
69 }

References fl_dart_project_new(), fl_renderer_get_refresh_rate(), kExpectedRefreshRate, and renderer_get_refresh_rate().

## ◆ 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
18 flutter::testing::fl_ensure_gtk_init();
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 =
23 fl_backing_store_provider_new(kWidth, kHeight);
24
25 fl_renderer_start(FL_RENDERER(renderer), view);
26 fl_renderer_wait_for_frame(FL_RENDERER(renderer), kWidth, kHeight);
27
28 FlutterBackingStore backing_store;
29 backing_store.type = kFlutterBackingStoreTypeOpenGL;
30 backing_store.open_gl.framebuffer.user_data = backing_store_provider;
31
32 FlutterLayer layer;
33 layer.type = kFlutterLayerContentTypeBackingStore;
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());
45 fl_renderer_render(FL_RENDERER(renderer), kWidth, kHeight);
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 }

References fl_backing_store_provider_new(), fl_dart_project_new(), fl_renderer_present_layers(), fl_renderer_render(), fl_renderer_start(), fl_renderer_wait_for_frame(), and fl_view_new().

## Variable Documentation

## ◆ kExpectedRefreshRate

constexpr double kExpectedRefreshRate = 120.0
| static constexpr

Definition at line 55 of file fl_renderer_test.cc.

Referenced by renderer_get_refresh_rate(), and TEST().

fl_renderer_wait_for_frame
void fl_renderer_wait_for_frame(FlRenderer *self, int target_width, int target_height)
Definition: fl_renderer.cc:207
fl_renderer_get_refresh_rate
gdouble fl_renderer_get_refresh_rate(FlRenderer *self)
Definition: fl_renderer.cc:156
renderer_get_refresh_rate
static gdouble renderer_get_refresh_rate(FlRenderer *renderer)
Definition: fl_renderer_test.cc:56
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:50
fl_backing_store_provider_new
FlBackingStoreProvider * fl_backing_store_provider_new(int width, int height)
Definition: fl_backing_store_provider.cc:35
fl_view_new
G_MODULE_EXPORT FlView * fl_view_new(FlDartProject *project)
Definition: fl_view.cc:837
fl_renderer_start
gboolean fl_renderer_start(FlRenderer *self, FlView *view)
Definition: fl_renderer.cc:125
fl_renderer_present_layers
gboolean fl_renderer_present_layers(FlRenderer *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:226
kExpectedRefreshRate
static constexpr double kExpectedRefreshRate
Definition: fl_renderer_test.cc:55
fl_renderer_render
void fl_renderer_render(FlRenderer *self, int width, int height)
Definition: fl_renderer.cc:316