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 {
LayerOwner();
virtual ~LayerOwner();
void SetLayer(std::unique_ptr<Layer> layer);
// Releases the owning reference to its layer, and returns it.
// 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
......@@ -42,6 +40,7 @@ class COMPOSITOR_EXPORT LayerOwner {
bool OwnsLayer() const;
protected:
void SetLayer(std::unique_ptr<Layer> layer);
void DestroyLayer();
private:
......
......@@ -4,6 +4,8 @@
#include "ui/compositor/layer_owner.h"
#include <utility>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/test/null_task_runner.h"
......@@ -41,6 +43,9 @@ class TestLayerAnimationObserver : public ImplicitAnimationObserver {
class LayerOwnerForTesting : public LayerOwner {
public:
LayerOwnerForTesting(std::unique_ptr<Layer> layer) {
SetLayer(std::move(layer));
}
void DestroyLayerForTesting() { DestroyLayer(); }
};
......@@ -94,8 +99,7 @@ void LayerOwnerTestWithCompositor::TearDown() {
} // namespace
TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
LayerOwner owner;
owner.SetLayer(std::make_unique<Layer>());
LayerOwnerForTesting owner(std::make_unique<Layer>());
Layer* layer = owner.layer();
compositor()->SetRootLayer(layer);
......@@ -110,8 +114,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
// properly updates the compositor. So that compositor is not null for observers
// of animations being cancelled.
TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerDuringAnimation) {
LayerOwner owner;
owner.SetLayer(std::make_unique<Layer>());
LayerOwnerForTesting owner(std::make_unique<Layer>());
Layer* layer = owner.layer();
compositor()->SetRootLayer(layer);
......@@ -145,8 +148,7 @@ TEST_F(LayerOwnerTestWithCompositor, RecreateNonRootLayerDuringAnimation) {
std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwner owner;
owner.SetLayer(std::make_unique<Layer>());
LayerOwnerForTesting owner(std::make_unique<Layer>());
Layer* layer = owner.layer();
root_layer->Add(layer);
......@@ -179,8 +181,7 @@ TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) {
std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwnerForTesting owner;
owner.SetLayer(std::make_unique<Layer>());
LayerOwnerForTesting owner(std::make_unique<Layer>());
Layer* layer = owner.layer();
layer->SetOpacity(0.5f);
root_layer->Add(layer);
......@@ -202,8 +203,7 @@ TEST_F(LayerOwnerTestWithCompositor,
std::unique_ptr<Layer> root_layer(new Layer);
compositor()->SetRootLayer(root_layer.get());
LayerOwner owner;
owner.SetLayer(std::make_unique<Layer>());
LayerOwnerForTesting owner(std::make_unique<Layer>());
Layer* layer = owner.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