Commit 315f4d32 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Make ui::LayerOwner::SetLayer a protected method.

The goal is to make it easy to verify that an aura::Window always
has a layer once initialized.

Bug: 738387
Change-Id: I09c4972006c8a4b86fcde0e39fc12291187e0a78
Reviewed-on: https://chromium-review.googlesource.com/774909
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517418}
parent 19090e84
...@@ -19,8 +19,6 @@ class COMPOSITOR_EXPORT LayerOwner { ...@@ -19,8 +19,6 @@ class COMPOSITOR_EXPORT LayerOwner {
LayerOwner(); LayerOwner();
virtual ~LayerOwner(); virtual ~LayerOwner();
void SetLayer(std::unique_ptr<Layer> layer);
// Releases the owning reference to its layer, and returns it. // Releases the owning reference to its layer, and returns it.
// This is used when you need to animate the presentation of the owner just // This is used when you need to animate the presentation of the owner just
// prior to destroying it. The Owner can be destroyed soon after calling this // prior to destroying it. The Owner can be destroyed soon after calling this
...@@ -42,6 +40,7 @@ class COMPOSITOR_EXPORT LayerOwner { ...@@ -42,6 +40,7 @@ class COMPOSITOR_EXPORT LayerOwner {
bool OwnsLayer() const; bool OwnsLayer() const;
protected: protected:
void SetLayer(std::unique_ptr<Layer> layer);
void DestroyLayer(); void DestroyLayer();
private: private:
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "ui/compositor/layer_owner.h" #include "ui/compositor/layer_owner.h"
#include <utility>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/test/null_task_runner.h" #include "base/test/null_task_runner.h"
...@@ -41,6 +43,9 @@ class TestLayerAnimationObserver : public ImplicitAnimationObserver { ...@@ -41,6 +43,9 @@ class TestLayerAnimationObserver : public ImplicitAnimationObserver {
class LayerOwnerForTesting : public LayerOwner { class LayerOwnerForTesting : public LayerOwner {
public: public:
LayerOwnerForTesting(std::unique_ptr<Layer> layer) {
SetLayer(std::move(layer));
}
void DestroyLayerForTesting() { DestroyLayer(); } void DestroyLayerForTesting() { DestroyLayer(); }
}; };
...@@ -94,8 +99,7 @@ void LayerOwnerTestWithCompositor::TearDown() { ...@@ -94,8 +99,7 @@ void LayerOwnerTestWithCompositor::TearDown() {
} // namespace } // namespace
TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) { TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
LayerOwner owner; LayerOwnerForTesting owner(std::make_unique<Layer>());
owner.SetLayer(std::make_unique<Layer>());
Layer* layer = owner.layer(); Layer* layer = owner.layer();
compositor()->SetRootLayer(layer); compositor()->SetRootLayer(layer);
...@@ -110,8 +114,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) { ...@@ -110,8 +114,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
// properly updates the compositor. So that compositor is not null for observers // properly updates the compositor. So that compositor is not null for observers
// of animations being cancelled. // of animations being cancelled.
TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerDuringAnimation) { TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerDuringAnimation) {
LayerOwner owner; LayerOwnerForTesting owner(std::make_unique<Layer>());
owner.SetLayer(std::make_unique<Layer>());
Layer* layer = owner.layer(); Layer* layer = owner.layer();
compositor()->SetRootLayer(layer); compositor()->SetRootLayer(layer);
...@@ -145,8 +148,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) { ...@@ -145,8 +148,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
std::unique_ptr<Layer> root_layer(new Layer); std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get()); compositor()->SetRootLayer(root_layer.get());
LayerOwner owner; LayerOwnerForTesting owner(std::make_unique<Layer>());
owner.SetLayer(std::make_unique<Layer>());
Layer* layer = owner.layer(); Layer* layer = owner.layer();
root_layer->Add(layer); root_layer->Add(layer);
...@@ -179,8 +181,7 @@ TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) { ...@@ -179,8 +181,7 @@ TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
std::unique_ptr<Layer> root_layer(new Layer); std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get()); compositor()->SetRootLayer(root_layer.get());
LayerOwnerForTesting owner; LayerOwnerForTesting owner(std::make_unique<Layer>());
owner.SetLayer(std::make_unique<Layer>());
Layer* layer = owner.layer(); Layer* layer = owner.layer();
layer->SetOpacity(0.5f); layer->SetOpacity(0.5f);
root_layer->Add(layer); root_layer->Add(layer);
...@@ -202,8 +203,7 @@ TEST_F(LayerOwnerTestWithCompositor, ...@@ -202,8 +203,7 @@ TEST_F(LayerOwnerTestWithCompositor,
std::unique_ptr<Layer> root_layer(new Layer); std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get()); compositor()->SetRootLayer(root_layer.get());
LayerOwner owner; LayerOwnerForTesting owner(std::make_unique<Layer>());
owner.SetLayer(std::make_unique<Layer>());
Layer* layer = owner.layer(); Layer* layer = owner.layer();
root_layer->Add(layer); root_layer->Add(layer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment