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

Side by Side Diff: base/callback_unittest.cc

Issue 2616403003: Replacing SurfaceReferenceBase and SequenceSurfaceReference with Closures (Closed)
Patch Set: callback unittest Created 3 years, 11 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 | « no previous file | cc/layers/surface_layer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/callback.h" 5 #include "base/callback.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Resetting should bring us back to empty. 108 // Resetting should bring us back to empty.
109 ASSERT_FALSE(callback_a_.is_null()); 109 ASSERT_FALSE(callback_a_.is_null());
110 ASSERT_FALSE(callback_a_.Equals(null_callback_)); 110 ASSERT_FALSE(callback_a_.Equals(null_callback_));
111 111
112 callback_a_.Reset(); 112 callback_a_.Reset();
113 113
114 EXPECT_TRUE(callback_a_.is_null()); 114 EXPECT_TRUE(callback_a_.is_null());
115 EXPECT_TRUE(callback_a_.Equals(null_callback_)); 115 EXPECT_TRUE(callback_a_.Equals(null_callback_));
116 } 116 }
117 117
118 TEST_F(CallbackTest, Move) {
119 // Moving should reset the callback
danakj 2017/01/11 16:21:37 comments get periods
120 ASSERT_FALSE(callback_a_.is_null());
121 ASSERT_FALSE(callback_a_.Equals(null_callback_));
122
123 auto tmp = std::move(callback_a_);
124
125 EXPECT_TRUE(callback_a_.is_null());
126 EXPECT_TRUE(callback_a_.Equals(null_callback_));
127 }
128
118 struct TestForReentrancy { 129 struct TestForReentrancy {
119 TestForReentrancy() 130 TestForReentrancy()
120 : cb_already_run(false), 131 : cb_already_run(false),
121 cb(Bind(&TestForReentrancy::AssertCBIsNull, Unretained(this))) { 132 cb(Bind(&TestForReentrancy::AssertCBIsNull, Unretained(this))) {
122 } 133 }
123 void AssertCBIsNull() { 134 void AssertCBIsNull() {
124 ASSERT_TRUE(cb.is_null()); 135 ASSERT_TRUE(cb.is_null());
125 cb_already_run = true; 136 cb_already_run = true;
126 } 137 }
127 bool cb_already_run; 138 bool cb_already_run;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 174
164 TEST_F(CallbackTest, CallbackHasLastRefOnContainingObject) { 175 TEST_F(CallbackTest, CallbackHasLastRefOnContainingObject) {
165 bool deleted = false; 176 bool deleted = false;
166 CallbackOwner* owner = new CallbackOwner(&deleted); 177 CallbackOwner* owner = new CallbackOwner(&deleted);
167 owner->Reset(); 178 owner->Reset();
168 ASSERT_TRUE(deleted); 179 ASSERT_TRUE(deleted);
169 } 180 }
170 181
171 } // namespace 182 } // namespace
172 } // namespace base 183 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | cc/layers/surface_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698