76TEST(PathTessellatorTest, SimpleClosedPath) {
84 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
86 ::testing::InSequence sequence;
88 EXPECT_CALL(mock_receiver,
89 BeginContour(
Point(0, 0),
true));
90 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
91 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(0, 20)));
92 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 20),
Point(0, 0)));
93 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
101 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
103 ::testing::InSequence sequence;
105 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
106 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
107 EXPECT_CALL(mock_writer, Write(
Point(0, 20)));
108 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
109 EXPECT_CALL(mock_writer, EndContour());
114TEST(PathTessellatorTest, SimpleUnclosedPath) {
122 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
124 ::testing::InSequence sequence;
126 EXPECT_CALL(mock_receiver,
127 BeginContour(
Point(0, 0),
false));
128 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
129 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(0, 20)));
130 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 20),
Point(0, 0)));
131 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
false));
139 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
141 ::testing::InSequence sequence;
143 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
144 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
145 EXPECT_CALL(mock_writer, Write(
Point(0, 20)));
146 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
147 EXPECT_CALL(mock_writer, EndContour());
152TEST(PathTessellatorTest, SimplePathTrailingMoveTo) {
158 builder.
MoveTo({500, 100});
161 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
163 ::testing::InSequence sequence;
165 EXPECT_CALL(mock_receiver,
166 BeginContour(
Point(0, 0),
true));
167 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
168 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(0, 20)));
169 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 20),
Point(0, 0)));
170 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
178 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
180 ::testing::InSequence sequence;
182 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
183 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
184 EXPECT_CALL(mock_writer, Write(
Point(0, 20)));
185 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
186 EXPECT_CALL(mock_writer, EndContour());
191TEST(PathTessellatorTest, DegenerateSegmentsPath) {
205 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
207 ::testing::InSequence sequence;
209 EXPECT_CALL(mock_receiver,
210 BeginContour(
Point(0, 0),
true));
211 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
219 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
221 ::testing::InSequence sequence;
223 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
224 EXPECT_CALL(mock_writer, EndContour());
229TEST(PathTessellatorTest, QuadToLineToOptimization) {
239 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
241 ::testing::InSequence sequence;
243 EXPECT_CALL(mock_receiver,
244 BeginContour(
Point(0, 0),
true));
245 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
246 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(20, 10)));
247 EXPECT_CALL(mock_receiver, RecordLine(
Point(20, 10),
Point(0, 0)));
248 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
256 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
258 ::testing::InSequence sequence;
260 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
261 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
262 EXPECT_CALL(mock_writer, Write(
Point(20, 10)));
263 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
264 EXPECT_CALL(mock_writer, EndContour());
269TEST(PathTessellatorTest, ConicToLineToOptimization) {
281 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
283 ::testing::InSequence sequence;
285 EXPECT_CALL(mock_receiver,
286 BeginContour(
Point(0, 0),
true));
287 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
288 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(20, 10)));
289 EXPECT_CALL(mock_receiver, RecordLine(
Point(20, 10),
Point(10, 0)));
290 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 0),
Point(0, 0)));
291 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
299 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
301 ::testing::InSequence sequence;
303 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
304 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
305 EXPECT_CALL(mock_writer, Write(
Point(20, 10)));
306 EXPECT_CALL(mock_writer, Write(
Point(10, 0)));
307 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
308 EXPECT_CALL(mock_writer, EndContour());
313TEST(PathTessellatorTest, ConicToQuadToOptimization) {
324 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
326 ::testing::InSequence sequence;
328 EXPECT_CALL(mock_receiver, BeginContour(quad.p1,
true));
329 EXPECT_CALL(mock_receiver, RecordQuad(quad.p1, quad.cp, quad.p2));
330 EXPECT_CALL(mock_receiver, RecordLine(quad.p2, quad.p1));
331 EXPECT_CALL(mock_receiver, EndContour(quad.p1,
true));
339 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
341 ::testing::InSequence sequence;
343 EXPECT_CALL(mock_writer, Write(quad.p1));
345 EXPECT_CALL(mock_writer, Write(quad.Solve(1 / 5.0f)));
346 EXPECT_CALL(mock_writer, Write(quad.Solve(2 / 5.0f)));
347 EXPECT_CALL(mock_writer, Write(quad.Solve(3 / 5.0f)));
348 EXPECT_CALL(mock_writer, Write(quad.Solve(4 / 5.0f)));
349 EXPECT_CALL(mock_writer, Write(quad.p2));
351 EXPECT_CALL(mock_writer, Write(quad.p1));
352 EXPECT_CALL(mock_writer, EndContour());
357TEST(PathTessellatorTest, SimplePathMultipleMoveTo) {
359 builder.
MoveTo({500, 100});
366 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
368 ::testing::InSequence sequence;
370 EXPECT_CALL(mock_receiver,
371 BeginContour(
Point(0, 0),
true));
372 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
373 EXPECT_CALL(mock_receiver, RecordLine(
Point(10, 10),
Point(0, 20)));
374 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 20),
Point(0, 0)));
375 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
383 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
385 ::testing::InSequence sequence;
387 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
388 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
389 EXPECT_CALL(mock_writer, Write(
Point(0, 20)));
390 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
391 EXPECT_CALL(mock_writer, EndContour());
396TEST(PathTessellatorTest, ComplexPath) {
410 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
412 ::testing::InSequence sequence;
414 EXPECT_CALL(mock_receiver,
415 BeginContour(
Point(0, 0),
true));
416 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
417 EXPECT_CALL(mock_receiver, RecordQuad(quad.p1, quad.cp, quad.p2));
418 EXPECT_CALL(mock_receiver,
419 RecordConic(conic.p1, conic.cp, conic.p2, conic.weight));
420 EXPECT_CALL(mock_receiver,
421 RecordCubic(cubic.p1, cubic.cp1, cubic.cp2, cubic.p2));
422 EXPECT_CALL(mock_receiver, RecordLine(cubic.p2,
Point(0, 0)));
423 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
431 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
433 ::testing::InSequence sequence;
435 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
436 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
438 EXPECT_CALL(mock_writer, Write(quad.Solve(1 / 5.0f)));
439 EXPECT_CALL(mock_writer, Write(quad.Solve(2 / 5.0f)));
440 EXPECT_CALL(mock_writer, Write(quad.Solve(3 / 5.0f)));
441 EXPECT_CALL(mock_writer, Write(quad.Solve(4 / 5.0f)));
442 EXPECT_CALL(mock_writer, Write(quad.p2));
445 EXPECT_CALL(mock_writer, Write(conic.Solve(1 / 8.0f)));
446 EXPECT_CALL(mock_writer, Write(conic.Solve(2 / 8.0f)));
447 EXPECT_CALL(mock_writer, Write(conic.Solve(3 / 8.0f)));
448 EXPECT_CALL(mock_writer, Write(conic.Solve(4 / 8.0f)));
449 EXPECT_CALL(mock_writer, Write(conic.Solve(5 / 8.0f)));
450 EXPECT_CALL(mock_writer, Write(conic.Solve(6 / 8.0f)));
451 EXPECT_CALL(mock_writer, Write(conic.Solve(7 / 8.0f)));
452 EXPECT_CALL(mock_writer, Write(conic.p2));
455 EXPECT_CALL(mock_writer, Write(cubic.Solve(1 / 9.0f)));
456 EXPECT_CALL(mock_writer, Write(cubic.Solve(2 / 9.0f)));
457 EXPECT_CALL(mock_writer, Write(cubic.Solve(3 / 9.0f)));
458 EXPECT_CALL(mock_writer, Write(cubic.Solve(4 / 9.0f)));
459 EXPECT_CALL(mock_writer, Write(cubic.Solve(5 / 9.0f)));
460 EXPECT_CALL(mock_writer, Write(cubic.Solve(6 / 9.0f)));
461 EXPECT_CALL(mock_writer, Write(cubic.Solve(7 / 9.0f)));
462 EXPECT_CALL(mock_writer, Write(cubic.Solve(8 / 9.0f)));
463 EXPECT_CALL(mock_writer, Write(cubic.p2));
465 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
466 EXPECT_CALL(mock_writer, EndContour());
471TEST(PathTessellatorTest, ComplexPathTrailingMoveTo) {
483 builder.
MoveTo({500, 100});
486 ::testing::StrictMock<MockSegmentReceiver> mock_receiver;
488 ::testing::InSequence sequence;
490 EXPECT_CALL(mock_receiver,
491 BeginContour(
Point(0, 0),
true));
492 EXPECT_CALL(mock_receiver, RecordLine(
Point(0, 0),
Point(10, 10)));
493 EXPECT_CALL(mock_receiver, RecordQuad(quad.p1, quad.cp, quad.p2));
494 EXPECT_CALL(mock_receiver,
495 RecordConic(conic.p1, conic.cp, conic.p2, conic.weight));
496 EXPECT_CALL(mock_receiver,
497 RecordCubic(cubic.p1, cubic.cp1, cubic.cp2, cubic.p2));
498 EXPECT_CALL(mock_receiver, RecordLine(cubic.p2,
Point(0, 0)));
499 EXPECT_CALL(mock_receiver, EndContour(
Point(0, 0),
true));
507 ::testing::StrictMock<MockPathVertexWriter> mock_writer;
509 ::testing::InSequence sequence;
511 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
512 EXPECT_CALL(mock_writer, Write(
Point(10, 10)));
514 EXPECT_CALL(mock_writer, Write(quad.Solve(1 / 5.0f)));
515 EXPECT_CALL(mock_writer, Write(quad.Solve(2 / 5.0f)));
516 EXPECT_CALL(mock_writer, Write(quad.Solve(3 / 5.0f)));
517 EXPECT_CALL(mock_writer, Write(quad.Solve(4 / 5.0f)));
518 EXPECT_CALL(mock_writer, Write(quad.p2));
521 EXPECT_CALL(mock_writer, Write(conic.Solve(1 / 8.0f)));
522 EXPECT_CALL(mock_writer, Write(conic.Solve(2 / 8.0f)));
523 EXPECT_CALL(mock_writer, Write(conic.Solve(3 / 8.0f)));
524 EXPECT_CALL(mock_writer, Write(conic.Solve(4 / 8.0f)));
525 EXPECT_CALL(mock_writer, Write(conic.Solve(5 / 8.0f)));
526 EXPECT_CALL(mock_writer, Write(conic.Solve(6 / 8.0f)));
527 EXPECT_CALL(mock_writer, Write(conic.Solve(7 / 8.0f)));
528 EXPECT_CALL(mock_writer, Write(conic.p2));
531 EXPECT_CALL(mock_writer, Write(cubic.Solve(1 / 9.0f)));
532 EXPECT_CALL(mock_writer, Write(cubic.Solve(2 / 9.0f)));
533 EXPECT_CALL(mock_writer, Write(cubic.Solve(3 / 9.0f)));
534 EXPECT_CALL(mock_writer, Write(cubic.Solve(4 / 9.0f)));
535 EXPECT_CALL(mock_writer, Write(cubic.Solve(5 / 9.0f)));
536 EXPECT_CALL(mock_writer, Write(cubic.Solve(6 / 9.0f)));
537 EXPECT_CALL(mock_writer, Write(cubic.Solve(7 / 9.0f)));
538 EXPECT_CALL(mock_writer, Write(cubic.Solve(8 / 9.0f)));
539 EXPECT_CALL(mock_writer, Write(cubic.p2));
541 EXPECT_CALL(mock_writer, Write(
Point(0, 0)));
542 EXPECT_CALL(mock_writer, EndContour());