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

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

Issue 511253003: Made Blink aware of top controls offset (Chromium-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed crash + mojo example build break Created 6 years, 3 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/trees/layer_tree_host_unittest_no_message_loop.cc ('k') | cc/trees/layer_tree_impl.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 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/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 PostSetNeedsCommitToMainThread(); 79 PostSetNeedsCommitToMainThread();
80 break; 80 break;
81 case 1: 81 case 1:
82 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); 82 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_);
83 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); 83 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_);
84 EndTest(); 84 EndTest();
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 89 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
90 float scale) OVERRIDE { 90 float scale,
91 float top_controls_delta) OVERRIDE {
91 num_scrolls_++; 92 num_scrolls_++;
92 } 93 }
93 94
94 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } 95 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); }
95 96
96 private: 97 private:
97 gfx::Vector2d initial_scroll_; 98 gfx::Vector2d initial_scroll_;
98 gfx::Vector2d second_scroll_; 99 gfx::Vector2d second_scroll_;
99 gfx::Vector2d scroll_amount_; 100 gfx::Vector2d scroll_amount_;
100 int num_scrolls_; 101 int num_scrolls_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } else if (impl->active_tree()->source_frame_number() == 1) { 164 } else if (impl->active_tree()->source_frame_number() == 1) {
164 // Third or later draw after second commit. 165 // Third or later draw after second commit.
165 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); 166 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3);
166 EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d()); 167 EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d());
167 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), 168 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(),
168 initial_scroll_ + scroll_amount_ + scroll_amount_); 169 initial_scroll_ + scroll_amount_ + scroll_amount_);
169 EndTest(); 170 EndTest();
170 } 171 }
171 } 172 }
172 173
173 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 174 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
174 float scale) OVERRIDE { 175 float scale,
176 float top_controls_delta) OVERRIDE {
175 num_scrolls_++; 177 num_scrolls_++;
176 } 178 }
177 179
178 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } 180 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); }
179 181
180 private: 182 private:
181 gfx::Vector2d initial_scroll_; 183 gfx::Vector2d initial_scroll_;
182 gfx::Vector2d scroll_amount_; 184 gfx::Vector2d scroll_amount_;
183 int num_scrolls_; 185 int num_scrolls_;
184 scoped_refptr<Layer> scroll_layer_; 186 scoped_refptr<Layer> scroll_layer_;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), 337 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(),
336 initial_scroll_ + impl_scroll_ + impl_scroll_ + 338 initial_scroll_ + impl_scroll_ + impl_scroll_ +
337 impl_scroll_ + second_main_scroll_); 339 impl_scroll_ + second_main_scroll_);
338 EndTest(); 340 EndTest();
339 } else { 341 } else {
340 // Commit for source frame 3 is aborted. 342 // Commit for source frame 3 is aborted.
341 NOTREACHED(); 343 NOTREACHED();
342 } 344 }
343 } 345 }
344 346
345 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 347 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
346 float scale) OVERRIDE { 348 float scale,
349 float top_controls_delta) OVERRIDE {
347 num_impl_scrolls_++; 350 num_impl_scrolls_++;
348 } 351 }
349 352
350 virtual void AfterTest() OVERRIDE { 353 virtual void AfterTest() OVERRIDE {
351 EXPECT_EQ(3, num_impl_scrolls_); 354 EXPECT_EQ(3, num_impl_scrolls_);
352 // Verify that the embedder sees aborted commits as real commits. 355 // Verify that the embedder sees aborted commits as real commits.
353 EXPECT_EQ(4, num_will_begin_main_frames_); 356 EXPECT_EQ(4, num_will_begin_main_frames_);
354 EXPECT_EQ(4, num_did_begin_main_frames_); 357 EXPECT_EQ(4, num_did_begin_main_frames_);
355 EXPECT_EQ(4, num_will_commits_); 358 EXPECT_EQ(4, num_will_commits_);
356 EXPECT_EQ(4, num_did_commits_); 359 EXPECT_EQ(4, num_did_commits_);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // will stall the test). 509 // will stall the test).
507 if (layer_tree_host()->source_frame_number() < 2) { 510 if (layer_tree_host()->source_frame_number() < 2) {
508 layer_tree_host()->SetNeedsCommit(); 511 layer_tree_host()->SetNeedsCommit();
509 } 512 }
510 } 513 }
511 514
512 void DidScroll() { 515 void DidScroll() {
513 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); 516 final_scroll_offset_ = expected_scroll_layer_->scroll_offset();
514 } 517 }
515 518
516 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 519 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
517 float scale) OVERRIDE { 520 float scale,
521 float top_controls_delta) OVERRIDE {
518 num_scrolls_++; 522 num_scrolls_++;
519 } 523 }
520 524
521 virtual void Layout() OVERRIDE { 525 virtual void Layout() OVERRIDE {
522 EXPECT_VECTOR_EQ(gfx::Vector2d(), 526 EXPECT_VECTOR_EQ(gfx::Vector2d(),
523 expected_no_scroll_layer_->scroll_offset()); 527 expected_no_scroll_layer_->scroll_offset());
524 528
525 switch (layer_tree_host()->source_frame_number()) { 529 switch (layer_tree_host()->source_frame_number()) {
526 case 0: 530 case 0:
527 EXPECT_VECTOR_EQ(initial_offset_, 531 EXPECT_VECTOR_EQ(initial_offset_,
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 EXPECT_VECTOR_EQ( 848 EXPECT_VECTOR_EQ(
845 scroll_layer->scroll_offset(), 849 scroll_layer->scroll_offset(),
846 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); 850 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_);
847 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); 851 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_);
848 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); 852 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d());
849 EndTest(); 853 EndTest();
850 break; 854 break;
851 } 855 }
852 } 856 }
853 857
854 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 858 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
855 float scale) OVERRIDE { 859 float scale,
860 float top_controls_delta) OVERRIDE {
856 num_scrolls_++; 861 num_scrolls_++;
857 } 862 }
858 863
859 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } 864 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); }
860 865
861 private: 866 private:
862 gfx::Vector2d initial_scroll_; 867 gfx::Vector2d initial_scroll_;
863 gfx::Vector2d main_thread_scroll_; 868 gfx::Vector2d main_thread_scroll_;
864 gfx::Vector2d impl_thread_scroll1_; 869 gfx::Vector2d impl_thread_scroll1_;
865 gfx::Vector2d impl_thread_scroll2_; 870 gfx::Vector2d impl_thread_scroll2_;
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 RunTest(true, false, true); 1220 RunTest(true, false, true);
1216 } 1221 }
1217 1222
1218 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1223 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1219 scroll_destroy_whole_tree_ = true; 1224 scroll_destroy_whole_tree_ = true;
1220 RunTest(true, false, true); 1225 RunTest(true, false, true);
1221 } 1226 }
1222 1227
1223 } // namespace 1228 } // namespace
1224 } // namespace cc 1229 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_no_message_loop.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698