| Flutter Impeller |

checkerboard_contents_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 <memory>
6 #include <optional>
7
8 #include "gtest/gtest.h"
9
10 #include "impeller/entity/contents/checkerboard_contents.h"
11 #include "impeller/entity/contents/contents.h"
12 #include "impeller/entity/entity.h"
13 #include "impeller/entity/entity_playground.h"
14 #include "impeller/renderer/render_target.h"
15
16 namespace impeller {
17 namespace testing {
18
19 using EntityTest = EntityPlayground;
20
21 #ifdef IMPELLER_DEBUG
22 TEST(EntityTest, HasNulloptCoverage) {
23 auto contents = std::make_shared<CheckerboardContents>();
24
25 Entity entity;
26 ASSERT_EQ(contents->GetCoverage(entity), std::nullopt);
27 }
28
29 TEST_P(EntityTest, RendersWithoutError) {
30 auto contents = std::make_shared<CheckerboardContents>();
31 contents->SetColor(Color::Aqua());
32 contents->SetSquareSize(10);
33
34 auto content_context = GetContentContext();
35 auto buffer = content_context->GetContext()->CreateCommandBuffer();
36 auto render_target = RenderTarget::CreateOffscreenMSAA(
37 *content_context->GetContext(),
38 *GetContentContext()->GetRenderTargetCache(), {100, 100});
39 auto render_pass = buffer->CreateRenderPass(render_target);
40 Entity entity;
41
42 ASSERT_TRUE(render_pass->GetCommands().empty());
43 ASSERT_TRUE(contents->Render(*content_context, entity, *render_pass));
44 ASSERT_FALSE(render_pass->GetCommands().empty());
45 }
46 #endif // IMPELLER_DEBUG
47
48 } // namespace testing
49 } // namespace impeller
contents.h
entity.h
checkerboard_contents.h
impeller::Entity
Definition: entity.h:21
impeller::testing::EntityTest
EntityPlayground EntityTest
Definition: checkerboard_contents_unittests.cc:19
impeller::testing::TEST
TEST(CanvasRecorder, Save)
Definition: canvas_recorder_unittests.cc:61
impeller::EntityPlayground
Definition: entity_playground.h:18
render_target.h
impeller::testing::TEST_P
TEST_P(AiksTest, CanRenderLinearGradientClamp)
Definition: aiks_gradient_unittests.cc:48
impeller
Definition: aiks_context.cc:10
impeller::RenderTarget::CreateOffscreenMSAA
static RenderTarget CreateOffscreenMSAA(const Context &context, RenderTargetAllocator &allocator, ISize size, const std::string &label="Offscreen MSAA", AttachmentConfigMSAA color_attachment_config=kDefaultColorAttachmentConfigMSAA, std::optional< AttachmentConfig > stencil_attachment_config=kDefaultStencilAttachmentConfig)
Definition: render_target.cc:265
impeller::Color::Aqua
static constexpr Color Aqua()
Definition: color.h:282
entity_playground.h