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

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

Issue 2499453002: Add ink drop ripple to overview mode button (Closed)
Patch Set: Addressed review comments Created 4 years, 1 month 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 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "ui/views/animation/ink_drop_impl.h" 7 #include "ui/views/animation/ink_drop_impl.h"
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/test/test_simple_task_runner.h" 11 #include "base/test/test_simple_task_runner.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
14 #include "ui/views/animation/test/ink_drop_impl_test_api.h" 15 #include "ui/views/animation/test/ink_drop_impl_test_api.h"
15 #include "ui/views/animation/test/test_ink_drop_host.h" 16 #include "ui/views/animation/test/test_ink_drop_host.h"
16 17
17 namespace views { 18 namespace views {
18 19
19 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests. 20 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests.
20 class InkDropImplTest : public testing::Test { 21 class InkDropImplTest : public testing::Test {
21 public: 22 public:
22 InkDropImplTest(); 23 InkDropImplTest();
23 ~InkDropImplTest() override; 24 ~InkDropImplTest() override;
24 25
25 protected: 26 protected:
26 TestInkDropHost* ink_drop_host() { return ink_drop_host_.get(); } 27 TestInkDropHost* ink_drop_host() { return ink_drop_host_.get(); }
27 28
28 InkDropImpl* ink_drop() { return ink_drop_.get(); } 29 InkDropImpl* ink_drop() { return ink_drop_.get(); }
29 30
30 test::InkDropImplTestApi* test_api() { return test_api_.get(); } 31 test::InkDropImplTestApi* test_api() { return test_api_.get(); }
31 32
32 // Runs all the pending tasks in |task_runner_|. This can be used to progress 33 // Runs all the pending tasks in |task_runner_|. This can be used to progress
33 // timers. e.g. HideHighlightOnRippleHiddenState's 34 // timers. e.g. HideHighlightOnRippleHiddenState's
34 // |highlight_after_ripple_timer_|. 35 // |highlight_after_ripple_timer_|.
35 void RunPendingTasks(); 36 void RunPendingTasks();
36 37
37 // Returns true if the ink drop layers have been added to |ink_drop_host_|. 38 // Returns true if the ink drop layers have been added to |ink_drop_host_|.
38 bool AreLayersAddedToHost() const; 39 bool AreLayersAddedToHost() const;
39 40
40 // Destroyes the |ink_drop_| and assocated |test_api_|. 41 // Destroys the |ink_drop_| and associated |test_api_|.
41 void DestroyInkDrop(); 42 void DestroyInkDrop();
42 43
43 // Used to control the tasks scheduled by the InkDropImpl's Timer. 44 // Used to control the tasks scheduled by the InkDropImpl's Timer.
44 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 45 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
45 46
46 // Required by base::Timer's. 47 // Required by base::Timer's.
47 std::unique_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_; 48 std::unique_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_;
48 49
49 private: 50 private:
50 std::unique_ptr<TestInkDropHost> ink_drop_host_; 51 std::unique_ptr<TestInkDropHost> ink_drop_host_;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 244
244 // Verifies there is no use after free errors. 245 // Verifies there is no use after free errors.
245 TEST_F(InkDropImplTest, 246 TEST_F(InkDropImplTest,
246 TearingDownHighlightStateThatAccessesTheStateFactoryIsSafe) { 247 TearingDownHighlightStateThatAccessesTheStateFactoryIsSafe) {
247 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( 248 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install(
248 test_api()->state_factory()); 249 test_api()->state_factory());
249 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( 250 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install(
250 test_api()->state_factory()); 251 test_api()->state_factory());
251 } 252 }
252 253
254 // Tests that if during destruction, a rippl animation is successfully ended, no
255 // crash happens (see https://crbug.com/663579).
256 TEST_F(InkDropImplTest, SuccessfulAnimationEndedDuringDestruction) {
257 // Start a ripple animation with non-zero duration.
258 ink_drop()->AnimateToState(InkDropState::ACTION_PENDING);
259 {
260 // Start another ripple animation with zero duration that would be queued
261 // until the previous one is finished/aborted.
262 ui::ScopedAnimationDurationScaleMode duration_mode(
263 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
264 ink_drop()->AnimateToState(InkDropState::ACTION_TRIGGERED);
265 }
266 // Abort the first animation, so that the queued animation is started (and
267 // finished immediately since it has zero duration). No crash should happen.
268 DestroyInkDrop();
269 }
270
253 //////////////////////////////////////////////////////////////////////////////// 271 ////////////////////////////////////////////////////////////////////////////////
254 // 272 //
255 // Common AutoHighlightMode tests 273 // Common AutoHighlightMode tests
256 // 274 //
257 275
258 typedef InkDropImplAutoHighlightTest InkDropImplCommonAutoHighlightTest; 276 typedef InkDropImplAutoHighlightTest InkDropImplCommonAutoHighlightTest;
259 // Note: First argument is optional and intentionally left blank. 277 // Note: First argument is optional and intentionally left blank.
260 // (it's a prefix for the generated test cases) 278 // (it's a prefix for the generated test cases)
261 INSTANTIATE_TEST_CASE_P( 279 INSTANTIATE_TEST_CASE_P(
262 , 280 ,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); 554 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible());
537 555
538 ink_drop()->SetHovered(false); 556 ink_drop()->SetHovered(false);
539 ink_drop()->SetFocused(false); 557 ink_drop()->SetFocused(false);
540 558
541 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); 559 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible());
542 EXPECT_FALSE(test_api()->ShouldHighlight()); 560 EXPECT_FALSE(test_api()->ShouldHighlight());
543 } 561 }
544 562
545 } // namespace views 563 } // namespace views
OLDNEW
« ash/common/wm/overview/window_selector_controller.h ('K') | « ui/views/animation/ink_drop_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698