| Flutter Impeller |

pipeline_library_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 "impeller/renderer/testing/mocks.h"
6
7 namespace impeller {
8 namespace testing {
9
10 TEST(MockPipelineLibrary, LogAndGetPipelineUsageSinglePipeline) {
11 MockPipelineLibrary pipeline_library;
12
13 PipelineDescriptor pipeline_desc;
14 pipeline_desc.SetLabel("pipeline");
15
16 pipeline_library.LogPipelineUsage(pipeline_desc);
17 pipeline_library.LogPipelineUsage(pipeline_desc);
18
19 auto usage_counts = pipeline_library.GetPipelineUseCounts();
20 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \
21 FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE
22 EXPECT_EQ(usage_counts[pipeline_desc], 2);
23 #else
24 EXPECT_EQ(usage_counts[pipeline_desc], 0);
25 #endif
26 }
27
28 TEST(MockPipelineLibrary, LogAndGetPipelineUsageMultiplePipelines) {
29 MockPipelineLibrary pipeline_library;
30
31 PipelineDescriptor pipeline_a;
32 pipeline_a.SetLabel("pipeline_a");
33
34 PipelineDescriptor pipeline_b;
35 pipeline_b.SetLabel("pipeline_b");
36
37 pipeline_library.LogPipelineUsage(pipeline_a);
38 pipeline_library.LogPipelineUsage(pipeline_a);
39 pipeline_library.LogPipelineUsage(pipeline_b);
40
41 auto usage_counts = pipeline_library.GetPipelineUseCounts();
42
43 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG || \
44 FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE
45 EXPECT_EQ(usage_counts[pipeline_a], 2);
46 EXPECT_EQ(usage_counts[pipeline_b], 1);
47 #else
48 EXPECT_EQ(usage_counts[pipeline_a], 0);
49 EXPECT_EQ(usage_counts[pipeline_b], 0);
50 #endif
51 }
52
53 } // namespace testing
54 } // namespace impeller
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineDescriptor::SetLabel
PipelineDescriptor & SetLabel(std::string_view label)
Definition: pipeline_descriptor.cc:72
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller
Definition: allocation.cc:12