Flutter Engine
fl_texture_registrar_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_texture_registrar.h"
#include "flutter/shell/platform/linux/fl_texture_private.h"
#include "flutter/shell/platform/linux/fl_texture_registrar_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_pixel_buffer_texture.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_texture_gl.h"
#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_texture_registrar.h"
#include "gtest/gtest.h"
#include <epoxy/gl.h>
#include <gmodule.h>

Go to the source code of this file.

Functions

 G_DECLARE_FINAL_TYPE (FlTestRegistrarTexture, fl_test_registrar_texture, FL, TEST_REGISTRAR_TEXTURE, FlTextureGL) struct _FlTestRegistrarTexture
 A simple texture. More...
 
 G_DEFINE_TYPE (FlTestRegistrarTexture, fl_test_registrar_texture, fl_texture_gl_get_type()) static gboolean fl_test_registrar_texture_populate(FlTextureGL *texture
 
static void fl_test_registrar_texture_class_init (FlTestRegistrarTextureClass *klass)
 
static void fl_test_registrar_texture_init (FlTestRegistrarTexture *self)
 
static FlTestRegistrarTexture * fl_test_registrar_texture_new ()
 
 TEST (FlTextureRegistrarTest, MockRegistrar)
 
 TEST (FlTextureRegistrarTest, RegisterTexture)
 
 TEST (FlTextureRegistrarTest, MarkTextureFrameAvailable)
 

Variables

static constexpr uint32_t BUFFER_WIDTH = 4u
 
static constexpr uint32_t BUFFER_HEIGHT = 4u
 
static constexpr uint32_t REAL_BUFFER_WIDTH = 2u
 
static constexpr uint32_t REAL_BUFFER_HEIGHT = 2u
 
uint32_t * target = GL_TEXTURE_2D
 
uint32_t uint32_t * format = GL_R8
 
uint32_t uint32_t uint32_t * width = REAL_BUFFER_WIDTH
 
uint32_t uint32_t uint32_t uint32_t * height = REAL_BUFFER_HEIGHT
 
uint32_t uint32_t uint32_t uint32_t GError ** error
 
return TRUE
 

Function Documentation

◆ fl_test_registrar_texture_class_init()

static void fl_test_registrar_texture_class_init ( FlTestRegistrarTextureClass *  klass)
static

Definition at line 56 of file fl_texture_registrar_test.cc.

57  {
58  FL_TEXTURE_GL_CLASS(klass)->populate = fl_test_registrar_texture_populate;
59 }

◆ fl_test_registrar_texture_init()

static void fl_test_registrar_texture_init ( FlTestRegistrarTexture *  self)
static

Definition at line 61 of file fl_texture_registrar_test.cc.

61 {}

◆ fl_test_registrar_texture_new()

static FlTestRegistrarTexture* fl_test_registrar_texture_new ( )
static

Definition at line 63 of file fl_texture_registrar_test.cc.

Referenced by TEST().

63  {
64  return FL_TEST_REGISTRAR_TEXTURE(
65  g_object_new(fl_test_registrar_texture_get_type(), nullptr));
66 }

◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE ( FlTestRegistrarTexture  ,
fl_test_registrar_texture  ,
FL  ,
TEST_REGISTRAR_TEXTURE  ,
FlTextureGL   
)

A simple texture.

Definition at line 23 of file fl_texture_registrar_test.cc.

References fl_texture_gl_get_type(), G_DEFINE_TYPE(), and texture.

30  {
31  FlTextureGL parent_instance;
32 };

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( FlTestRegistrarTexture  ,
fl_test_registrar_texture  ,
fl_texture_gl_get_type()   
)

Referenced by G_DECLARE_FINAL_TYPE().

◆ TEST() [1/3]

TEST ( FlTextureRegistrarTest  ,
MockRegistrar   
)

Definition at line 69 of file fl_texture_registrar_test.cc.

References fl_mock_texture_registrar_get_frame_available(), fl_mock_texture_registrar_get_texture(), fl_mock_texture_registrar_new(), fl_test_registrar_texture_new(), fl_texture_get_texture_id(), fl_texture_registrar_lookup_texture(), fl_texture_registrar_mark_texture_frame_available(), fl_texture_registrar_register_texture(), fl_texture_registrar_unregister_texture(), and texture.

69  {
70  g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
71  g_autoptr(FlMockTextureRegistrar) registrar = fl_mock_texture_registrar_new();
72  EXPECT_TRUE(FL_IS_MOCK_TEXTURE_REGISTRAR(registrar));
73 
75  FL_TEXTURE_REGISTRAR(registrar), texture));
76  EXPECT_EQ(fl_mock_texture_registrar_get_texture(registrar), texture);
77  EXPECT_EQ(
78  fl_texture_registrar_lookup_texture(FL_TEXTURE_REGISTRAR(registrar),
80  texture);
82  FL_TEXTURE_REGISTRAR(registrar), texture));
83  EXPECT_TRUE(fl_mock_texture_registrar_get_frame_available(registrar));
85  FL_TEXTURE_REGISTRAR(registrar), texture));
86  EXPECT_EQ(fl_mock_texture_registrar_get_texture(registrar), nullptr);
87 }
gboolean fl_mock_texture_registrar_get_frame_available(FlMockTextureRegistrar *self)
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
int64_t fl_texture_get_texture_id(FlTexture *self)
Definition: fl_texture.cc:18
G_MODULE_EXPORT gboolean fl_texture_registrar_register_texture(FlTextureRegistrar *self, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar *self, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_mark_texture_frame_available(FlTextureRegistrar *self, FlTexture *texture)
FlMockTextureRegistrar * fl_mock_texture_registrar_new()
FlTexture * fl_mock_texture_registrar_get_texture(FlMockTextureRegistrar *self)
FlTexture * texture
static FlTestRegistrarTexture * fl_test_registrar_texture_new()

◆ TEST() [2/3]

TEST ( FlTextureRegistrarTest  ,
RegisterTexture   
)

Definition at line 90 of file fl_texture_registrar_test.cc.

References engine, fl_test_registrar_texture_new(), fl_texture_registrar_new(), fl_texture_registrar_register_texture(), fl_texture_registrar_unregister_texture(), make_mock_engine(), and texture.

90  {
91  g_autoptr(FlEngine) engine = make_mock_engine();
92  g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
93  g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
94 
95  EXPECT_FALSE(fl_texture_registrar_unregister_texture(registrar, texture));
96  EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
97  EXPECT_TRUE(fl_texture_registrar_unregister_texture(registrar, texture));
98 }
static FlEngine * make_mock_engine()
G_MODULE_EXPORT gboolean fl_texture_registrar_register_texture(FlTextureRegistrar *self, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar *self, FlTexture *texture)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
FlTexture * texture
static FlTestRegistrarTexture * fl_test_registrar_texture_new()

◆ TEST() [3/3]

TEST ( FlTextureRegistrarTest  ,
MarkTextureFrameAvailable   
)

Definition at line 101 of file fl_texture_registrar_test.cc.

References engine, fl_test_registrar_texture_new(), fl_texture_registrar_mark_texture_frame_available(), fl_texture_registrar_new(), fl_texture_registrar_register_texture(), make_mock_engine(), and texture.

101  {
102  g_autoptr(FlEngine) engine = make_mock_engine();
103  g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
104  g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
105 
106  EXPECT_FALSE(
108  EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
109  EXPECT_TRUE(
111 }
static FlEngine * make_mock_engine()
G_MODULE_EXPORT gboolean fl_texture_registrar_register_texture(FlTextureRegistrar *self, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_mark_texture_frame_available(FlTextureRegistrar *self, FlTexture *texture)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
FlTexture * texture
static FlTestRegistrarTexture * fl_test_registrar_texture_new()

Variable Documentation

◆ BUFFER_HEIGHT

constexpr uint32_t BUFFER_HEIGHT = 4u
static

Definition at line 19 of file fl_texture_registrar_test.cc.

◆ BUFFER_WIDTH

constexpr uint32_t BUFFER_WIDTH = 4u
static

Definition at line 18 of file fl_texture_registrar_test.cc.

◆ error

uint32_t uint32_t uint32_t uint32_t GError** error
Initial value:
{
EXPECT_TRUE(FL_IS_TEST_REGISTRAR_TEXTURE(texture))
FlTexture * texture

Definition at line 43 of file fl_texture_registrar_test.cc.

◆ format

◆ height

* height = REAL_BUFFER_HEIGHT

Definition at line 39 of file fl_texture_registrar_test.cc.

◆ REAL_BUFFER_HEIGHT

constexpr uint32_t REAL_BUFFER_HEIGHT = 2u
static

Definition at line 21 of file fl_texture_registrar_test.cc.

◆ REAL_BUFFER_WIDTH

constexpr uint32_t REAL_BUFFER_WIDTH = 2u
static

Definition at line 20 of file fl_texture_registrar_test.cc.

◆ target

◆ TRUE

return TRUE

Definition at line 53 of file fl_texture_registrar_test.cc.

◆ width

* width = REAL_BUFFER_WIDTH

Definition at line 39 of file fl_texture_registrar_test.cc.