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

Unified Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 1999783003: cc : Initialize solid color scrollbar layer on main thread to 0. (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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/scrollbar_layer_unittest.cc
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index 22114c8b297e714db75c1e5a206148c5ed3cb2fd..81b99f04dc83a05c73fcf1258bb38d49f0cce9e6 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -522,32 +522,45 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) {
layer_tree_root->SetBounds(gfx::Size(2, 2));
scroll_layer->SetBounds(gfx::Size(10, 10));
- layer_tree_host_->UpdateLayers();
-
- LayerImpl* layer_impl_tree_root =
- layer_tree_host_->CommitAndCreateLayerImplTree();
-
- scrollbar_layer->SetOpacity(0.5f);
+ // A solid color scrollbar layer's opacity is initialized to 0 on main thread
layer_tree_host_->UpdateLayers();
EffectNode* node = layer_tree_host_->property_trees()->effect_tree.Node(
scrollbar_layer->effect_tree_index());
- EXPECT_EQ(node->data.opacity, 0.5f);
+ EXPECT_EQ(node->data.opacity, 0.f);
+ // This tests that the initial opacity(0) of the scrollbar gets pushed onto
+ // the pending tree and then onto the active tree.
LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl();
host_impl->CreatePendingTree();
- layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree();
+ LayerImpl* layer_impl_tree_root =
+ layer_tree_host_->CommitAndCreatePendingTree();
LayerTreeImpl* layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
EXPECT_TRUE(layer_tree_impl->IsPendingTree());
- layer_tree_impl->property_trees()->effect_tree.Node(
+ node = layer_tree_impl->property_trees()->effect_tree.Node(
+ scrollbar_layer->effect_tree_index());
+ EXPECT_EQ(node->data.opacity, 0.f);
+ host_impl->ActivateSyncTree();
+ layer_tree_impl = host_impl->active_tree();
+ node = layer_tree_impl->property_trees()->effect_tree.Node(
+ scrollbar_layer->effect_tree_index());
+ EXPECT_EQ(node->data.opacity, 0.f);
+
+ // This tests that activation does not change the opacity of scrollbar layer.
+ LayerImpl* scrollbar_layer_impl =
+ layer_tree_impl->LayerById(scrollbar_layer->id());
+ scrollbar_layer_impl->OnOpacityAnimated(0.25f);
+ host_impl->CreatePendingTree();
+ layer_impl_tree_root = layer_tree_host_->CommitAndCreatePendingTree();
+ layer_tree_impl = layer_impl_tree_root->layer_tree_impl();
+ EXPECT_TRUE(layer_tree_impl->IsPendingTree());
+ node = layer_tree_impl->property_trees()->effect_tree.Node(
scrollbar_layer->effect_tree_index());
- EXPECT_EQ(node->data.opacity, 0.5f);
- // The active tree opacity should not change with activation for scrollbar
- // layer.
+ EXPECT_EQ(node->data.opacity, 0.f);
host_impl->ActivateSyncTree();
layer_tree_impl = host_impl->active_tree();
node = layer_tree_impl->property_trees()->effect_tree.Node(
scrollbar_layer->effect_tree_index());
- EXPECT_EQ(node->data.opacity, 1.f);
+ EXPECT_EQ(node->data.opacity, 0.25f);
}
class ScrollbarLayerSolidColorThumbTest : public testing::Test {

Powered by Google App Engine
This is Rietveld 408576698