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

Side by Side Diff: cc/layer_unittest.cc

Issue 11377108: [cc] Fix crash when adding a child layer to its own parent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unittest. Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer.h" 7 #include "cc/layer.h"
8 8
9 #include "cc/keyframed_animation_curve.h" 9 #include "cc/keyframed_animation_curve.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child)); 157 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child));
158 158
159 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); 159 ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
160 EXPECT_EQ(child.get(), parent->children()[0]); 160 EXPECT_EQ(child.get(), parent->children()[0]);
161 EXPECT_EQ(parent.get(), child->parent()); 161 EXPECT_EQ(parent.get(), child->parent());
162 EXPECT_EQ(parent.get(), child->rootLayer()); 162 EXPECT_EQ(parent.get(), child->rootLayer());
163 163
164 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromPa rent()); 164 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromPa rent());
165 } 165 }
166 166
167 TEST_F(LayerTest, addSameChildTwice)
168 {
169 scoped_refptr<Layer> parent = Layer::create();
170 scoped_refptr<Layer> child = Layer::create();
171
172 parent->setLayerTreeHost(m_layerTreeHost.get());
danakj 2012/11/12 21:47:23 Do m_layerTreeHost->setRootLayer(parent) instead
Ted C 2012/11/12 22:15:45 Done.
173
174 ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
175
176 parent->addChild(child);
177 ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
178 EXPECT_EQ(parent.get(), child->parent());
179
180 parent->addChild(child);
181 ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
182 EXPECT_EQ(parent.get(), child->parent());
183 }
184
167 TEST_F(LayerTest, insertChild) 185 TEST_F(LayerTest, insertChild)
168 { 186 {
169 scoped_refptr<Layer> parent = Layer::create(); 187 scoped_refptr<Layer> parent = Layer::create();
170 scoped_refptr<Layer> child1 = Layer::create(); 188 scoped_refptr<Layer> child1 = Layer::create();
171 scoped_refptr<Layer> child2 = Layer::create(); 189 scoped_refptr<Layer> child2 = Layer::create();
172 scoped_refptr<Layer> child3 = Layer::create(); 190 scoped_refptr<Layer> child3 = Layer::create();
173 scoped_refptr<Layer> child4 = Layer::create(); 191 scoped_refptr<Layer> child4 = Layer::create();
174 192
175 parent->setLayerTreeHost(m_layerTreeHost.get()); 193 parent->setLayerTreeHost(m_layerTreeHost.get());
176 194
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 scoped_refptr<MockLayer> layer(new MockLayer); 811 scoped_refptr<MockLayer> layer(new MockLayer);
794 EXPECT_FALSE(layer->needsDisplay()); 812 EXPECT_FALSE(layer->needsDisplay());
795 layer->setBounds(gfx::Size(0, 10)); 813 layer->setBounds(gfx::Size(0, 10));
796 EXPECT_FALSE(layer->needsDisplay()); 814 EXPECT_FALSE(layer->needsDisplay());
797 layer->setBounds(gfx::Size(10, 10)); 815 layer->setBounds(gfx::Size(10, 10));
798 EXPECT_TRUE(layer->needsDisplay()); 816 EXPECT_TRUE(layer->needsDisplay());
799 } 817 }
800 818
801 819
802 } // anonymous namespace 820 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698