Flutter Engine
 
Loading...
Searching...
No Matches
proc_table_gles_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <optional>
6
7#include "flutter/testing/testing.h" // IWYU pragma: keep
8#include "gtest/gtest.h"
11
12namespace impeller {
13namespace testing {
14
15#define EXPECT_AVAILABLE(proc_ivar) \
16 EXPECT_TRUE(mock_gles->GetProcTable().proc_ivar.IsAvailable());
17#define EXPECT_UNAVAILABLE(proc_ivar) \
18 EXPECT_FALSE(mock_gles->GetProcTable().proc_ivar.IsAvailable());
19
20TEST(ProcTableGLES, ResolvesCorrectClearDepthProcOnES) {
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
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt)
Definition mock_gles.cc:260
TEST(FrameTimingsRecorderTest, RecordVsync)
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)
std::string_view name