5#define FML_USED_ON_EMBEDDER
7#include "flutter/shell/common/pipeline.h"
13#include "gtest/gtest.h"
21TEST(PipelineTest, ConsumeOneVal) {
22 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(2);
26 const int test_val = 1;
28 continuation.
Complete(std::make_unique<int>(test_val));
29 ASSERT_EQ(
result.success,
true);
30 ASSERT_EQ(
result.is_first_item,
true);
33 [&test_val](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val); });
38TEST(PipelineTest, ContinuationCanOnlyBeUsedOnce) {
39 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(2);
43 const int test_val = 1;
45 continuation.
Complete(std::make_unique<int>(test_val));
46 ASSERT_EQ(
result.success,
true);
47 ASSERT_EQ(
result.is_first_item,
true);
50 [&test_val](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val); });
53 ASSERT_EQ(
result.success,
false);
57 pipeline->Consume([](std::unique_ptr<int> v) {
FAIL(); });
60 ASSERT_EQ(
result.success,
false);
64TEST(PipelineTest, PushingMoreThanDepthCompletesFirstSubmission) {
66 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
71 const int test_val_1 = 1, test_val_2 = 2;
73 continuation_1.
Complete(std::make_unique<int>(test_val_1));
74 ASSERT_EQ(
result.success,
true);
75 ASSERT_EQ(
result.is_first_item,
true);
76 result = continuation_2.
Complete(std::make_unique<int>(test_val_2));
77 ASSERT_EQ(
result.success,
false);
80 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
85TEST(PipelineTest, PushingMultiProcessesInOrder) {
87 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
92 const int test_val_1 = 1, test_val_2 = 2;
94 continuation_1.
Complete(std::make_unique<int>(test_val_1));
95 ASSERT_EQ(
result.success,
true);
96 ASSERT_EQ(
result.is_first_item,
true);
97 result = continuation_2.
Complete(std::make_unique<int>(test_val_2));
98 ASSERT_EQ(
result.success,
true);
99 ASSERT_EQ(
result.is_first_item,
false);
102 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
106 [&test_val_2](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_2); });
110TEST(PipelineTest, ProduceIfEmptyDoesNotConsumeWhenQueueIsNotEmpty) {
112 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
115 Continuation continuation_2 = pipeline->ProduceIfEmpty();
117 const int test_val_1 = 1, test_val_2 = 2;
119 continuation_1.
Complete(std::make_unique<int>(test_val_1));
120 ASSERT_EQ(
result.success,
true);
121 ASSERT_EQ(
result.is_first_item,
true);
122 result = continuation_2.
Complete(std::make_unique<int>(test_val_2));
123 ASSERT_EQ(
result.success,
false);
126 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
130TEST(PipelineTest, ProduceIfEmptySuccessfulIfQueueIsEmpty) {
132 std::shared_ptr<IntPipeline> pipeline = std::make_shared<IntPipeline>(depth);
134 Continuation continuation_1 = pipeline->ProduceIfEmpty();
136 const int test_val_1 = 1;
138 continuation_1.
Complete(std::make_unique<int>(test_val_1));
139 ASSERT_EQ(
result.success,
true);
140 ASSERT_EQ(
result.is_first_item,
true);
143 [&test_val_1](std::unique_ptr<int> v) { ASSERT_EQ(*v, test_val_1); });
PipelineProduceResult Complete(ResourcePtr resource)
Completes the continuation with the specified resource.
#define FAIL(name, result)
TEST(DisplayListComplexity, EmptyDisplayList)