Chromium Code Reviews| Index: ui/compositor/layer_owner_unittest.cc |
| diff --git a/ui/compositor/layer_owner_unittest.cc b/ui/compositor/layer_owner_unittest.cc |
| index 6390ecaf4633f026c409573114a6defb216f003e..5196c2d0330fa4543724ce2fcfdb6176db8d2e76 100644 |
| --- a/ui/compositor/layer_owner_unittest.cc |
| +++ b/ui/compositor/layer_owner_unittest.cc |
| @@ -4,10 +4,14 @@ |
| #include "ui/compositor/layer_owner.h" |
| +#include "base/test/null_task_runner.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/compositor/compositor.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_animator.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| +#include "ui/compositor/test/context_factories_for_test.h" |
| +#include "ui/gfx/native_widget_types.h" |
| namespace ui { |
| @@ -30,4 +34,35 @@ TEST(LayerOwnerTest, RecreateLayerHonorsTargetVisibilityAndOpacity) { |
| EXPECT_EQ(0.0f, owner.layer()->opacity()); |
| } |
| +TEST(LayerOwnerTest, RecreateRootLayerWithNullCompositor) { |
| + LayerOwner owner; |
| + Layer* layer = new Layer; |
| + owner.SetLayer(layer); |
| + |
| + scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); |
| + |
| + EXPECT_EQ(nullptr, owner.layer()->GetCompositor()); |
| + EXPECT_EQ(nullptr, layer_copy->GetCompositor()); |
| +} |
| + |
| +TEST(LayerOwnerTest, RecreateRootLayerWithCompositor) { |
| + LayerOwner owner; |
| + Layer* layer = new Layer; |
| + owner.SetLayer(layer); |
| + |
| + ui::ContextFactory* context_factory = |
| + ui::InitializeContextFactoryForTests(false); |
|
Lei Zhang
2015/03/06 22:09:14
Looks like you forgot to call TerminateContextFact
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| + new base::NullTaskRunner(); |
| + scoped_ptr<ui::Compositor> compositor(new ui::Compositor( |
| + gfx::kNullAcceleratedWidget, context_factory, task_runner)); |
| + compositor->SetRootLayer(layer); |
| + |
| + scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); |
| + |
| + EXPECT_EQ(compositor.get(), owner.layer()->GetCompositor()); |
| + EXPECT_EQ(owner.layer(), compositor->root_layer()); |
| + EXPECT_EQ(nullptr, layer_copy->GetCompositor()); |
| +} |
| + |
| } // namespace ui |