| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/output/filter_operation.h" | 7 #include "cc/output/filter_operation.h" |
| 8 #include "cc/output/filter_operations.h" | 8 #include "cc/output/filter_operations.h" |
| 9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset()); | 369 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset()); |
| 370 } | 370 } |
| 371 | 371 |
| 372 class ScrollDelegateIgnore : public LayerScrollOffsetDelegate { | 372 class ScrollDelegateIgnore : public LayerScrollOffsetDelegate { |
| 373 public: | 373 public: |
| 374 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} | 374 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} |
| 375 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE {} | 375 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE {} |
| 376 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { | 376 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { |
| 377 return fixed_offset_; | 377 return fixed_offset_; |
| 378 } | 378 } |
| 379 virtual bool IsExternalFlingActive() const OVERRIDE { return false; } | |
| 380 | 379 |
| 381 void set_fixed_offset(gfx::Vector2dF fixed_offset) { | 380 void set_fixed_offset(gfx::Vector2dF fixed_offset) { |
| 382 fixed_offset_ = fixed_offset; | 381 fixed_offset_ = fixed_offset; |
| 383 } | 382 } |
| 384 | 383 |
| 385 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} | 384 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} |
| 386 virtual void SetScrollableSize(gfx::SizeF scrollable_size) OVERRIDE {} | 385 virtual void SetScrollableSize(gfx::SizeF scrollable_size) OVERRIDE {} |
| 387 | 386 |
| 388 private: | 387 private: |
| 389 gfx::Vector2dF fixed_offset_; | 388 gfx::Vector2dF fixed_offset_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 425 |
| 427 class ScrollDelegateAccept : public LayerScrollOffsetDelegate { | 426 class ScrollDelegateAccept : public LayerScrollOffsetDelegate { |
| 428 public: | 427 public: |
| 429 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} | 428 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} |
| 430 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE { | 429 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE { |
| 431 current_offset_ = new_value; | 430 current_offset_ = new_value; |
| 432 } | 431 } |
| 433 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { | 432 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { |
| 434 return current_offset_; | 433 return current_offset_; |
| 435 } | 434 } |
| 436 virtual bool IsExternalFlingActive() const OVERRIDE { return false; } | |
| 437 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} | 435 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} |
| 438 virtual void SetScrollableSize(gfx::SizeF scrollable_size) OVERRIDE {} | 436 virtual void SetScrollableSize(gfx::SizeF scrollable_size) OVERRIDE {} |
| 439 | 437 |
| 440 private: | 438 private: |
| 441 gfx::Vector2dF current_offset_; | 439 gfx::Vector2dF current_offset_; |
| 442 }; | 440 }; |
| 443 | 441 |
| 444 TEST_F(LayerImplScrollTest, ScrollByWithAcceptingDelegate) { | 442 TEST_F(LayerImplScrollTest, ScrollByWithAcceptingDelegate) { |
| 445 gfx::Vector2d max_scroll_offset(50, 80); | 443 gfx::Vector2d max_scroll_offset(50, 80); |
| 446 gfx::Vector2d scroll_offset(10, 5); | 444 gfx::Vector2d scroll_offset(10, 5); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 layer()->SetMaxScrollOffset(max_scroll_offset); | 554 layer()->SetMaxScrollOffset(max_scroll_offset); |
| 557 layer()->SetScrollOffset(scroll_offset); | 555 layer()->SetScrollOffset(scroll_offset); |
| 558 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); | 556 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); |
| 559 | 557 |
| 560 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); | 558 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); |
| 561 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); | 559 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); |
| 562 } | 560 } |
| 563 | 561 |
| 564 } // namespace | 562 } // namespace |
| 565 } // namespace cc | 563 } // namespace cc |
| OLD | NEW |