|
| 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 "flutter/testing/testing.h" |
| 6 | +#include "gtest/gtest.h" |
| 7 | +#include "impeller/geometry/path_builder.h" |
| 8 | +#include "impeller/tessellator/tessellator.h" |
| 9 | + |
| 10 | +namespace impeller { |
| 11 | +namespace testing { |
| 12 | + |
| 13 | +TEST(TessellatorTest, TessellatorReturnsCorrectResultStatus) { |
| 14 | + // Zero points. |
| 15 | + { |
| 16 | + Tessellator t; |
| 17 | + auto polyline = PathBuilder{}.TakePath().CreatePolyline(); |
| 18 | + Tessellator::Result result = |
| 19 | + t.Tessellate(FillType::kPositive, polyline, [](Point point) {}); |
| 20 | + |
| 21 | + ASSERT_EQ(polyline.points.size(), 0u); |
| 22 | + ASSERT_EQ(result, Tessellator::Result::kInputError); |
| 23 | + } |
| 24 | + |
| 25 | + // One point. |
| 26 | + { |
| 27 | + Tessellator t; |
| 28 | + auto polyline = PathBuilder{}.LineTo({0, 0}).TakePath().CreatePolyline(); |
| 29 | + Tessellator::Result result = |
| 30 | + t.Tessellate(FillType::kPositive, polyline, [](Point point) {}); |
| 31 | + |
| 32 | + ASSERT_EQ(polyline.points.size(), 1u); |
| 33 | + ASSERT_EQ(result, Tessellator::Result::kSuccess); |
| 34 | + } |
| 35 | + |
| 36 | + // Two points. |
| 37 | + { |
| 38 | + Tessellator t; |
| 39 | + auto polyline = |
| 40 | + PathBuilder{}.AddLine({0, 0}, {0, 1}).TakePath().CreatePolyline(); |
| 41 | + Tessellator::Result result = |
| 42 | + t.Tessellate(FillType::kPositive, polyline, [](Point point) {}); |
| 43 | + |
| 44 | + ASSERT_EQ(polyline.points.size(), 2u); |
| 45 | + ASSERT_EQ(result, Tessellator::Result::kSuccess); |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +} // namespace testing |
| 50 | +} // namespace impeller |
0 commit comments