OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 PostSetNeedsCommitToMainThread(); | 76 PostSetNeedsCommitToMainThread(); |
77 break; | 77 break; |
78 case 1: | 78 case 1: |
79 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); | 79 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); |
80 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 80 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
81 EndTest(); | 81 EndTest(); |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 86 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
87 float scale) OVERRIDE { | 87 float scale) OVERRIDE { |
88 num_scrolls_++; | 88 num_scrolls_++; |
89 } | 89 } |
90 | 90 |
91 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 91 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
92 | 92 |
93 private: | 93 private: |
94 gfx::Vector2d initial_scroll_; | 94 gfx::Vector2d initial_scroll_; |
95 gfx::Vector2d second_scroll_; | 95 gfx::Vector2d second_scroll_; |
96 gfx::Vector2d scroll_amount_; | 96 gfx::Vector2d scroll_amount_; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } else if (impl->active_tree()->source_frame_number() == 1) { | 160 } else if (impl->active_tree()->source_frame_number() == 1) { |
161 // Third or later draw after second commit. | 161 // Third or later draw after second commit. |
162 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); | 162 EXPECT_GE(impl->SourceAnimationFrameNumber(), 3); |
163 EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d()); | 163 EXPECT_VECTOR_EQ(scroll_layer_->ScrollDelta(), gfx::Vector2d()); |
164 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), | 164 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), |
165 initial_scroll_ + scroll_amount_ + scroll_amount_); | 165 initial_scroll_ + scroll_amount_ + scroll_amount_); |
166 EndTest(); | 166 EndTest(); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 170 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
171 float scale) OVERRIDE { | 171 float scale) OVERRIDE { |
172 num_scrolls_++; | 172 num_scrolls_++; |
173 } | 173 } |
174 | 174 |
175 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 175 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
176 | 176 |
177 private: | 177 private: |
178 gfx::Vector2d initial_scroll_; | 178 gfx::Vector2d initial_scroll_; |
179 gfx::Vector2d scroll_amount_; | 179 gfx::Vector2d scroll_amount_; |
180 int num_scrolls_; | 180 int num_scrolls_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 impl->SourceAnimationFrameNumber() == 4) { | 324 impl->SourceAnimationFrameNumber() == 4) { |
325 // Final draw after the second aborted commit. | 325 // Final draw after the second aborted commit. |
326 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 326 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); |
327 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 327 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), |
328 initial_scroll_ + impl_scroll_ + impl_scroll_ + | 328 initial_scroll_ + impl_scroll_ + impl_scroll_ + |
329 impl_scroll_ + second_main_scroll_); | 329 impl_scroll_ + second_main_scroll_); |
330 EndTest(); | 330 EndTest(); |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 334 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
335 float scale) OVERRIDE { | 335 float scale) OVERRIDE { |
336 num_impl_scrolls_++; | 336 num_impl_scrolls_++; |
337 } | 337 } |
338 | 338 |
339 virtual void AfterTest() OVERRIDE { | 339 virtual void AfterTest() OVERRIDE { |
340 EXPECT_EQ(3, num_impl_scrolls_); | 340 EXPECT_EQ(3, num_impl_scrolls_); |
341 // Verify that the embedder sees aborted commits as real commits. | 341 // Verify that the embedder sees aborted commits as real commits. |
342 EXPECT_EQ(4, num_will_begin_main_frames_); | 342 EXPECT_EQ(4, num_will_begin_main_frames_); |
343 EXPECT_EQ(4, num_did_begin_main_frames_); | 343 EXPECT_EQ(4, num_did_begin_main_frames_); |
344 EXPECT_EQ(4, num_will_commits_); | 344 EXPECT_EQ(4, num_will_commits_); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // will stall the test). | 497 // will stall the test). |
498 if (layer_tree_host()->source_frame_number() < 2) { | 498 if (layer_tree_host()->source_frame_number() < 2) { |
499 layer_tree_host()->SetNeedsCommit(); | 499 layer_tree_host()->SetNeedsCommit(); |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 void DidScroll() { | 503 void DidScroll() { |
504 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); | 504 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); |
505 } | 505 } |
506 | 506 |
507 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 507 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
508 float scale) OVERRIDE { | 508 float scale) OVERRIDE { |
509 num_scrolls_++; | 509 num_scrolls_++; |
510 } | 510 } |
511 | 511 |
512 virtual void Layout() OVERRIDE { | 512 virtual void Layout() OVERRIDE { |
513 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 513 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
514 expected_no_scroll_layer_->scroll_offset()); | 514 expected_no_scroll_layer_->scroll_offset()); |
515 | 515 |
516 switch (layer_tree_host()->source_frame_number()) { | 516 switch (layer_tree_host()->source_frame_number()) { |
517 case 0: | 517 case 0: |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 EXPECT_VECTOR_EQ( | 857 EXPECT_VECTOR_EQ( |
858 scroll_layer->scroll_offset(), | 858 scroll_layer->scroll_offset(), |
859 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); | 859 initial_scroll_ + main_thread_scroll_ + impl_thread_scroll1_); |
860 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); | 860 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); |
861 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 861 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); |
862 EndTest(); | 862 EndTest(); |
863 break; | 863 break; |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 867 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
868 float scale) OVERRIDE { | 868 float scale) OVERRIDE { |
869 num_scrolls_++; | 869 num_scrolls_++; |
870 } | 870 } |
871 | 871 |
872 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 872 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } |
873 | 873 |
874 private: | 874 private: |
875 gfx::Vector2d initial_scroll_; | 875 gfx::Vector2d initial_scroll_; |
876 gfx::Vector2d main_thread_scroll_; | 876 gfx::Vector2d main_thread_scroll_; |
877 gfx::Vector2d impl_thread_scroll1_; | 877 gfx::Vector2d impl_thread_scroll1_; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 RunTest(true, false, false); | 1220 RunTest(true, false, false); |
1221 } | 1221 } |
1222 | 1222 |
1223 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1223 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
1224 scroll_destroy_whole_tree_ = true; | 1224 scroll_destroy_whole_tree_ = true; |
1225 RunTest(true, false, false); | 1225 RunTest(true, false, false); |
1226 } | 1226 } |
1227 | 1227 |
1228 } // namespace | 1228 } // namespace |
1229 } // namespace cc | 1229 } // namespace cc |
OLD | NEW |