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 "content/browser/web_contents/aura/overscroll_window_animation.h" | 5 #include "content/browser/web_contents/aura/overscroll_window_animation.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 owa_.reset(new OverscrollWindowAnimation(this)); | 59 owa_.reset(new OverscrollWindowAnimation(this)); |
60 } | 60 } |
61 | 61 |
62 void TearDown() override { | 62 void TearDown() override { |
63 owa_.reset(); | 63 owa_.reset(); |
64 main_window_.reset(); | 64 main_window_.reset(); |
65 aura::test::AuraTestBase::TearDown(); | 65 aura::test::AuraTestBase::TearDown(); |
66 } | 66 } |
67 | 67 |
68 // OverscrollWindowAnimation::Delegate: | 68 // OverscrollWindowAnimation::Delegate: |
69 scoped_ptr<aura::Window> CreateFrontWindow(const gfx::Rect& bounds) override { | 69 std::unique_ptr<aura::Window> CreateFrontWindow( |
| 70 const gfx::Rect& bounds) override { |
70 return CreateSlideWindow(bounds); | 71 return CreateSlideWindow(bounds); |
71 } | 72 } |
72 | 73 |
73 scoped_ptr<aura::Window> CreateBackWindow(const gfx::Rect& bounds) override { | 74 std::unique_ptr<aura::Window> CreateBackWindow( |
| 75 const gfx::Rect& bounds) override { |
74 return CreateSlideWindow(bounds); | 76 return CreateSlideWindow(bounds); |
75 } | 77 } |
76 | 78 |
77 aura::Window* GetMainWindow() const override { return main_window_.get(); } | 79 aura::Window* GetMainWindow() const override { return main_window_.get(); } |
78 | 80 |
79 void OnOverscrollCompleting() override { overscroll_completing_ = true; } | 81 void OnOverscrollCompleting() override { overscroll_completing_ = true; } |
80 | 82 |
81 void OnOverscrollCompleted(scoped_ptr<aura::Window> window) override { | 83 void OnOverscrollCompleted(std::unique_ptr<aura::Window> window) override { |
82 overscroll_completed_ = true; | 84 overscroll_completed_ = true; |
83 } | 85 } |
84 | 86 |
85 void OnOverscrollCancelled() override { overscroll_aborted_ = true; } | 87 void OnOverscrollCancelled() override { overscroll_aborted_ = true; } |
86 | 88 |
87 private: | 89 private: |
88 // The overscroll window animation under test. | 90 // The overscroll window animation under test. |
89 scoped_ptr<OverscrollWindowAnimation> owa_; | 91 std::unique_ptr<OverscrollWindowAnimation> owa_; |
90 | 92 |
91 scoped_ptr<aura::Window> CreateSlideWindow(const gfx::Rect& bounds) { | 93 std::unique_ptr<aura::Window> CreateSlideWindow(const gfx::Rect& bounds) { |
92 overscroll_started_ = true; | 94 overscroll_started_ = true; |
93 if (create_window_) { | 95 if (create_window_) { |
94 scoped_ptr<aura::Window> window( | 96 std::unique_ptr<aura::Window> window( |
95 CreateNormalWindow(++last_window_id_, root_window(), nullptr)); | 97 CreateNormalWindow(++last_window_id_, root_window(), nullptr)); |
96 window->SetBounds(bounds); | 98 window->SetBounds(bounds); |
97 return window; | 99 return window; |
98 } | 100 } |
99 return nullptr; | 101 return nullptr; |
100 } | 102 } |
101 | 103 |
102 // Controls if we return a window for the window creation callbacks or not. | 104 // Controls if we return a window for the window creation callbacks or not. |
103 bool create_window_; | 105 bool create_window_; |
104 | 106 |
105 // State flags. | 107 // State flags. |
106 bool overscroll_started_; | 108 bool overscroll_started_; |
107 bool overscroll_completing_; | 109 bool overscroll_completing_; |
108 bool overscroll_completed_; | 110 bool overscroll_completed_; |
109 bool overscroll_aborted_; | 111 bool overscroll_aborted_; |
110 | 112 |
111 int last_window_id_; | 113 int last_window_id_; |
112 | 114 |
113 // The dummy target window we provide. | 115 // The dummy target window we provide. |
114 scoped_ptr<aura::Window> main_window_; | 116 std::unique_ptr<aura::Window> main_window_; |
115 | 117 |
116 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimationTest); | 118 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowAnimationTest); |
117 }; | 119 }; |
118 | 120 |
119 // Tests a simple overscroll gesture. | 121 // Tests a simple overscroll gesture. |
120 TEST_F(OverscrollWindowAnimationTest, BasicOverscroll) { | 122 TEST_F(OverscrollWindowAnimationTest, BasicOverscroll) { |
121 EXPECT_FALSE(owa()->is_active()); | 123 EXPECT_FALSE(owa()->is_active()); |
122 EXPECT_FALSE(overscroll_started()); | 124 EXPECT_FALSE(overscroll_started()); |
123 EXPECT_FALSE(overscroll_completing()); | 125 EXPECT_FALSE(overscroll_completing()); |
124 EXPECT_FALSE(overscroll_completed()); | 126 EXPECT_FALSE(overscroll_completed()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // The animation has finished, OverscrollCompleted should have been fired. | 219 // The animation has finished, OverscrollCompleted should have been fired. |
218 animator->Step(start_time + duration); | 220 animator->Step(start_time + duration); |
219 EXPECT_FALSE(owa()->is_active()); | 221 EXPECT_FALSE(owa()->is_active()); |
220 EXPECT_FALSE(overscroll_started()); | 222 EXPECT_FALSE(overscroll_started()); |
221 EXPECT_TRUE(overscroll_completing()); | 223 EXPECT_TRUE(overscroll_completing()); |
222 EXPECT_TRUE(overscroll_completed()); | 224 EXPECT_TRUE(overscroll_completed()); |
223 EXPECT_FALSE(overscroll_aborted()); | 225 EXPECT_FALSE(overscroll_aborted()); |
224 } | 226 } |
225 | 227 |
226 } // namespace content | 228 } // namespace content |
OLD | NEW |