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

Unified Diff: ui/gfx/compositor/layer_unittest.cc

Issue 8510076: Fix stale compositor references from ui::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux_touch build Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/compositor/layer.cc ('k') | views/view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer_unittest.cc
diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc
index e6b04f36cf5307505a4f74e341da7655435df499..3ed245147e3db4f6a403afdc9d56c8a13731358c 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -34,8 +34,8 @@ namespace {
class ColoredLayer : public Layer, public LayerDelegate {
public:
- ColoredLayer(Compositor* compositor, SkColor color)
- : Layer(compositor, Layer::LAYER_HAS_TEXTURE),
+ explicit ColoredLayer(SkColor color)
+ : Layer(Layer::LAYER_HAS_TEXTURE),
color_(color) {
set_delegate(this);
}
@@ -71,11 +71,11 @@ class LayerWithRealCompositorTest : public testing::Test {
}
Layer* CreateLayer(Layer::LayerType type) {
- return new Layer(GetCompositor(), type);
+ return new Layer(type);
}
Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) {
- Layer* layer = new ColoredLayer(GetCompositor(), color);
+ Layer* layer = new ColoredLayer(color);
layer->SetBounds(bounds);
return layer;
}
@@ -203,6 +203,7 @@ bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) {
#define MAYBE_Hierarchy DISABLED_Hierarchy
#define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture
#define MAYBE_DrawPixels DISABLED_DrawPixels
+#define MAYBE_SetRootLayer DISABLED_SetRootLayer
#else
#define MAYBE_Delegate Delegate
#define MAYBE_Draw Draw
@@ -210,6 +211,7 @@ bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) {
#define MAYBE_Hierarchy Hierarchy
#define MAYBE_HierarchyNoTexture HierarchyNoTexture
#define MAYBE_DrawPixels DrawPixels
+#define MAYBE_SetRootLayer SetRootLayer
#endif
TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) {
@@ -257,11 +259,11 @@ class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
Compositor* compositor() { return compositor_.get(); }
virtual Layer* CreateLayer(Layer::LayerType type) {
- return new Layer(compositor(), type);
+ return new Layer(type);
}
Layer* CreateColorLayer(SkColor color, const gfx::Rect& bounds) {
- Layer* layer = new ColoredLayer(compositor(), color);
+ Layer* layer = new ColoredLayer(color);
layer->SetBounds(bounds);
return layer;
}
@@ -461,7 +463,7 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest {
}
Layer* CreateLayer(Layer::LayerType type) OVERRIDE {
- Layer* layer = new Layer(compositor(), type);
+ Layer* layer = new Layer(type);
layer->set_delegate(default_layer_delegate_.get());
return layer;
}
@@ -888,9 +890,9 @@ TEST_F(LayerWithNullDelegateTest,
// Various visibile/drawn assertions.
TEST_F(LayerWithNullDelegateTest, Visibility) {
- scoped_ptr<Layer> l1(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
- scoped_ptr<Layer> l2(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
- scoped_ptr<Layer> l3(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
+ scoped_ptr<Layer> l1(new Layer(Layer::LAYER_HAS_TEXTURE));
+ scoped_ptr<Layer> l2(new Layer(Layer::LAYER_HAS_TEXTURE));
+ scoped_ptr<Layer> l3(new Layer(Layer::LAYER_HAS_TEXTURE));
l1->Add(l2.get());
l2->Add(l3.get());
@@ -999,4 +1001,30 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) {
EXPECT_TRUE(is_all_red);
}
+// Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
+TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) {
+ Compositor* compositor = GetCompositor();
+ Layer l1;
+ EXPECT_EQ(NULL, l1.GetCompositor());
+
+ Layer l2;
+ EXPECT_EQ(NULL, l2.GetCompositor());
+
+ compositor->SetRootLayer(&l1);
+ EXPECT_EQ(compositor, l1.GetCompositor());
+
+ l1.Add(&l2);
+ EXPECT_EQ(compositor, l2.GetCompositor());
+
+ l1.Remove(&l2);
+ EXPECT_EQ(NULL, l2.GetCompositor());
+
+ l1.Add(&l2);
+ EXPECT_EQ(compositor, l2.GetCompositor());
+
+ compositor->SetRootLayer(NULL);
+ EXPECT_EQ(NULL, l1.GetCompositor());
+ EXPECT_EQ(NULL, l2.GetCompositor());
+}
+
} // namespace ui
« no previous file with comments | « ui/gfx/compositor/layer.cc ('k') | views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698