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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 130443005: [#5] Pass gfx structs by const ref (gfx::Vector2dF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated the review comments Created 6 years, 11 months 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
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 layer()->ScrollBy(gfx::Vector2dF(100, -100)); 445 layer()->ScrollBy(gfx::Vector2dF(100, -100));
446 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 0), layer()->TotalScrollOffset()); 446 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 0), layer()->TotalScrollOffset());
447 447
448 EXPECT_VECTOR_EQ(layer()->ScrollDelta() + scroll_offset, 448 EXPECT_VECTOR_EQ(layer()->ScrollDelta() + scroll_offset,
449 layer()->TotalScrollOffset()); 449 layer()->TotalScrollOffset());
450 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset()); 450 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset());
451 } 451 }
452 452
453 class ScrollDelegateIgnore : public LayerScrollOffsetDelegate { 453 class ScrollDelegateIgnore : public LayerScrollOffsetDelegate {
454 public: 454 public:
455 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} 455 virtual void SetMaxScrollOffset(
456 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE {} 456 const gfx::Vector2dF& max_scroll_offset) OVERRIDE {}
457 virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) OVERRIDE {}
457 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { 458 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE {
458 return fixed_offset_; 459 return fixed_offset_;
459 } 460 }
460 virtual bool IsExternalFlingActive() const OVERRIDE { return false; } 461 virtual bool IsExternalFlingActive() const OVERRIDE { return false; }
461 462
462 void set_fixed_offset(gfx::Vector2dF fixed_offset) { 463 void set_fixed_offset(const gfx::Vector2dF& fixed_offset) {
463 fixed_offset_ = fixed_offset; 464 fixed_offset_ = fixed_offset;
464 } 465 }
465 466
466 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} 467 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {}
467 virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {} 468 virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {}
468 469
469 private: 470 private:
470 gfx::Vector2dF fixed_offset_; 471 gfx::Vector2dF fixed_offset_;
471 }; 472 };
472 473
(...skipping 27 matching lines...) Expand all
500 501
501 gfx::Vector2dF scroll_delta(1, 1); 502 gfx::Vector2dF scroll_delta(1, 1);
502 layer()->ScrollBy(scroll_delta); 503 layer()->ScrollBy(scroll_delta);
503 504
504 EXPECT_VECTOR_EQ(fixed_offset + scroll_delta, layer()->TotalScrollOffset()); 505 EXPECT_VECTOR_EQ(fixed_offset + scroll_delta, layer()->TotalScrollOffset());
505 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset()); 506 EXPECT_VECTOR_EQ(scroll_offset, layer()->scroll_offset());
506 } 507 }
507 508
508 class ScrollDelegateAccept : public LayerScrollOffsetDelegate { 509 class ScrollDelegateAccept : public LayerScrollOffsetDelegate {
509 public: 510 public:
510 virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) OVERRIDE {} 511 virtual void SetMaxScrollOffset(
511 virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) OVERRIDE { 512 const gfx::Vector2dF& max_scroll_offset) OVERRIDE {}
513 virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) OVERRIDE {
512 current_offset_ = new_value; 514 current_offset_ = new_value;
513 } 515 }
514 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { 516 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE {
515 return current_offset_; 517 return current_offset_;
516 } 518 }
517 virtual bool IsExternalFlingActive() const OVERRIDE { return false; } 519 virtual bool IsExternalFlingActive() const OVERRIDE { return false; }
518 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {} 520 virtual void SetTotalPageScaleFactor(float page_scale_factor) OVERRIDE {}
519 virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {} 521 virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {}
520 522
521 private: 523 private:
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 layer()->SetMaxScrollOffset(max_scroll_offset); 641 layer()->SetMaxScrollOffset(max_scroll_offset);
640 layer()->SetScrollOffset(scroll_offset); 642 layer()->SetScrollOffset(scroll_offset);
641 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); 643 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
642 644
643 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); 645 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled);
644 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); 646 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset());
645 } 647 }
646 648
647 } // namespace 649 } // namespace
648 } // namespace cc 650 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698