5#include "flatbuffers/stl_emulation.h"
10#include "gmock/gmock.h"
11#include "gtest/gtest.h"
17using ::testing::StartsWith;
20EmbedderSurfaceGLSkia::GLDispatchTable StubDispatchTable(
21 std::string_view version) {
23 static constexpr auto dummy_always_true = [] {
return true; };
24 return EmbedderSurfaceGLSkia::GLDispatchTable{
25 .gl_make_current_callback = dummy_always_true,
26 .gl_clear_current_callback = dummy_always_true,
27 .gl_present_callback = [](
const auto) {
return true; },
28 .gl_fbo_callback = [](
const auto) {
return 0; },
29 .gl_make_resource_current_callback = dummy_always_true,
30 .gl_surface_transformation_callback = [] {
return DlMatrix{}; },
32 .gl_populate_existing_damage = [](
const auto) {
return GLFBOInfo{}; },
37TEST(EmbedderSurfaceGLImpellerTest, GLES3ContextHasGLES3Shaders) {
38 const auto gl_dispatch_table =
39 StubDispatchTable(
"OpenGL ES 3.0");
41 gl_dispatch_table,
false,
45 const std::shared_ptr<impeller::Context>
context =
46 surface.CreateImpellerContext();
47 const std::shared_ptr<impeller::ShaderLibrary> shaders =
49 const std::shared_ptr<const impeller::ShaderFunction> func =
50 shaders->GetFunction(
"imp_uber_sdf_fragment_main",
53 const std::shared_ptr<const fml::Mapping> source =
54 gles_func->GetSourceMapping();
56 std::string_view(
reinterpret_cast<const char*
>(source->GetMapping()));
57 EXPECT_THAT(
text, StartsWith(
"#version 300 es"));
60TEST(EmbedderSurfaceGLImpellerTest, GLES2ContextDoesNotHaveGLES3Shaders) {
61 const auto gl_dispatch_table =
62 StubDispatchTable(
"OpenGL ES 2.0");
64 gl_dispatch_table,
false,
68 const std::shared_ptr<impeller::Context>
context =
69 surface.CreateImpellerContext();
70 const std::shared_ptr<impeller::ShaderLibrary> shaders =
72 const std::shared_ptr<const impeller::ShaderFunction> func =
73 shaders->GetFunction(
"imp_uber_sdf_fragment_main",
76 const std::shared_ptr<const fml::Mapping> source =
77 gles_func->GetSourceMapping();
79 std::string_view(
reinterpret_cast<const char*
>(source->GetMapping()));
80 EXPECT_THAT(
text, StartsWith(
"#version 100"));
static ShaderFunctionGLES & Cast(ShaderFunction &base)
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt, const char *version_string="OpenGL ES 3.0")
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Matrix DlMatrix
const ProcTableGLES::Resolver kMockResolverGLES
std::shared_ptr< ContextGLES > context