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

Unified Diff: ui/views/animation/test/test_ink_drop_host.cc

Issue 1913243002: Enabled tests to control material design ink drop animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/test/test_ink_drop_host.cc
diff --git a/ui/views/animation/test/test_ink_drop_host.cc b/ui/views/animation/test/test_ink_drop_host.cc
index c919b685b3c9046a565ac4b883757f8e6c2001c6..f264e25c6656c8081edbc4f1b58245e006b9bfda 100644
--- a/ui/views/animation/test/test_ink_drop_host.cc
+++ b/ui/views/animation/test/test_ink_drop_host.cc
@@ -8,11 +8,74 @@
#include "ui/gfx/geometry/size.h"
#include "ui/views/animation/ink_drop_hover.h"
#include "ui/views/animation/square_ink_drop_animation.h"
+#include "ui/views/animation/test/ink_drop_hover_test_api.h"
+#include "ui/views/animation/test/square_ink_drop_animation_test_api.h"
namespace views {
+namespace {
+
+// Test specific subclass of InkDropAnimation that returns a test api from
+// GetTestApi().
+class TestInkDropAnimation : public SquareInkDropAnimation {
+ public:
+ TestInkDropAnimation(const gfx::Size& large_size,
+ int large_corner_radius,
+ const gfx::Size& small_size,
+ int small_corner_radius,
+ const gfx::Point& center_point,
+ SkColor color)
+ : SquareInkDropAnimation(large_size,
+ large_corner_radius,
+ small_size,
+ small_corner_radius,
+ center_point,
+ color) {}
+
+ ~TestInkDropAnimation() override {}
+
+ test::InkDropAnimationTestApi* GetTestApi() override {
+ if (!test_api_)
+ test_api_.reset(new test::SquareInkDropAnimationTestApi(this));
+ return test_api_.get();
+ }
+
+ private:
+ std::unique_ptr<test::InkDropAnimationTestApi> test_api_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestInkDropAnimation);
+};
+
+// Test specific subclass of InkDropHover that returns a test api from
+// GetTestApi().
+class TestInkDropHover : public InkDropHover {
+ public:
+ TestInkDropHover(const gfx::Size& size,
+ int corner_radius,
+ const gfx::Point& center_point,
+ SkColor color)
+ : InkDropHover(size, corner_radius, center_point, color) {}
+
+ ~TestInkDropHover() override {}
+
+ test::InkDropHoverTestApi* GetTestApi() override {
+ if (!test_api_)
+ test_api_.reset(new test::InkDropHoverTestApi(this));
+ return test_api_.get();
+ }
+
+ private:
+ std::unique_ptr<test::InkDropHoverTestApi> test_api_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestInkDropHover);
+};
+
+} // namespace
+
TestInkDropHost::TestInkDropHost()
- : num_ink_drop_layers_(0), should_show_hover_(false) {}
+ : num_ink_drop_layers_(0),
+ should_show_hover_(false),
+ disable_timers_for_test_(false) {}
TestInkDropHost::~TestInkDropHost() {}
@@ -27,15 +90,22 @@ void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
std::unique_ptr<InkDropAnimation> TestInkDropHost::CreateInkDropAnimation()
const {
gfx::Size size(10, 10);
- return base::WrapUnique(new SquareInkDropAnimation(
- size, 5, size, 5, gfx::Point(), SK_ColorBLACK));
+ std::unique_ptr<InkDropAnimation> animation(
+ new TestInkDropAnimation(size, 5, size, 5, gfx::Point(), SK_ColorBLACK));
+ if (disable_timers_for_test_)
+ animation->GetTestApi()->SetDisableAnimationTimers(true);
+ return animation;
}
std::unique_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const {
- return should_show_hover_
- ? base::WrapUnique(new InkDropHover(gfx::Size(10, 10), 4,
- gfx::Point(), SK_ColorBLACK))
- : nullptr;
+ std::unique_ptr<InkDropHover> hover;
+ if (should_show_hover_) {
+ hover.reset(new TestInkDropHover(gfx::Size(10, 10), 4, gfx::Point(),
+ SK_ColorBLACK));
+ if (disable_timers_for_test_)
+ hover->GetTestApi()->SetDisableAnimationTimers(true);
+ }
+ return hover;
}
} // namespace views
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698