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

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 132163009: [#6]Pass gfx structs by const ref (gfx::Vector2d) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 PostSetNeedsCommitToMainThread(); 65 PostSetNeedsCommitToMainThread();
66 break; 66 break;
67 case 1: 67 case 1:
68 EXPECT_VECTOR_EQ(root->scroll_offset(), second_scroll_); 68 EXPECT_VECTOR_EQ(root->scroll_offset(), second_scroll_);
69 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_); 69 EXPECT_VECTOR_EQ(root->ScrollDelta(), scroll_amount_);
70 EndTest(); 70 EndTest();
71 break; 71 break;
72 } 72 }
73 } 73 }
74 74
75 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 75 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
76 float scale) OVERRIDE { 76 float scale) OVERRIDE {
77 num_scrolls_++; 77 num_scrolls_++;
78 } 78 }
79 79
80 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } 80 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); }
81 81
82 private: 82 private:
83 gfx::Vector2d initial_scroll_; 83 gfx::Vector2d initial_scroll_;
84 gfx::Vector2d second_scroll_; 84 gfx::Vector2d second_scroll_;
85 gfx::Vector2d scroll_amount_; 85 gfx::Vector2d scroll_amount_;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 impl->SourceAnimationFrameNumber() == 4) { 302 impl->SourceAnimationFrameNumber() == 4) {
303 // Final draw after the second aborted commit. 303 // Final draw after the second aborted commit.
304 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); 304 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d());
305 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 305 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
306 initial_scroll_ + impl_scroll_ + impl_scroll_ + 306 initial_scroll_ + impl_scroll_ + impl_scroll_ +
307 impl_scroll_ + second_main_scroll_); 307 impl_scroll_ + second_main_scroll_);
308 EndTest(); 308 EndTest();
309 } 309 }
310 } 310 }
311 311
312 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 312 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
313 float scale) OVERRIDE { 313 float scale) OVERRIDE {
314 num_impl_scrolls_++; 314 num_impl_scrolls_++;
315 } 315 }
316 316
317 virtual void AfterTest() OVERRIDE { 317 virtual void AfterTest() OVERRIDE {
318 EXPECT_EQ(3, num_impl_scrolls_); 318 EXPECT_EQ(3, num_impl_scrolls_);
319 // Verify that the embedder sees aborted commits as real commits. 319 // Verify that the embedder sees aborted commits as real commits.
320 EXPECT_EQ(4, num_will_begin_main_frames_); 320 EXPECT_EQ(4, num_will_begin_main_frames_);
321 EXPECT_EQ(4, num_did_begin_main_frames_); 321 EXPECT_EQ(4, num_did_begin_main_frames_);
322 EXPECT_EQ(4, num_will_commits_); 322 EXPECT_EQ(4, num_will_commits_);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // will stall the test). 458 // will stall the test).
459 if (layer_tree_host()->source_frame_number() < 2) { 459 if (layer_tree_host()->source_frame_number() < 2) {
460 layer_tree_host()->SetNeedsCommit(); 460 layer_tree_host()->SetNeedsCommit();
461 } 461 }
462 } 462 }
463 463
464 void DidScroll() { 464 void DidScroll() {
465 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); 465 final_scroll_offset_ = expected_scroll_layer_->scroll_offset();
466 } 466 }
467 467
468 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 468 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
469 float scale) OVERRIDE { 469 float scale) OVERRIDE {
470 num_scrolls_++; 470 num_scrolls_++;
471 } 471 }
472 472
473 virtual void Layout() OVERRIDE { 473 virtual void Layout() OVERRIDE {
474 EXPECT_VECTOR_EQ(gfx::Vector2d(), 474 EXPECT_VECTOR_EQ(gfx::Vector2d(),
475 expected_no_scroll_layer_->scroll_offset()); 475 expected_no_scroll_layer_->scroll_offset());
476 476
477 switch (layer_tree_host()->source_frame_number()) { 477 switch (layer_tree_host()->source_frame_number()) {
478 case 0: 478 case 0:
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 EXPECT_VECTOR_EQ( 798 EXPECT_VECTOR_EQ(
799 root->scroll_offset(), 799 root->scroll_offset(),
800 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); 800 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_);
801 EXPECT_VECTOR_EQ(root->ScrollDelta(), impl_thread_scroll2_); 801 EXPECT_VECTOR_EQ(root->ScrollDelta(), impl_thread_scroll2_);
802 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), gfx::Vector2d()); 802 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), gfx::Vector2d());
803 EndTest(); 803 EndTest();
804 break; 804 break;
805 } 805 }
806 } 806 }
807 807
808 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 808 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
809 float scale) OVERRIDE { 809 float scale) OVERRIDE {
810 num_scrolls_++; 810 num_scrolls_++;
811 } 811 }
812 812
813 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } 813 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); }
814 814
815 private: 815 private:
816 gfx::Vector2d initial_scroll_; 816 gfx::Vector2d initial_scroll_;
817 gfx::Vector2d main_thread_scroll_; 817 gfx::Vector2d main_thread_scroll_;
818 gfx::Vector2d impl_thread_scroll1_; 818 gfx::Vector2d impl_thread_scroll1_;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 RunTest(true, false, false); 1116 RunTest(true, false, false);
1117 } 1117 }
1118 1118
1119 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1119 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1120 scroll_destroy_whole_tree_ = true; 1120 scroll_destroy_whole_tree_ = true;
1121 RunTest(true, false, false); 1121 RunTest(true, false, false);
1122 } 1122 }
1123 1123
1124 } // namespace 1124 } // namespace
1125 } // namespace cc 1125 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698