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

Unified Diff: ui/views/animation/ink_drop_animation_controller_impl_unittest.cc

Issue 1390113006: Added material design mouse hover feedback support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the InkDropAnimationControllerImpl to destroy its timer when not running. Created 4 years, 11 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/ink_drop_animation_controller_impl.cc ('k') | ui/views/animation/ink_drop_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
diff --git a/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc b/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..78fd2b61fea9b7b9812dd40904d58d17fbc3b96f
--- /dev/null
+++ b/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
@@ -0,0 +1,87 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/macros.h"
+#include "base/test/test_simple_task_runner.h"
+#include "base/thread_task_runner_handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/compositor/scoped_animation_duration_scale_mode.h"
+#include "ui/views/animation/ink_drop_animation_controller_impl.h"
+#include "ui/views/animation/test/test_ink_drop_host.h"
+
+namespace views {
+
+// NOTE: The InkDropAnimationControllerImpl class is also tested by the
+// InkDropAnimationControllerFactoryTest tests.
+class InkDropAnimationControllerImplTest : public testing::Test {
+ public:
+ InkDropAnimationControllerImplTest();
+ ~InkDropAnimationControllerImplTest() override;
+
+ protected:
+ TestInkDropHost ink_drop_host_;
+
+ // The test target.
+ InkDropAnimationControllerImpl ink_drop_animation_controller_;
+
+ // Used to control the tasks scheduled by the InkDropAnimationControllerImpl's
+ // Timer.
+ scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
+
+ // Required by base::Timer's.
+ scoped_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_;
+
+ private:
+ // Ensures all animations complete immediately.
+ scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
+
+ DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImplTest);
+};
+
+InkDropAnimationControllerImplTest::InkDropAnimationControllerImplTest()
+ : ink_drop_animation_controller_(&ink_drop_host_),
+ task_runner_(new base::TestSimpleTaskRunner),
+ thread_task_runner_handle_(
+ new base::ThreadTaskRunnerHandle(task_runner_)) {
+ zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
+ ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
+}
+
+InkDropAnimationControllerImplTest::~InkDropAnimationControllerImplTest() {}
+
+TEST_F(InkDropAnimationControllerImplTest, SetHoveredIsHovered) {
+ ink_drop_host_.set_should_show_hover(true);
+
+ ink_drop_animation_controller_.SetHovered(true);
+ EXPECT_TRUE(ink_drop_animation_controller_.IsHovered());
+
+ ink_drop_animation_controller_.SetHovered(false);
+ EXPECT_FALSE(ink_drop_animation_controller_.IsHovered());
+}
+
+TEST_F(InkDropAnimationControllerImplTest,
+ HoveredStateAfterHoverTimerFiresWhenHostIsHovered) {
+ ink_drop_host_.set_should_show_hover(true);
+ ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION);
+
+ EXPECT_TRUE(task_runner_->HasPendingTask());
+
+ task_runner_->RunPendingTasks();
+
+ EXPECT_TRUE(ink_drop_animation_controller_.IsHovered());
+}
+
+TEST_F(InkDropAnimationControllerImplTest,
+ HoveredStateAfterHoverTimerFiresWhenHostIsNotHovered) {
+ ink_drop_host_.set_should_show_hover(false);
+ ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION);
+
+ EXPECT_TRUE(task_runner_->HasPendingTask());
+
+ task_runner_->RunPendingTasks();
+
+ EXPECT_FALSE(ink_drop_animation_controller_.IsHovered());
+}
+
+} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_impl.cc ('k') | ui/views/animation/ink_drop_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698