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

Side by Side Diff: ui/compositor/callback_layer_animation_observer_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « ui/chromeos/touch_exploration_controller_unittest.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/callback_layer_animation_observer.h" 5 #include "ui/compositor/callback_layer_animation_observer.h"
6 6
7 #include <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/ptr_util.h"
10 #include "base/memory/scoped_vector.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/compositor/layer_animation_sequence.h" 13 #include "ui/compositor/layer_animation_sequence.h"
13 #include "ui/compositor/test/layer_animation_observer_test_api.h" 14 #include "ui/compositor/test/layer_animation_observer_test_api.h"
14 15
15 namespace ui { 16 namespace ui {
16 namespace test { 17 namespace test {
17 18
18 // Simple class that tracks whether callbacks were invoked and when. 19 // Simple class that tracks whether callbacks were invoked and when.
19 class TestCallbacks { 20 class TestCallbacks {
20 public: 21 public:
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 class CallbackLayerAnimationObserverTest : public testing::Test { 213 class CallbackLayerAnimationObserverTest : public testing::Test {
213 public: 214 public:
214 CallbackLayerAnimationObserverTest(); 215 CallbackLayerAnimationObserverTest();
215 ~CallbackLayerAnimationObserverTest() override; 216 ~CallbackLayerAnimationObserverTest() override;
216 217
217 protected: 218 protected:
218 // Creates a LayerAnimationSequence. The lifetime of the sequence will be 219 // Creates a LayerAnimationSequence. The lifetime of the sequence will be
219 // managed by this. 220 // managed by this.
220 LayerAnimationSequence* CreateLayerAnimationSequence(); 221 LayerAnimationSequence* CreateLayerAnimationSequence();
221 222
222 scoped_ptr<TestCallbacks> callbacks_; 223 std::unique_ptr<TestCallbacks> callbacks_;
223 224
224 scoped_ptr<CallbackLayerAnimationObserver> observer_; 225 std::unique_ptr<CallbackLayerAnimationObserver> observer_;
225 226
226 scoped_ptr<LayerAnimationObserverTestApi> observer_test_api_; 227 std::unique_ptr<LayerAnimationObserverTestApi> observer_test_api_;
227 228
228 // List of managaged sequences created by CreateLayerAnimationSequence() that 229 // List of managaged sequences created by CreateLayerAnimationSequence() that
229 // need to be destroyed. 230 // need to be destroyed.
230 ScopedVector<LayerAnimationSequence> sequences_; 231 std::vector<std::unique_ptr<LayerAnimationSequence>> sequences_;
231 232
232 private: 233 private:
233 DISALLOW_COPY_AND_ASSIGN(CallbackLayerAnimationObserverTest); 234 DISALLOW_COPY_AND_ASSIGN(CallbackLayerAnimationObserverTest);
234 }; 235 };
235 236
236 CallbackLayerAnimationObserverTest::CallbackLayerAnimationObserverTest() 237 CallbackLayerAnimationObserverTest::CallbackLayerAnimationObserverTest()
237 : callbacks_(new TestCallbacks()), 238 : callbacks_(new TestCallbacks()),
238 observer_(new CallbackLayerAnimationObserver( 239 observer_(new CallbackLayerAnimationObserver(
239 base::Bind(&TestCallbacks::AnimationsStarted, 240 base::Bind(&TestCallbacks::AnimationsStarted,
240 base::Unretained(callbacks_.get())), 241 base::Unretained(callbacks_.get())),
241 base::Bind(&TestCallbacks::AnimationsEnded, 242 base::Bind(&TestCallbacks::AnimationsEnded,
242 base::Unretained(callbacks_.get())))), 243 base::Unretained(callbacks_.get())))),
243 observer_test_api_(new LayerAnimationObserverTestApi(observer_.get())) {} 244 observer_test_api_(new LayerAnimationObserverTestApi(observer_.get())) {}
244 245
245 CallbackLayerAnimationObserverTest::~CallbackLayerAnimationObserverTest() { 246 CallbackLayerAnimationObserverTest::~CallbackLayerAnimationObserverTest() {
246 observer_test_api_.reset(); 247 observer_test_api_.reset();
247 // The |observer_| will detach from all attached sequences upon destruction so 248 // The |observer_| will detach from all attached sequences upon destruction so
248 // we need to explicitly delete the |observer_| before the |sequences_| and 249 // we need to explicitly delete the |observer_| before the |sequences_| and
249 // |callbacks_|. 250 // |callbacks_|.
250 observer_.reset(); 251 observer_.reset();
251 } 252 }
252 253
253 LayerAnimationSequence* 254 LayerAnimationSequence*
254 CallbackLayerAnimationObserverTest::CreateLayerAnimationSequence() { 255 CallbackLayerAnimationObserverTest::CreateLayerAnimationSequence() {
255 LayerAnimationSequence* sequence = new LayerAnimationSequence(); 256 sequences_.emplace_back(new LayerAnimationSequence);
256 sequences_.push_back(sequence); 257 return sequences_.back().get();
257 return sequence;
258 } 258 }
259 259
260 TEST(CallbackLayerAnimationObserverDestructionTest, VerifyFalseAutoDelete) { 260 TEST(CallbackLayerAnimationObserverDestructionTest, VerifyFalseAutoDelete) {
261 TestCallbacks callbacks; 261 TestCallbacks callbacks;
262 callbacks.set_should_delete_observer_on_animations_ended(false); 262 callbacks.set_should_delete_observer_on_animations_ended(false);
263 263
264 bool is_destroyed = false; 264 bool is_destroyed = false;
265 265
266 TestCallbackLayerAnimationObserver* observer = 266 TestCallbackLayerAnimationObserver* observer =
267 new TestCallbackLayerAnimationObserver( 267 new TestCallbackLayerAnimationObserver(
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 observer_->OnLayerAnimationEnded(sequence_4); 579 observer_->OnLayerAnimationEnded(sequence_4);
580 580
581 EXPECT_FALSE(observer_->active()); 581 EXPECT_FALSE(observer_->active());
582 EXPECT_TRUE(callbacks_->animations_started()); 582 EXPECT_TRUE(callbacks_->animations_started());
583 EXPECT_TRUE(callbacks_->animations_ended()); 583 EXPECT_TRUE(callbacks_->animations_ended());
584 EXPECT_EQ(4, observer_->successful_count()); 584 EXPECT_EQ(4, observer_->successful_count());
585 } 585 }
586 586
587 } // namespace test 587 } // namespace test
588 } // namespace ui 588 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/touch_exploration_controller_unittest.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698