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

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

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 // Check that a fractional scroll delta is correctly accumulated over 423 // Check that a fractional scroll delta is correctly accumulated over
424 // multiple commits. 424 // multiple commits.
425 switch (impl->active_tree()->source_frame_number()) { 425 switch (impl->active_tree()->source_frame_number()) {
426 case 0: 426 case 0:
427 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), gfx::Vector2d(0, 0)); 427 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), gfx::Vector2d(0, 0));
428 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); 428 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0));
429 PostSetNeedsCommitToMainThread(); 429 PostSetNeedsCommitToMainThread();
430 break; 430 break;
431 case 1: 431 case 1:
432 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), 432 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(), scroll_amount_);
433 gfx::ToFlooredVector2d(scroll_amount_)); 433 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF());
434 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(),
435 gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f));
436 PostSetNeedsCommitToMainThread(); 434 PostSetNeedsCommitToMainThread();
437 break; 435 break;
438 case 2: 436 case 2:
439 EXPECT_VECTOR_EQ( 437 EXPECT_VECTOR_EQ(scroll_layer->BaseScrollOffset(),
440 scroll_layer->BaseScrollOffset(), 438 (scroll_amount_ + scroll_amount_));
441 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); 439 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2dF());
442 EXPECT_VECTOR_EQ(
443 scroll_layer->ScrollDelta(),
444 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f));
445 EndTest(); 440 EndTest();
446 break; 441 break;
447 } 442 }
448 scroll_layer->ScrollBy(scroll_amount_); 443 scroll_layer->ScrollBy(scroll_amount_);
449 } 444 }
450 445
451 void AfterTest() override {} 446 void AfterTest() override {}
452 447
453 private: 448 private:
454 gfx::Vector2dF scroll_amount_; 449 gfx::Vector2dF scroll_amount_;
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1032 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1038 1033
1039 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1034 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1040 LayerImpl* root = impl->active_tree()->root_layer(); 1035 LayerImpl* root = impl->active_tree()->root_layer();
1041 LayerImpl* scroll_layer = root->children()[0]; 1036 LayerImpl* scroll_layer = root->children()[0];
1042 scroll_layer->SetScrollClipLayer(root->id()); 1037 scroll_layer->SetScrollClipLayer(root->id());
1043 1038
1044 // Set max_scroll_offset = (100, 100). 1039 // Set max_scroll_offset = (100, 100).
1045 scroll_layer->SetBounds( 1040 scroll_layer->SetBounds(
1046 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); 1041 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100));
1047 EXPECT_EQ(InputHandler::ScrollStarted, 1042 EXPECT_EQ(
1048 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), 1043 InputHandler::ScrollStarted,
1049 InputHandler::Gesture)); 1044 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture,
1045 ScrollBlocksOnNone));
1050 1046
1051 // Set max_scroll_offset = (0, 0). 1047 // Set max_scroll_offset = (0, 0).
1052 scroll_layer->SetBounds(root->bounds()); 1048 scroll_layer->SetBounds(root->bounds());
1053 EXPECT_EQ(InputHandler::ScrollIgnored, 1049 EXPECT_EQ(
1054 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), 1050 InputHandler::ScrollIgnored,
1055 InputHandler::Gesture)); 1051 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture,
1052 ScrollBlocksOnNone));
1056 1053
1057 // Set max_scroll_offset = (-100, -100). 1054 // Set max_scroll_offset = (-100, -100).
1058 scroll_layer->SetBounds(gfx::Size()); 1055 scroll_layer->SetBounds(gfx::Size());
1059 EXPECT_EQ(InputHandler::ScrollIgnored, 1056 EXPECT_EQ(
1060 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), 1057 InputHandler::ScrollIgnored,
1061 InputHandler::Gesture)); 1058 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), InputHandler::Gesture,
1059 ScrollBlocksOnNone));
1062 1060
1063 EndTest(); 1061 EndTest();
1064 } 1062 }
1065 1063
1066 void AfterTest() override {} 1064 void AfterTest() override {}
1067 }; 1065 };
1068 1066
1069 SINGLE_AND_MULTI_THREAD_TEST_F( 1067 SINGLE_AND_MULTI_THREAD_TEST_F(
1070 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); 1068 LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
1071 1069
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 RunTest(true, false, true); 1229 RunTest(true, false, true);
1232 } 1230 }
1233 1231
1234 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1232 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1235 scroll_destroy_whole_tree_ = true; 1233 scroll_destroy_whole_tree_ = true;
1236 RunTest(true, false, true); 1234 RunTest(true, false, true);
1237 } 1235 }
1238 1236
1239 } // namespace 1237 } // namespace
1240 } // namespace cc 1238 } // 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