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

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

Issue 2014533005: cc : Reland Add IsInIdtoIndexMap to property tres (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/trees/property_tree.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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/input/scrollbar_animation_controller.h" 10 #include "cc/input/scrollbar_animation_controller.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 int next_id_; 92 int next_id_;
93 int total_ui_resource_created_; 93 int total_ui_resource_created_;
94 int total_ui_resource_deleted_; 94 int total_ui_resource_deleted_;
95 }; 95 };
96 96
97 class ScrollbarLayerTest : public testing::Test { 97 class ScrollbarLayerTest : public testing::Test {
98 public: 98 public:
99 ScrollbarLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) { 99 ScrollbarLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {
100 layer_tree_settings_.single_thread_proxy_scheduler = false; 100 layer_tree_settings_.single_thread_proxy_scheduler = false;
101 layer_tree_settings_.use_zero_copy = true; 101 layer_tree_settings_.use_zero_copy = true;
102 layer_tree_settings_.scrollbar_animator = LayerTreeSettings::LINEAR_FADE;
103 layer_tree_settings_.scrollbar_fade_delay_ms = 20;
104 layer_tree_settings_.scrollbar_fade_duration_ms = 20;
102 105
103 scrollbar_layer_id_ = -1; 106 scrollbar_layer_id_ = -1;
104 107
105 LayerTreeHost::InitParams params; 108 LayerTreeHost::InitParams params;
106 params.client = &fake_client_; 109 params.client = &fake_client_;
107 params.settings = &layer_tree_settings_; 110 params.settings = &layer_tree_settings_;
108 params.task_graph_runner = &task_graph_runner_; 111 params.task_graph_runner = &task_graph_runner_;
109 112
110 layer_tree_host_.reset( 113 layer_tree_host_.reset(
111 new FakeResourceTrackingLayerTreeHost(&fake_client_, &params)); 114 new FakeResourceTrackingLayerTreeHost(&fake_client_, &params));
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 EXPECT_EQ(node->data.opacity, 0.5f); 546 EXPECT_EQ(node->data.opacity, 0.5f);
544 // The active tree opacity should not change with activation for scrollbar 547 // The active tree opacity should not change with activation for scrollbar
545 // layer. 548 // layer.
546 host_impl->ActivateSyncTree(); 549 host_impl->ActivateSyncTree();
547 layer_tree_impl = host_impl->active_tree(); 550 layer_tree_impl = host_impl->active_tree();
548 node = layer_tree_impl->property_trees()->effect_tree.Node( 551 node = layer_tree_impl->property_trees()->effect_tree.Node(
549 scrollbar_layer->effect_tree_index()); 552 scrollbar_layer->effect_tree_index());
550 EXPECT_EQ(node->data.opacity, 1.f); 553 EXPECT_EQ(node->data.opacity, 1.f);
551 } 554 }
552 555
556 TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) {
557 // Pushing changed bounds of scroll layer can lead to calling
558 // OnOpacityAnimated on scrollbar layer which means OnOpacityAnimated should
559 // be independent of scrollbar layer's properties as scrollbar layer can push
560 // its properties after scroll layer.
561 const int kThumbThickness = 3;
562 const int kTrackStart = 0;
563 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
564
565 scoped_refptr<Layer> layer_tree_root = Layer::Create();
566 scoped_refptr<Layer> scroll_layer = Layer::Create();
567 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
568 scoped_refptr<Layer> child1 = Layer::Create();
569 scoped_refptr<Layer> scrollbar_layer;
570 const bool kIsLeftSideVerticalScrollbar = false;
571 scrollbar_layer = SolidColorScrollbarLayer::Create(
572 scrollbar->Orientation(), kThumbThickness, kTrackStart,
573 kIsLeftSideVerticalScrollbar, child1->id());
574 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
575 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id());
576 scroll_layer->AddChild(child1);
577 scroll_layer->InsertChild(scrollbar_layer, 1);
578 layer_tree_root->AddChild(scroll_layer);
579 layer_tree_host_->SetRootLayer(layer_tree_root);
580
581 layer_tree_root->SetBounds(gfx::Size(2, 2));
582 scroll_layer->SetBounds(gfx::Size(10, 10));
583 layer_tree_host_->UpdateLayers();
584 LayerImpl* layer_impl_tree_root =
585 layer_tree_host_->CommitAndCreateLayerImplTree();
586 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
587 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForId(scroll_layer->id()));
588
589 scroll_layer->SetBounds(gfx::Size(20, 20));
590 scroll_layer->SetForceRenderSurfaceForTesting(true);
591 layer_tree_host_->UpdateLayers();
592 host_impl->CreatePendingTree();
593 layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree();
594 host_impl->ActivateSyncTree();
595 EffectNode* node =
596 host_impl->active_tree()->property_trees()->effect_tree.Node(
597 scrollbar_layer->effect_tree_index());
598 EXPECT_EQ(node->data.opacity, 1.f);
jaydasika 2016/05/26 02:17:06 If we use effect tree index in LayerImpl::OnOpacit
599 }
600
553 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 601 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
554 public: 602 public:
555 ScrollbarLayerSolidColorThumbTest() { 603 ScrollbarLayerSolidColorThumbTest() {
556 LayerTreeSettings layer_tree_settings; 604 LayerTreeSettings layer_tree_settings;
557 host_impl_.reset(new FakeLayerTreeHostImpl( 605 host_impl_.reset(new FakeLayerTreeHostImpl(
558 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_, 606 layer_tree_settings, &task_runner_provider_, &shared_bitmap_manager_,
559 &task_graph_runner_)); 607 &task_graph_runner_));
560 608
561 const int kThumbThickness = 3; 609 const int kThumbThickness = 3;
562 const int kTrackStart = 0; 610 const int kTrackStart = 0;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 1120 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1073 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1121 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1074 1122
1075 // Horizontal Scrollbars. 1123 // Horizontal Scrollbars.
1076 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1124 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1077 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1125 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1078 } 1126 }
1079 1127
1080 } // namespace 1128 } // namespace
1081 } // namespace cc 1129 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698