Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp

Issue 1819783002: Blink Platform UnitBezier: Implement Slope and Range methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 EXPECT_EQ(regions.size(), 2ul); 445 EXPECT_EQ(regions.size(), 2ul);
446 EXPECT_EQ(regions.at(0).half, TimingFunction::RangeHalf::Lower); 446 EXPECT_EQ(regions.at(0).half, TimingFunction::RangeHalf::Lower);
447 EXPECT_EQ(regions.at(1).half, TimingFunction::RangeHalf::Upper); 447 EXPECT_EQ(regions.at(1).half, TimingFunction::RangeHalf::Upper);
448 448
449 EXPECT_EQ(0, regions.at(0).start); 449 EXPECT_EQ(0, regions.at(0).start);
450 EXPECT_EQ(regions.at(0).end, regions.at(1).start); 450 EXPECT_EQ(regions.at(0).end, regions.at(1).start);
451 EXPECT_EQ(1, regions.at(1).end); 451 EXPECT_EQ(1, regions.at(1).end);
452 452
453 UnitBezier bezier = UnitBezier(x1, y1, x2, y2); 453 UnitBezier bezier = UnitBezier(x1, y1, x2, y2);
454 EXPECT_FLOAT_EQ(0.5, bezier.solve(regions.at(0).end, std::numeric_limits<dou ble>::epsilon())); 454 EXPECT_FLOAT_EQ(0.5, bezier.solveWithEpsilon(regions.at(0).end, std::numeric _limits<double>::epsilon()));
455 } 455 }
456 456
457 static void checkCubicRegions4(double x1, double y1, double x2, double y2) 457 static void checkCubicRegions4(double x1, double y1, double x2, double y2)
458 { 458 {
459 Vector<TimingFunction::PartitionRegion> regions = Vector<TimingFunction::Par titionRegion>(); 459 Vector<TimingFunction::PartitionRegion> regions = Vector<TimingFunction::Par titionRegion>();
460 RefPtr<TimingFunction> cubic = CubicBezierTimingFunction::create(x1, y1, x2, y2); 460 RefPtr<TimingFunction> cubic = CubicBezierTimingFunction::create(x1, y1, x2, y2);
461 cubic->partition(regions); 461 cubic->partition(regions);
462 462
463 EXPECT_EQ(regions.size(), 4ul); 463 EXPECT_EQ(regions.size(), 4ul);
464 EXPECT_EQ(regions.at(0).half, TimingFunction::RangeHalf::Lower); 464 EXPECT_EQ(regions.at(0).half, TimingFunction::RangeHalf::Lower);
465 EXPECT_EQ(regions.at(1).half, TimingFunction::RangeHalf::Upper); 465 EXPECT_EQ(regions.at(1).half, TimingFunction::RangeHalf::Upper);
466 EXPECT_EQ(regions.at(2).half, TimingFunction::RangeHalf::Lower); 466 EXPECT_EQ(regions.at(2).half, TimingFunction::RangeHalf::Lower);
467 EXPECT_EQ(regions.at(3).half, TimingFunction::RangeHalf::Upper); 467 EXPECT_EQ(regions.at(3).half, TimingFunction::RangeHalf::Upper);
468 468
469 EXPECT_EQ(0, regions.at(0).start); 469 EXPECT_EQ(0, regions.at(0).start);
470 EXPECT_EQ(regions.at(0).end, regions.at(1).start); 470 EXPECT_EQ(regions.at(0).end, regions.at(1).start);
471 EXPECT_EQ(regions.at(1).end, regions.at(2).start); 471 EXPECT_EQ(regions.at(1).end, regions.at(2).start);
472 EXPECT_EQ(regions.at(2).end, regions.at(3).start); 472 EXPECT_EQ(regions.at(2).end, regions.at(3).start);
473 EXPECT_EQ(1, regions.at(3).end); 473 EXPECT_EQ(1, regions.at(3).end);
474 474
475 UnitBezier bezier = UnitBezier(x1, y1, x2, y2); 475 UnitBezier bezier = UnitBezier(x1, y1, x2, y2);
476 EXPECT_FLOAT_EQ(0.5, bezier.solve(regions.at(0).end, std::numeric_limits<dou ble>::epsilon())); 476 EXPECT_FLOAT_EQ(0.5, bezier.solveWithEpsilon(regions.at(0).end, std::numeric _limits<double>::epsilon()));
477 EXPECT_FLOAT_EQ(0.5, bezier.solve(regions.at(1).end, std::numeric_limits<dou ble>::epsilon())); 477 EXPECT_FLOAT_EQ(0.5, bezier.solveWithEpsilon(regions.at(1).end, std::numeric _limits<double>::epsilon()));
478 } 478 }
479 479
480 TEST_F(TimingFunctionTest, StepsPartitioning) 480 TEST_F(TimingFunctionTest, StepsPartitioning)
481 { 481 {
482 checkSteps(1, StepsTimingFunction::StepAtPosition::Start, 0.0); 482 checkSteps(1, StepsTimingFunction::StepAtPosition::Start, 0.0);
483 checkSteps(1, StepsTimingFunction::StepAtPosition::Middle, 0.5); 483 checkSteps(1, StepsTimingFunction::StepAtPosition::Middle, 0.5);
484 checkSteps(1, StepsTimingFunction::StepAtPosition::End, 1.0); 484 checkSteps(1, StepsTimingFunction::StepAtPosition::End, 1.0);
485 485
486 checkSteps(2, StepsTimingFunction::StepAtPosition::Start, 0.0); 486 checkSteps(2, StepsTimingFunction::StepAtPosition::Start, 0.0);
487 checkSteps(2, StepsTimingFunction::StepAtPosition::Middle, 0.25); 487 checkSteps(2, StepsTimingFunction::StepAtPosition::Middle, 0.25);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 checkCubicRegions2(0.0, 1.64, 0.0, -1.5); 541 checkCubicRegions2(0.0, 1.64, 0.0, -1.5);
542 542
543 // Curves with turning points touching y = 0.5 543 // Curves with turning points touching y = 0.5
544 checkCubicRegions2(0.0, 41.0 / 27.0, 1.0, -10.0 / 9.0); 544 checkCubicRegions2(0.0, 41.0 / 27.0, 1.0, -10.0 / 9.0);
545 checkCubicRegions2(0.0, 19.0 / 9.0, 1.0, -14.0 / 27.0); 545 checkCubicRegions2(0.0, 19.0 / 9.0, 1.0, -14.0 / 27.0);
546 } 546 }
547 547
548 } // namespace 548 } // namespace
549 549
550 } // namespace blink 550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698