Flutter Engine
 
Loading...
Searching...
No Matches
gpu_tracer_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
13using ::testing::_;
14
15#ifdef IMPELLER_DEBUG
16TEST(GPUTracerGLES, CanFormatFramebufferErrorMessage) {
17 auto const extensions = std::vector<const char*>{
18 "GL_KHR_debug", //
19 "GL_EXT_disjoint_timer_query", //
20 };
21 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
22
23 {
24 ::testing::InSequence seq;
25 auto gen_queries = [](GLsizei n, GLuint* ids) {
26 for (int i = 0; i < n; ++i) {
27 ids[i] = i + 1;
28 }
29 };
30 EXPECT_CALL(*mock_gles_impl, GenQueriesEXT(_, _)).WillOnce(gen_queries);
31 EXPECT_CALL(*mock_gles_impl, BeginQueryEXT(GL_TIME_ELAPSED_EXT, _));
32 EXPECT_CALL(*mock_gles_impl, EndQueryEXT(GL_TIME_ELAPSED_EXT));
33 EXPECT_CALL(*mock_gles_impl,
34 GetQueryObjectuivEXT(_, GL_QUERY_RESULT_AVAILABLE_EXT, _))
35 .WillOnce([](GLuint id, GLenum target, GLuint* result) {
36 *result = GL_TRUE;
37 });
38 EXPECT_CALL(*mock_gles_impl,
39 GetQueryObjectui64vEXT(_, GL_QUERY_RESULT_EXT, _))
40 .WillOnce([](GLuint id, GLenum target, GLuint64* result) {
41 *result = 1000u;
42 });
43 EXPECT_CALL(*mock_gles_impl, DeleteQueriesEXT(_, _));
44 EXPECT_CALL(*mock_gles_impl, GenQueriesEXT(_, _)).WillOnce(gen_queries);
45 EXPECT_CALL(*mock_gles_impl, BeginQueryEXT(GL_TIME_ELAPSED_EXT, _));
46 }
47 std::shared_ptr<MockGLES> mock_gles =
48 MockGLES::Init(std::move(mock_gles_impl), extensions);
49 auto tracer =
50 std::make_shared<GPUTracerGLES>(mock_gles->GetProcTable(), true);
51 tracer->RecordRasterThread();
52 tracer->MarkFrameStart(mock_gles->GetProcTable());
53 tracer->MarkFrameEnd(mock_gles->GetProcTable());
54 tracer->MarkFrameStart(mock_gles->GetProcTable());
55}
56
57#endif // IMPELLER_DEBUG
58
59} // namespace testing
60} // 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
uint32_t * target
TEST(FrameTimingsRecorderTest, RecordVsync)