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

Side by Side 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, 10 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
(Empty)
1 // Copyright 2015 The Chromium 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 "base/macros.h"
6 #include "base/test/test_simple_task_runner.h"
7 #include "base/thread_task_runner_handle.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
10 #include "ui/views/animation/ink_drop_animation_controller_impl.h"
11 #include "ui/views/animation/test/test_ink_drop_host.h"
12
13 namespace views {
14
15 // NOTE: The InkDropAnimationControllerImpl class is also tested by the
16 // InkDropAnimationControllerFactoryTest tests.
17 class InkDropAnimationControllerImplTest : public testing::Test {
18 public:
19 InkDropAnimationControllerImplTest();
20 ~InkDropAnimationControllerImplTest() override;
21
22 protected:
23 TestInkDropHost ink_drop_host_;
24
25 // The test target.
26 InkDropAnimationControllerImpl ink_drop_animation_controller_;
27
28 // Used to control the tasks scheduled by the InkDropAnimationControllerImpl's
29 // Timer.
30 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
31
32 // Required by base::Timer's.
33 scoped_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_;
34
35 private:
36 // Ensures all animations complete immediately.
37 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
38
39 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImplTest);
40 };
41
42 InkDropAnimationControllerImplTest::InkDropAnimationControllerImplTest()
43 : ink_drop_animation_controller_(&ink_drop_host_),
44 task_runner_(new base::TestSimpleTaskRunner),
45 thread_task_runner_handle_(
46 new base::ThreadTaskRunnerHandle(task_runner_)) {
47 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
48 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
49 }
50
51 InkDropAnimationControllerImplTest::~InkDropAnimationControllerImplTest() {}
52
53 TEST_F(InkDropAnimationControllerImplTest, SetHoveredIsHovered) {
54 ink_drop_host_.set_should_show_hover(true);
55
56 ink_drop_animation_controller_.SetHovered(true);
57 EXPECT_TRUE(ink_drop_animation_controller_.IsHovered());
58
59 ink_drop_animation_controller_.SetHovered(false);
60 EXPECT_FALSE(ink_drop_animation_controller_.IsHovered());
61 }
62
63 TEST_F(InkDropAnimationControllerImplTest,
64 HoveredStateAfterHoverTimerFiresWhenHostIsHovered) {
65 ink_drop_host_.set_should_show_hover(true);
66 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION);
67
68 EXPECT_TRUE(task_runner_->HasPendingTask());
69
70 task_runner_->RunPendingTasks();
71
72 EXPECT_TRUE(ink_drop_animation_controller_.IsHovered());
73 }
74
75 TEST_F(InkDropAnimationControllerImplTest,
76 HoveredStateAfterHoverTimerFiresWhenHostIsNotHovered) {
77 ink_drop_host_.set_should_show_hover(false);
78 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION);
79
80 EXPECT_TRUE(task_runner_->HasPendingTask());
81
82 task_runner_->RunPendingTasks();
83
84 EXPECT_FALSE(ink_drop_animation_controller_.IsHovered());
85 }
86
87 } // namespace views
OLDNEW
« 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