Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
impeller::testing::ContextSpy Class Reference

#include <context_spy.h>

Inheritance diagram for impeller::testing::ContextSpy:

Public Member Functions

std::shared_ptr< ContextMockMakeContext (const std::shared_ptr< Context > &real_context)
 

Static Public Member Functions

static std::shared_ptr< ContextSpyMake ()
 

Public Attributes

std::vector< std::shared_ptr< RecordingRenderPass > > render_passes_
 
std::shared_ptr< CommandQueuecommand_queue_
 

Detailed Description

Forwards calls to a real Context but can store information about how the Context was used.

Definition at line 26 of file context_spy.h.

Member Function Documentation

◆ Make()

std::shared_ptr< ContextSpy > impeller::testing::ContextSpy::Make ( )
static

Definition at line 23 of file context_spy.cc.

23 {
24 return std::shared_ptr<ContextSpy>(new ContextSpy());
25}

◆ MakeContext()

std::shared_ptr< ContextMock > impeller::testing::ContextSpy::MakeContext ( const std::shared_ptr< Context > &  real_context)

Definition at line 27 of file context_spy.cc.

28 {
29 std::shared_ptr<ContextMock> mock_context =
30 std::make_shared<::testing::NiceMock<ContextMock>>();
31 std::shared_ptr<ContextSpy> shared_this = shared_from_this();
32
33 ON_CALL(*mock_context, IsValid).WillByDefault([real_context]() {
34 return real_context->IsValid();
35 });
36
37 ON_CALL(*mock_context, GetBackendType)
38 .WillByDefault([real_context]() -> Context::BackendType {
39 return real_context->GetBackendType();
40 });
41
42 ON_CALL(*mock_context, GetCapabilities)
43 .WillByDefault(
44 [real_context]() -> const std::shared_ptr<const Capabilities>& {
45 return real_context->GetCapabilities();
46 });
47
48 ON_CALL(*mock_context, UpdateOffscreenLayerPixelFormat)
49 .WillByDefault([real_context](PixelFormat format) {
50 return real_context->UpdateOffscreenLayerPixelFormat(format);
51 });
52
53 ON_CALL(*mock_context, GetResourceAllocator).WillByDefault([real_context]() {
54 return real_context->GetResourceAllocator();
55 });
56
57 ON_CALL(*mock_context, GetShaderLibrary).WillByDefault([real_context]() {
58 return real_context->GetShaderLibrary();
59 });
60
61 ON_CALL(*mock_context, GetSamplerLibrary).WillByDefault([real_context]() {
62 return real_context->GetSamplerLibrary();
63 });
64
65 ON_CALL(*mock_context, GetPipelineLibrary).WillByDefault([real_context]() {
66 return real_context->GetPipelineLibrary();
67 });
68
69 ON_CALL(*mock_context, GetCommandQueue).WillByDefault([shared_this]() {
70 return shared_this->command_queue_;
71 });
72
74 .WillByDefault([real_context, shared_this]() {
75 auto real_buffer = real_context->CreateCommandBuffer();
76 auto spy = std::make_shared<::testing::NiceMock<CommandBufferMock>>(
77 real_context);
78
79 ON_CALL(*spy, IsValid).WillByDefault([real_buffer]() {
80 return real_buffer->IsValid();
81 });
82
83 ON_CALL(*spy, SetLabel)
84 .WillByDefault([real_buffer](const std::string& label) {
85 return real_buffer->SetLabel(label);
86 });
87
88 ON_CALL(*spy, OnCreateRenderPass)
89 .WillByDefault([real_buffer, shared_this,
90 real_context](const RenderTarget& render_target) {
91 std::shared_ptr<RenderPass> result =
93 real_buffer.get(), render_target);
94 std::shared_ptr<RecordingRenderPass> recorder =
95 std::make_shared<RecordingRenderPass>(result, real_context,
96 render_target);
97 shared_this->render_passes_.push_back(recorder);
98 return recorder;
99 });
100
101 ON_CALL(*spy, OnCreateBlitPass).WillByDefault([real_buffer]() {
102 return CommandBufferMock::ForwardOnCreateBlitPass(real_buffer.get());
103 });
104
105 ON_CALL(*spy, OnSubmitCommands)
106 .WillByDefault(
109 real_buffer.get(), std::move(callback));
110 });
111
112 ON_CALL(*spy, OnWaitUntilScheduled).WillByDefault([real_buffer]() {
114 real_buffer.get());
115 });
116
117 ON_CALL(*spy, OnCreateComputePass).WillByDefault([real_buffer]() {
119 real_buffer.get());
120 });
121
122 return spy;
123 });
124
125 return mock_context;
126}
std::function< void(Status)> CompletionCallback
static std::shared_ptr< BlitPass > ForwardOnCreateBlitPass(CommandBuffer *command_buffer)
static std::shared_ptr< RenderPass > ForwardOnCreateRenderPass(CommandBuffer *command_buffer, const RenderTarget &render_target)
static std::shared_ptr< ComputePass > ForwardOnCreateComputePass(CommandBuffer *command_buffer)
static bool ForwardOnSubmitCommands(CommandBuffer *command_buffer, CompletionCallback callback)
static void ForwardOnWaitUntilScheduled(CommandBuffer *command_buffer)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
uint32_t uint32_t * format
static MockContext mock_context
Definition mock_epoxy.cc:51
static id< MTLCommandBuffer > CreateCommandBuffer(id< MTLCommandQueue > queue)

Member Data Documentation

◆ command_queue_

std::shared_ptr<CommandQueue> impeller::testing::ContextSpy::command_queue_
Initial value:
=
std::make_shared<NoopCommandQueue>()

Definition at line 34 of file context_spy.h.

◆ render_passes_

std::vector<std::shared_ptr<RecordingRenderPass> > impeller::testing::ContextSpy::render_passes_

Definition at line 33 of file context_spy.h.


The documentation for this class was generated from the following files: