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 
12 #include "impeller/entity/contents/test/recording_render_pass.h"
13 #include "impeller/entity/entity.h"
16 
17 namespace impeller {
18 namespace testing {
19 
21 
22 #ifdef IMPELLER_DEBUG
23 TEST(EntityTest, HasNulloptCoverage) {
24  auto contents = std::make_shared<CheckerboardContents>();
25 
26  Entity entity;
27  ASSERT_EQ(contents->GetCoverage(entity), std::nullopt);
28 }
29 
30 TEST_P(EntityTest, RendersWithoutError) {
31  auto contents = std::make_shared<CheckerboardContents>();
32  contents->SetColor(Color::Aqua());
33  contents->SetSquareSize(10);
34 
35  auto content_context = GetContentContext();
36  auto buffer = content_context->GetContext()->CreateCommandBuffer();
37  auto render_target =
38  GetContentContext()->GetRenderTargetCache()->CreateOffscreenMSAA(
39  *content_context->GetContext(), {100, 100},
40  /*mip_count=*/1);
41  auto render_pass = buffer->CreateRenderPass(render_target);
42  auto recording_pass = std::make_shared<RecordingRenderPass>(
43  render_pass, GetContext(), render_target);
44 
45  Entity entity;
46 
47  ASSERT_TRUE(recording_pass->GetCommands().empty());
48  ASSERT_TRUE(contents->Render(*content_context, entity, *recording_pass));
49  ASSERT_FALSE(recording_pass->GetCommands().empty());
50 
51  if (GetParam() == PlaygroundBackend::kMetal) {
52  recording_pass->EncodeCommands();
53  }
54 }
55 #endif // IMPELLER_DEBUG
56 
57 } // namespace testing
58 } // namespace impeller
contents.h
entity.h
impeller::PlaygroundBackend::kMetal
@ kMetal
checkerboard_contents.h
impeller::Entity
Definition: entity.h:21
impeller::testing::EntityTest
EntityPlayground EntityTest
Definition: checkerboard_contents_unittests.cc:20
impeller::testing::TEST
TEST(CanvasRecorder, Save)
Definition: canvas_recorder_unittests.cc:65
impeller::EntityPlayground
Definition: entity_playground.h:18
impeller::testing::TEST_P
TEST_P(AiksTest, CanRenderMaskBlurHugeSigma)
Definition: aiks_blur_unittests.cc:23
render_target.h
impeller
Definition: aiks_blur_unittests.cc:20
impeller::Color::Aqua
static constexpr Color Aqua()
Definition: color.h:282
entity_playground.h