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

Side by Side Diff: ui/views/animation/ink_drop_animation_controller_factory_unittest.cc

Issue 1298513003: Implemented prototype for new ink drop specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed outstanding concerns and improved documentation. Created 5 years, 3 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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
7
8 #include "base/command_line.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/base/test/material_design_controller_test_api.h"
13 #include "ui/base/ui_base_switches.h"
14 #include "ui/views/animation/ink_drop_animation_controller.h"
15 #include "ui/views/animation/ink_drop_animation_controller_factory.h"
16 #include "ui/views/animation/ink_drop_host.h"
17 #include "ui/views/animation/ink_drop_state.h"
18 #include "ui/views/animation/test/test_ink_drop_host.h"
19
20 namespace views {
21
22 // Macro that will execute |test_code| against all derivatives of the
23 // InkDropAnimationController returned by the InkDropAnimationControllerFactory.
24 #define TEST_ALL_INK_DROPS(test_name, test_code) \
25 TEST_F(InkDropAnimationControllerFactoryTest, test_name) \
26 test_code TEST_F(MDInkDropAnimationControllerFactoryTest, test_name) test_code
27
28 // Test fixture to test the non material design InkDropAnimationController.
29 class InkDropAnimationControllerFactoryTest : public testing::Test {
30 public:
31 InkDropAnimationControllerFactoryTest() {}
32 ~InkDropAnimationControllerFactoryTest() override {}
33
34 // testing::Test:
35 void SetUp() override;
36 void TearDown() override;
37
38 protected:
39 // A dummy InkDropHost required to create an InkDropAnimationController.
40 TestInkDropHost test_ink_drop_host_;
41
42 // The InkDropAnimationController returned by the
43 // InkDropAnimationControllerFactory test target.
44 scoped_ptr<InkDropAnimationController> ink_drop_animation_controller_;
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerFactoryTest);
48 };
49
50 void InkDropAnimationControllerFactoryTest::SetUp() {
51 // Any call by a previous test to MaterialDesignController::GetMode() will
52 // initialize and cache the mode. This ensures that these tests will run from
53 // a non-initialized state.
54 ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
55
56 ink_drop_animation_controller_ =
57 InkDropAnimationControllerFactory::CreateInkDropAnimationController(
58 &test_ink_drop_host_);
59 }
60
61 void InkDropAnimationControllerFactoryTest::TearDown() {
62 ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
63 }
64
65 // Test fixture to test the material design InkDropAnimationController.
66 class MDInkDropAnimationControllerFactoryTest
67 : public InkDropAnimationControllerFactoryTest {
68 public:
69 MDInkDropAnimationControllerFactoryTest() {}
70
71 // InkDropAnimationControllerFactoryTest:
72 void SetUp() override;
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest);
76 };
77
78 void MDInkDropAnimationControllerFactoryTest::SetUp() {
79 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
80 switches::kTopChromeMD, switches::kTopChromeMDMaterial);
81 InkDropAnimationControllerFactoryTest::SetUp();
82 }
83
84 TEST_ALL_INK_DROPS(StateIsHiddenInitially,
85 {
86 EXPECT_EQ(
87 InkDropState::HIDDEN,
88 ink_drop_animation_controller_->GetInkDropState());
89 })
90
91 TEST_ALL_INK_DROPS(TypicalQuickAction,
92 {
93 ink_drop_animation_controller_->AnimateToState(
94 InkDropState::ACTION_PENDING);
95 ink_drop_animation_controller_->AnimateToState(
96 InkDropState::QUICK_ACTION);
97 EXPECT_EQ(
98 InkDropState::HIDDEN,
99 ink_drop_animation_controller_->GetInkDropState());
100 })
101
102 TEST_ALL_INK_DROPS(CancelQuickAction,
103 {
104 ink_drop_animation_controller_->AnimateToState(
105 InkDropState::ACTION_PENDING);
106 ink_drop_animation_controller_->AnimateToState(
107 InkDropState::HIDDEN);
108 EXPECT_EQ(
109 InkDropState::HIDDEN,
110 ink_drop_animation_controller_->GetInkDropState());
111 })
112
113 TEST_ALL_INK_DROPS(TypicalSlowAction,
114 {
115 ink_drop_animation_controller_->AnimateToState(
116 InkDropState::ACTION_PENDING);
117 ink_drop_animation_controller_->AnimateToState(
118 InkDropState::SLOW_ACTION_PENDING);
119 ink_drop_animation_controller_->AnimateToState(
120 InkDropState::SLOW_ACTION);
121 EXPECT_EQ(
122 InkDropState::HIDDEN,
123 ink_drop_animation_controller_->GetInkDropState());
124 })
125
126 TEST_ALL_INK_DROPS(CancelSlowAction,
127 {
128 ink_drop_animation_controller_->AnimateToState(
129 InkDropState::ACTION_PENDING);
130 ink_drop_animation_controller_->AnimateToState(
131 InkDropState::SLOW_ACTION_PENDING);
132 ink_drop_animation_controller_->AnimateToState(
133 InkDropState::HIDDEN);
134 EXPECT_EQ(
135 InkDropState::HIDDEN,
136 ink_drop_animation_controller_->GetInkDropState());
137 })
138
139 TEST_ALL_INK_DROPS(
140 TypicalQuickActivated,
141 {
142 ink_drop_animation_controller_->AnimateToState(
143 InkDropState::ACTION_PENDING);
144 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
145 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
146 EXPECT_EQ(InkDropState::HIDDEN,
147 ink_drop_animation_controller_->GetInkDropState());
148 })
149
150 TEST_ALL_INK_DROPS(
151 TypicalSlowActivated,
152 {
153 ink_drop_animation_controller_->AnimateToState(
154 InkDropState::ACTION_PENDING);
155 ink_drop_animation_controller_->AnimateToState(
156 InkDropState::SLOW_ACTION_PENDING);
157 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
158 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
159 EXPECT_EQ(InkDropState::HIDDEN,
160 ink_drop_animation_controller_->GetInkDropState());
161 })
162
163 } // namespace views
164
165 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698