Index: third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp |
index bd06f90e472914a5fa516aaa1a9b69f4c5713813..38247d108e40503a2a79733b7d1d01e949bd72c7 100644 |
--- a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp |
@@ -12,6 +12,7 @@ |
#include "cc/test/test_task_graph_runner.h" |
#include "cc/trees/layer_tree_host_impl.h" |
#include "cc/trees/layer_tree_impl.h" |
+#include "platform/graphics/CompositorElementId.h" |
#include "platform/graphics/CompositorMutableProperties.h" |
#include "platform/graphics/CompositorMutableStateProvider.h" |
#include "platform/graphics/CompositorMutation.h" |
@@ -83,22 +84,14 @@ TEST_F(CompositorMutableStateTest, NoMutableState) |
EXPECT_FALSE(state); |
} |
-TEST_F(CompositorMutableStateTest, MutableStateNoMutableProperties) |
+TEST_F(CompositorMutableStateTest, EnsureNoSubElementIdCollisions) |
{ |
- // In this test, there is a layer with an element id, but no mutable |
- // properties. This should behave just as if we'd had no element id. |
- std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree(), 42); |
- SetLayerPropertiesForTesting(root.get()); |
- root->SetElementId(42); |
- |
- hostImpl().SetViewportSize(root->bounds()); |
- hostImpl().active_tree()->SetRootLayer(std::move(root)); |
- hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
- |
- CompositorMutations mutations; |
- CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations); |
- OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); |
- EXPECT_FALSE(state); |
+ // If we happen to do bit shifting in CompositorElementId, try to catch |
jbroman
2016/06/06 14:23:20
Is this test still meaningful with the current pai
Ian Vollick
2016/06/06 16:31:29
Not really. I'd put it in to catch a bug I'd cause
|
+ // cases where we forget to shift before bitwise or'ing. |
+ const int domNodeId = 42; |
+ CompositorElementId createdWithSubElement = createCompositorElementId(domNodeId, CompositorSubElementId::Scroll); |
+ CompositorElementId createdDirectly(static_cast<uint64_t>(domNodeId) | static_cast<uint64_t>(CompositorSubElementId::Scroll), 0); |
+ EXPECT_NE(createdWithSubElement, createdDirectly); |
} |
TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) |
@@ -116,8 +109,10 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) |
root->AddChild(std::move(scopedLayer)); |
SetLayerPropertiesForTesting(layer); |
- layer->SetElementId(12); |
- root->SetElementId(layer->element_id()); |
+ |
+ int primaryId = 12; |
+ root->SetElementId(createCompositorElementId(primaryId, CompositorSubElementId::Primary)); |
+ layer->SetElementId(createCompositorElementId(primaryId, CompositorSubElementId::Scroll)); |
root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorMutableProperty::kTransform); |
layer->SetMutableProperties(CompositorMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop); |
@@ -129,7 +124,7 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) |
CompositorMutations mutations; |
CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations); |
- OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(layer->element_id())); |
+ OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(primaryId)); |
EXPECT_TRUE(state.get()); |
EXPECT_EQ(1.0, rootLayer()->Opacity()); |
@@ -151,7 +146,7 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) |
// The corresponding mutation should reflect the changed values. |
EXPECT_EQ(1ul, mutations.map.size()); |
- const CompositorMutation& mutation = *mutations.map.find(layer->element_id())->value; |
+ const CompositorMutation& mutation = *mutations.map.find(primaryId)->value; |
EXPECT_TRUE(mutation.isOpacityMutated()); |
EXPECT_TRUE(mutation.isTransformMutated()); |
EXPECT_TRUE(mutation.isScrollLeftMutated()); |