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

Unified Diff: ui/compositor/layer_animator_unittest.cc

Issue 2550933002: Make all LayerAnimationElement::Create*Element return unique_ptr (Closed)
Patch Set: Complete inclusion Created 4 years 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
Index: ui/compositor/layer_animator_unittest.cc
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc
index 012eea4fe69a1de5cca1d3eeb472c39e85f4081b..53fec5f0e7ee0d798167cd02e72a85e664837241 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -44,12 +45,12 @@ std::string ColorToString(SkColor color) {
// Creates vector with two LayerAnimationSequences, based on |first| and
// |second| layer animation elements.
std::vector<LayerAnimationSequence*> CreateMultiSequence(
- LayerAnimationElement* first,
- LayerAnimationElement* second) {
+ std::unique_ptr<LayerAnimationElement> first,
+ std::unique_ptr<LayerAnimationElement> second) {
LayerAnimationSequence* first_sequence = new LayerAnimationSequence();
- first_sequence->AddElement(first);
+ first_sequence->AddElement(std::move(first));
LayerAnimationSequence* second_sequence = new LayerAnimationSequence();
- second_sequence->AddElement(second);
+ second_sequence->AddElement(std::move(second));
std::vector<ui::LayerAnimationSequence*> animations;
animations.push_back(first_sequence);
@@ -242,9 +243,9 @@ class TestLayerAnimator : public LayerAnimator {
// created and destroyed.
class TestLayerAnimationSequence : public LayerAnimationSequence {
public:
- TestLayerAnimationSequence(LayerAnimationElement* element,
+ TestLayerAnimationSequence(std::unique_ptr<LayerAnimationElement> element,
int* num_live_instances)
- : LayerAnimationSequence(element),
+ : LayerAnimationSequence(std::move(element)),
num_live_instances_(num_live_instances) {
(*num_live_instances_)++;
}
@@ -2106,8 +2107,9 @@ TEST(LayerAnimatorTest, SettingPropertyDuringAnAnimation) {
delegate.SetOpacityFromAnimation(start_opacity);
- std::unique_ptr<LayerAnimationSequence> sequence(new LayerAnimationSequence(
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
+ std::unique_ptr<LayerAnimationSequence> sequence =
+ base::MakeUnique<LayerAnimationSequence>(
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta));
animator->StartAnimation(sequence.release());
@@ -2140,10 +2142,10 @@ TEST(LayerAnimatorTest, ImmediatelySettingNewTargetDoesNotLeak) {
int num_live_instances = 0;
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- std::unique_ptr<TestLayerAnimationSequence> sequence(
- new TestLayerAnimationSequence(
+ std::unique_ptr<TestLayerAnimationSequence> sequence =
+ base::MakeUnique<TestLayerAnimationSequence>(
LayerAnimationElement::CreateBoundsElement(target_bounds, delta),
- &num_live_instances));
+ &num_live_instances);
EXPECT_EQ(1, num_live_instances);

Powered by Google App Engine
This is Rietveld 408576698