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,
44 const std::shared_ptr<impeller::Context> context =
45 surface.CreateImpellerContext();
46 const std::shared_ptr<impeller::ShaderLibrary> shaders =
47 context->GetShaderLibrary();
48 const std::shared_ptr<const impeller::ShaderFunction> func =
49 shaders->GetFunction(
"imp_line_fragment_main",
52 const std::shared_ptr<const fml::Mapping> source =
53 gles_func->GetSourceMapping();
55 std::string_view(
reinterpret_cast<const char*
>(source->GetMapping()));
56 EXPECT_THAT(
text, StartsWith(
"#version 300 es"));
59TEST(EmbedderSurfaceGLImpellerTest, GLES2ContextDoesNotHaveGLES3Shaders) {
60 const auto gl_dispatch_table =
61 StubDispatchTable(
"OpenGL ES 2.0");
63 gl_dispatch_table,
false,
66 const std::shared_ptr<impeller::Context> context =
67 surface.CreateImpellerContext();
68 const std::shared_ptr<impeller::ShaderLibrary> shaders =
69 context->GetShaderLibrary();
70 const std::shared_ptr<const impeller::ShaderFunction> func =
71 shaders->GetFunction(
"imp_line_fragment_main",
74 const std::shared_ptr<const fml::Mapping> source =
75 gles_func->GetSourceMapping();
77 std::string_view(
reinterpret_cast<const char*
>(source->GetMapping()));
78 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