5#include "flutter/testing/testing.h"
7#include "gtest/gtest.h"
14TEST(SpecConstant, CanCreateShaderWithSpecializationConstant) {
16 auto& proc_table = mock_gles->GetProcTable();
19 "#ifndef SPIRV_CROSS_CONSTANT_ID_0\n"
20 "#define SPIRV_CROSS_CONSTANT_ID_0 1\n"
22 "void main() { return vec4(0.0); }";
23 auto test_shader = std::make_shared<fml::DataMapping>(shader_source);
25 auto result = proc_table.ComputeShaderWithDefines(*test_shader, {0});
27 auto expected_shader_source =
29 "#define SPIRV_CROSS_CONSTANT_ID_0 0.000000\n"
30 "#ifndef SPIRV_CROSS_CONSTANT_ID_0\n"
31 "#define SPIRV_CROSS_CONSTANT_ID_0 1\n"
33 "void main() { return vec4(0.0); }";
36 GTEST_FAIL() <<
"Expected shader source";
38 ASSERT_EQ(
result.value(), expected_shader_source);
41TEST(SpecConstant, CanCreateShaderWithSpecializationConstantMultipleValues) {
43 auto& proc_table = mock_gles->GetProcTable();
46 "#ifndef SPIRV_CROSS_CONSTANT_ID_0\n"
47 "#define SPIRV_CROSS_CONSTANT_ID_0 1\n"
49 "void main() { return vec4(0.0); }";
50 auto test_shader = std::make_shared<fml::DataMapping>(shader_source);
53 proc_table.ComputeShaderWithDefines(*test_shader, {0, 1, 2, 3, 4, 5});
55 auto expected_shader_source =
57 "#define SPIRV_CROSS_CONSTANT_ID_0 0.000000\n"
58 "#define SPIRV_CROSS_CONSTANT_ID_1 1.000000\n"
59 "#define SPIRV_CROSS_CONSTANT_ID_2 2.000000\n"
60 "#define SPIRV_CROSS_CONSTANT_ID_3 3.000000\n"
61 "#define SPIRV_CROSS_CONSTANT_ID_4 4.000000\n"
62 "#define SPIRV_CROSS_CONSTANT_ID_5 5.000000\n"
63 "#ifndef SPIRV_CROSS_CONSTANT_ID_0\n"
64 "#define SPIRV_CROSS_CONSTANT_ID_0 1\n"
66 "void main() { return vec4(0.0); }";
69 GTEST_FAIL() <<
"Expected shader source";
71 ASSERT_EQ(
result.value(), expected_shader_source);
static std::shared_ptr< MockGLES > Init(const std::optional< std::vector< const unsigned char * > > &extensions=std::nullopt, const char *version_string="OpenGL ES 3.0", ProcTableGLES::Resolver resolver=kMockResolverGLES)
Returns an initialized |MockGLES| instance.
TEST(AiksCanvasTest, EmptyCullRect)