Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
mock_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 "flutter/testing/testing.h" // IWYU pragma: keep
6#include "gtest/gtest.h"
9
10namespace impeller {
11namespace testing {
12
13// This test just checks that the proc table is initialized correctly.
14//
15// If this test doesn't pass, no test that uses the proc table will pass.
16TEST(MockGLES, CanInitialize) {
17 auto mock_gles = MockGLES::Init();
18
19 std::string_view vendor(reinterpret_cast<const char*>(
20 mock_gles->GetProcTable().GetString(GL_VENDOR)));
21 EXPECT_EQ(vendor, "MockGLES");
22}
23
24// Tests we can call two functions and capture the calls.
25TEST(MockGLES, CapturesPushAndPopDebugGroup) {
26 auto mock_gles = MockGLES::Init();
27
28 auto& gl = mock_gles->GetProcTable();
29 gl.PushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, 0, -1, "test");
30 gl.PopDebugGroupKHR();
31
32 auto calls = mock_gles->GetCapturedCalls();
33 EXPECT_EQ(calls, std::vector<std::string>(
34 {"PushDebugGroupKHR", "PopDebugGroupKHR"}));
35}
36
37// Tests that if we call a function we have not mocked, it's OK.
38TEST(MockGLES, CanCallUnmockedFunction) {
39 auto mock_gles = MockGLES::Init();
40
41 auto& gl = mock_gles->GetProcTable();
42 gl.DeleteFramebuffers(1, nullptr);
43
44 // Test should still complete.
45 // If we end up mocking DeleteFramebuffers, delete this test.
46}
47
48} // namespace testing
49} // namespace impeller
#define TEST(S, s, D, expected)
Provides a mocked version of the |ProcTableGLES| class.
Definition mock_gles.h:26
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.
Definition mock_gles.cc:166