| OLD | NEW |
| 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 "ui/views/animation/ink_drop_hover.h" | 5 #include "ui/views/animation/ink_drop_hover.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 12 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 11 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 12 | 14 |
| 13 namespace views { | 15 namespace views { |
| 14 namespace test { | 16 namespace test { |
| 15 | 17 |
| 16 class InkDropHoverTest : public testing::Test { | 18 class InkDropHoverTest : public testing::Test { |
| 17 public: | 19 public: |
| 18 InkDropHoverTest(); | 20 InkDropHoverTest(); |
| 19 ~InkDropHoverTest() override; | 21 ~InkDropHoverTest() override; |
| 20 | 22 |
| 21 protected: | 23 protected: |
| 22 scoped_ptr<InkDropHover> CreateInkDropHover() const; | 24 std::unique_ptr<InkDropHover> CreateInkDropHover() const; |
| 23 | 25 |
| 24 private: | 26 private: |
| 25 // Enables zero duration animations during the tests. | 27 // Enables zero duration animations during the tests. |
| 26 scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; | 28 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; |
| 27 | 29 |
| 28 DISALLOW_COPY_AND_ASSIGN(InkDropHoverTest); | 30 DISALLOW_COPY_AND_ASSIGN(InkDropHoverTest); |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 InkDropHoverTest::InkDropHoverTest() { | 33 InkDropHoverTest::InkDropHoverTest() { |
| 32 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 34 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
| 33 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 35 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
| 34 } | 36 } |
| 35 | 37 |
| 36 InkDropHoverTest::~InkDropHoverTest() {} | 38 InkDropHoverTest::~InkDropHoverTest() {} |
| 37 | 39 |
| 38 scoped_ptr<InkDropHover> InkDropHoverTest::CreateInkDropHover() const { | 40 std::unique_ptr<InkDropHover> InkDropHoverTest::CreateInkDropHover() const { |
| 39 return make_scoped_ptr( | 41 return base::WrapUnique( |
| 40 new InkDropHover(gfx::Size(10, 10), 3, gfx::Point(), SK_ColorBLACK)); | 42 new InkDropHover(gfx::Size(10, 10), 3, gfx::Point(), SK_ColorBLACK)); |
| 41 } | 43 } |
| 42 | 44 |
| 43 TEST_F(InkDropHoverTest, InitialStateAfterConstruction) { | 45 TEST_F(InkDropHoverTest, InitialStateAfterConstruction) { |
| 44 scoped_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover(); | 46 std::unique_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover(); |
| 45 EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible()); | 47 EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible()); |
| 46 } | 48 } |
| 47 | 49 |
| 48 TEST_F(InkDropHoverTest, IsHoveredStateTransitions) { | 50 TEST_F(InkDropHoverTest, IsHoveredStateTransitions) { |
| 49 scoped_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover(); | 51 std::unique_ptr<InkDropHover> ink_drop_hover = CreateInkDropHover(); |
| 50 | 52 |
| 51 ink_drop_hover->FadeIn(base::TimeDelta::FromMilliseconds(0)); | 53 ink_drop_hover->FadeIn(base::TimeDelta::FromMilliseconds(0)); |
| 52 EXPECT_TRUE(ink_drop_hover->IsFadingInOrVisible()); | 54 EXPECT_TRUE(ink_drop_hover->IsFadingInOrVisible()); |
| 53 | 55 |
| 54 ink_drop_hover->FadeOut(base::TimeDelta::FromMilliseconds(0)); | 56 ink_drop_hover->FadeOut(base::TimeDelta::FromMilliseconds(0)); |
| 55 EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible()); | 57 EXPECT_FALSE(ink_drop_hover->IsFadingInOrVisible()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 } // namespace test | 60 } // namespace test |
| 59 } // namespace views | 61 } // namespace views |
| OLD | NEW |