OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 #include "content/browser/android/overscroll_refresh.h" | 6 #include "content/browser/android/overscroll_refresh.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/base/android/system_ui_resource_manager.h" | 8 #include "ui/android/resources/resource_manager.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 const float kDragTargetPixels = 100; | 12 const float kDragTargetPixels = 100; |
13 | 13 |
14 gfx::SizeF DefaultViewportSize() { | 14 gfx::SizeF DefaultViewportSize() { |
15 return gfx::SizeF(512, 512); | 15 return gfx::SizeF(512, 512); |
16 } | 16 } |
17 | 17 |
18 class OverscrollRefreshTest : public OverscrollRefreshClient, | 18 class OverscrollRefreshTest : public OverscrollRefreshClient, |
19 public ui::SystemUIResourceManager, | 19 public ui::ResourceManager, |
20 public testing::Test { | 20 public testing::Test { |
21 public: | 21 public: |
22 OverscrollRefreshTest() : refresh_triggered_(false) {} | 22 OverscrollRefreshTest() |
| 23 : ui::ResourceManager(nullptr), refresh_triggered_(false) {} |
23 | 24 |
24 // OverscrollRefreshClient implementation. | 25 // OverscrollRefreshClient implementation. |
25 void TriggerRefresh() override { | 26 void TriggerRefresh() override { |
26 refresh_triggered_ = true; | 27 refresh_triggered_ = true; |
27 still_refreshing_ = true; | 28 still_refreshing_ = true; |
28 } | 29 } |
29 | 30 |
30 bool IsStillRefreshing() const override { return still_refreshing_; } | 31 bool IsStillRefreshing() const override { return still_refreshing_; } |
31 | 32 |
32 // SystemUIResoruceManager implementation. | 33 // ResoruceManager implementation. |
33 void PreloadResource(ui::SystemUIResourceType) override {} | 34 void PreloadResource(ui::AndroidResourceType res_type, int res_id) override {} |
34 | 35 |
35 bool GetAndResetRefreshTriggered() { | 36 bool GetAndResetRefreshTriggered() { |
36 bool triggered = refresh_triggered_; | 37 bool triggered = refresh_triggered_; |
37 refresh_triggered_ = false; | 38 refresh_triggered_ = false; |
38 return triggered; | 39 return triggered; |
39 } | 40 } |
40 | 41 |
41 protected: | 42 protected: |
42 void SignalRefreshCompleted() { still_refreshing_ = false; } | 43 void SignalRefreshCompleted() { still_refreshing_ = false; } |
43 | 44 |
44 cc::UIResourceId GetUIResourceId(ui::SystemUIResourceType) override { | 45 cc::UIResourceId GetUIResourceId(ui::AndroidResourceType res_type, |
| 46 int res_id) override { |
45 return 0; | 47 return 0; |
46 } | 48 } |
47 | 49 |
48 private: | 50 private: |
49 bool refresh_triggered_; | 51 bool refresh_triggered_; |
50 bool still_refreshing_; | 52 bool still_refreshing_; |
51 }; | 53 }; |
52 | 54 |
53 TEST_F(OverscrollRefreshTest, Basic) { | 55 TEST_F(OverscrollRefreshTest, Basic) { |
54 OverscrollRefresh effect(this, this, kDragTargetPixels); | 56 OverscrollRefresh effect(this, this, kDragTargetPixels); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); | 291 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); |
290 while (effect.Animate(current_time, layer.get())) | 292 while (effect.Animate(current_time, layer.get())) |
291 current_time += base::TimeDelta::FromMilliseconds(16); | 293 current_time += base::TimeDelta::FromMilliseconds(16); |
292 | 294 |
293 EXPECT_GT(current_time.ToInternalValue(), initial_time.ToInternalValue()); | 295 EXPECT_GT(current_time.ToInternalValue(), initial_time.ToInternalValue()); |
294 EXPECT_FALSE(effect.IsActive()); | 296 EXPECT_FALSE(effect.IsActive()); |
295 EXPECT_FALSE(GetAndResetRefreshTriggered()); | 297 EXPECT_FALSE(GetAndResetRefreshTriggered()); |
296 } | 298 } |
297 | 299 |
298 } // namespace content | 300 } // namespace content |
OLD | NEW |