Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::gpu::testing Namespace Reference

Functions

static std::shared_ptr< fml::MappingCreateMappingFromVector (const std::shared_ptr< std::vector< uint8_t > > &data)
 
static std::shared_ptr< std::vector< uint8_t > > BuildValidEmptyBundle ()
 
static std::shared_ptr< std::vector< uint8_t > > BuildCorruptBundle ()
 
 TEST (FlutterGpuShaderLibraryTest, VerifierAcceptsValidBundleRejectsCorrupt)
 
 TEST (FlutterGpuShaderLibraryTest, MakeFromFlatbufferRejectsCorruptBufferWithValidIdentifier)
 
 TEST (FlutterGpuShaderLibraryTest, MakeFromFlatbufferRejectsTruncatedBuffer)
 
 TEST (FlutterGpuShaderLibraryTest, MakeFromFlatbufferRejectsMissingIdentifier)
 
 TEST (FlutterGpuShaderLibraryTest, MakeFromFlatbufferRejectsNullPayload)
 
 TEST (FlutterGpuShaderLibraryTest, MakeFromFlatbufferValidEmptyBundleIsNotRejectedByVerifier)
 

Function Documentation

◆ BuildCorruptBundle()

static std::shared_ptr< std::vector< uint8_t > > flutter::gpu::testing::BuildCorruptBundle ( )
static

Definition at line 61 of file shader_library_unittests.cc.

61 {
62 auto data = std::make_shared<std::vector<uint8_t>>(32, 0);
63 // "IPSB" file identifier at bytes 4-7.
64 (*data)[4] = 'I';
65 (*data)[5] = 'P';
66 (*data)[6] = 'S';
67 (*data)[7] = 'B';
68 // Root offset (little-endian uint32 at offset 0) pointing out of bounds.
69 (*data)[0] = 0xFF;
70 (*data)[1] = 0xFF;
71 return data;
72}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36

References flutter::data.

Referenced by TEST(), and TEST().

◆ BuildValidEmptyBundle()

static std::shared_ptr< std::vector< uint8_t > > flutter::gpu::testing::BuildValidEmptyBundle ( )
static

Definition at line 38 of file shader_library_unittests.cc.

38 {
39 flatbuffers::FlatBufferBuilder builder;
40 std::vector<flatbuffers::Offset<impeller::fb::shaderbundle::Shader>> shaders;
41 auto shaders_vec = builder.CreateVector(shaders);
42 impeller::fb::shaderbundle::ShaderBundleBuilder bundle_builder(builder);
43 bundle_builder.add_format_version(static_cast<uint32_t>(
44 impeller::fb::shaderbundle::ShaderBundleFormatVersion::kVersion));
45 bundle_builder.add_shaders(shaders_vec);
46 auto bundle = bundle_builder.Finish();
47 // Finish with the "IPSB" file identifier (mirrors the runtime_stage test's
48 // builder.Finish(stages, fb::RuntimeStagesIdentifier()) idiom).
49 builder.Finish(bundle, impeller::fb::shaderbundle::ShaderBundleIdentifier());
50 return std::make_shared<std::vector<uint8_t>>(
51 builder.GetBufferPointer(),
52 builder.GetBufferPointer() + builder.GetSize());
53}

Referenced by TEST(), and TEST().

◆ CreateMappingFromVector()

static std::shared_ptr< fml::Mapping > flutter::gpu::testing::CreateMappingFromVector ( const std::shared_ptr< std::vector< uint8_t > > &  data)
static

Definition at line 25 of file shader_library_unittests.cc.

26 {
27 const uint8_t* ptr = data->data();
28 const size_t size = data->size();
29 return std::make_shared<fml::NonOwnedMapping>(ptr, size,
30 [data](auto, auto) {});
31}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

References flutter::data, and flutter::size.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ TEST() [1/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
MakeFromFlatbufferRejectsCorruptBufferWithValidIdentifier   
)

Definition at line 100 of file shader_library_unittests.cc.

101 {
103 auto library =
104 ShaderLibrary::MakeFromFlatbuffer(impeller::Context::BackendType::kMetal,
105 std::move(mapping), "test_bundle");
106 EXPECT_FALSE(library);
107}
static std::shared_ptr< std::vector< uint8_t > > BuildCorruptBundle()
static std::shared_ptr< fml::Mapping > CreateMappingFromVector(const std::shared_ptr< std::vector< uint8_t > > &data)

References BuildCorruptBundle(), CreateMappingFromVector(), impeller::Context::kMetal, and flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ TEST() [2/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
MakeFromFlatbufferRejectsMissingIdentifier   
)

Definition at line 128 of file shader_library_unittests.cc.

128 {
129 auto data = std::make_shared<std::vector<uint8_t>>(32, 0);
130 // No identifier bytes set.
131 auto library = ShaderLibrary::MakeFromFlatbuffer(
133 "test_bundle");
134 EXPECT_FALSE(library);
135}

References CreateMappingFromVector(), flutter::data, impeller::Context::kMetal, and flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ TEST() [3/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
MakeFromFlatbufferRejectsNullPayload   
)

Definition at line 138 of file shader_library_unittests.cc.

138 {
139 auto library = ShaderLibrary::MakeFromFlatbuffer(
140 impeller::Context::BackendType::kMetal, nullptr, "test_bundle");
141 EXPECT_FALSE(library);
142}

References impeller::Context::kMetal, and flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ TEST() [4/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
MakeFromFlatbufferRejectsTruncatedBuffer   
)

Definition at line 111 of file shader_library_unittests.cc.

111 {
112 // 8 bytes: just enough to hold a (bogus) root offset + "IPSB" identifier.
113 auto data = std::make_shared<std::vector<uint8_t>>(8, 0);
114 (*data)[4] = 'I';
115 (*data)[5] = 'P';
116 (*data)[6] = 'S';
117 (*data)[7] = 'B';
118 // Root offset points past the 8-byte buffer.
119 (*data)[0] = 0x10;
120 auto library = ShaderLibrary::MakeFromFlatbuffer(
122 "test_bundle");
123 EXPECT_FALSE(library);
124}

References CreateMappingFromVector(), flutter::data, impeller::Context::kMetal, and flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ TEST() [5/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
MakeFromFlatbufferValidEmptyBundleIsNotRejectedByVerifier   
)

Definition at line 149 of file shader_library_unittests.cc.

150 {
151 auto valid = BuildValidEmptyBundle();
152 // The verifier accepts it (asserted directly here so this test stands alone).
153 flatbuffers::Verifier verifier(valid->data(), valid->size());
154 ASSERT_TRUE(impeller::fb::shaderbundle::VerifyShaderBundleBuffer(verifier));
155
156 // Driven through the public entry, an empty bundle yields a null library
157 // because there are no shaders to register (empty ShaderMap), NOT because the
158 // verifier rejected it.
159 auto library = ShaderLibrary::MakeFromFlatbuffer(
161 "test_bundle");
162 EXPECT_FALSE(library);
163}
static std::shared_ptr< std::vector< uint8_t > > BuildValidEmptyBundle()

References BuildValidEmptyBundle(), CreateMappingFromVector(), impeller::Context::kMetal, and flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ TEST() [6/6]

flutter::gpu::testing::TEST ( FlutterGpuShaderLibraryTest  ,
VerifierAcceptsValidBundleRejectsCorrupt   
)

Definition at line 77 of file shader_library_unittests.cc.

77 {
78 auto valid = BuildValidEmptyBundle();
79 EXPECT_TRUE(impeller::fb::shaderbundle::ShaderBundleBufferHasIdentifier(
80 valid->data()));
81 {
82 flatbuffers::Verifier verifier(valid->data(), valid->size());
83 EXPECT_TRUE(impeller::fb::shaderbundle::VerifyShaderBundleBuffer(verifier));
84 }
85
86 auto corrupt = BuildCorruptBundle();
87 EXPECT_TRUE(impeller::fb::shaderbundle::ShaderBundleBufferHasIdentifier(
88 corrupt->data()));
89 {
90 flatbuffers::Verifier verifier(corrupt->data(), corrupt->size());
91 EXPECT_FALSE(
92 impeller::fb::shaderbundle::VerifyShaderBundleBuffer(verifier));
93 }
94}

References BuildCorruptBundle(), and BuildValidEmptyBundle().