Flutter Engine
 
Loading...
Searching...
No Matches
proc_table_gles_unittests.cc File Reference
#include <optional>
#include "flutter/testing/testing.h"
#include "gtest/gtest.h"
#include "impeller/renderer/backend/gles/proc_table_gles.h"
#include "impeller/renderer/backend/gles/test/mock_gles.h"

Go to the source code of this file.

Namespaces

namespace  impeller
 
namespace  impeller::testing
 

Macros

#define EXPECT_AVAILABLE(proc_ivar)    EXPECT_TRUE(mock_gles->GetProcTable().proc_ivar.IsAvailable());
 
#define EXPECT_UNAVAILABLE(proc_ivar)    EXPECT_FALSE(mock_gles->GetProcTable().proc_ivar.IsAvailable());
 

Functions

 impeller::testing::TEST (ProcTableGLES, ResolvesCorrectClearDepthProcOnES)
 
 impeller::testing::TEST (ProcTableGLES, ResolvesCorrectClearDepthProcOnDesktopGL)
 
 impeller::testing::TEST (GLErrorToString, ReturnsCorrectStringForKnownErrors)
 
 impeller::testing::TEST (GLErrorToString, ReturnsUnknownForInvalidError)
 
 impeller::testing::TEST (GLErrorToString, ReturnValueIsValidStringView)
 
 impeller::testing::TEST (GLProc, NameFieldWorksWithStringView)
 

Macro Definition Documentation

◆ EXPECT_AVAILABLE

#define EXPECT_AVAILABLE (   proc_ivar)     EXPECT_TRUE(mock_gles->GetProcTable().proc_ivar.IsAvailable());

Definition at line 15 of file proc_table_gles_unittests.cc.

20 {
21 auto mock_gles = MockGLES::Init(std::nullopt, "OpenGL ES 3.0");
22 EXPECT_TRUE(mock_gles->GetProcTable().GetDescription()->IsES());
23
26}
27
28TEST(ProcTableGLES, ResolvesCorrectClearDepthProcOnDesktopGL) {
29 auto mock_gles = MockGLES::Init(std::nullopt, "OpenGL 4.0");
30 EXPECT_FALSE(mock_gles->GetProcTable().GetDescription()->IsES());
31
34}
35
36TEST(GLErrorToString, ReturnsCorrectStringForKnownErrors) {
37 EXPECT_EQ(GLErrorToString(GL_NO_ERROR), "GL_NO_ERROR");
38 EXPECT_EQ(GLErrorToString(GL_INVALID_ENUM), "GL_INVALID_ENUM");
39 EXPECT_EQ(GLErrorToString(GL_INVALID_VALUE), "GL_INVALID_VALUE");
40 EXPECT_EQ(GLErrorToString(GL_INVALID_OPERATION), "GL_INVALID_OPERATION");
41 EXPECT_EQ(GLErrorToString(GL_INVALID_FRAMEBUFFER_OPERATION),
42 "GL_INVALID_FRAMEBUFFER_OPERATION");
43 EXPECT_EQ(GLErrorToString(GL_FRAMEBUFFER_COMPLETE),
44 "GL_FRAMEBUFFER_COMPLETE");
45 EXPECT_EQ(GLErrorToString(GL_OUT_OF_MEMORY), "GL_OUT_OF_MEMORY");
46}
47
48TEST(GLErrorToString, ReturnsUnknownForInvalidError) {
49 // Test with an invalid error code
50 GLenum invalid_error = 0x9999;
51 EXPECT_EQ(GLErrorToString(invalid_error), "Unknown.");
52}
53
54TEST(GLErrorToString, ReturnValueIsValidStringView) {
55 // Test that the returned string_view is valid and non-empty
56 auto result = GLErrorToString(GL_NO_ERROR);
57 EXPECT_FALSE(result.empty());
58 EXPECT_NE(result.data(), nullptr);
59
60 // Test that we can compare with string literals
61 EXPECT_TRUE(result == "GL_NO_ERROR");
62}
63
64TEST(GLProc, NameFieldWorksWithStringView) {
65 GLProc<void()> proc;
66
67 // Test setting name with string literal
68 const char* literal = "glTestFunction";
69 proc.name = literal;
70
71 EXPECT_EQ(proc.name, "glTestFunction");
72 EXPECT_FALSE(proc.name.empty());
73
74 // Test that the string_view properly references the original data
75 EXPECT_EQ(proc.name.data(), literal);
76}
77
78} // namespace testing
79} // namespace impeller
TEST(AsciiTableTest, Simple)
std::string_view GLErrorToString(GLenum value)
#define FOR_EACH_IMPELLER_DESKTOP_ONLY_PROC(PROC)
#define FOR_EACH_IMPELLER_ES_ONLY_PROC(PROC)
#define EXPECT_AVAILABLE(proc_ivar)
#define EXPECT_UNAVAILABLE(proc_ivar)

◆ EXPECT_UNAVAILABLE

#define EXPECT_UNAVAILABLE (   proc_ivar)     EXPECT_FALSE(mock_gles->GetProcTable().proc_ivar.IsAvailable());

Definition at line 17 of file proc_table_gles_unittests.cc.