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

Side by Side Diff: base/timer/timer_unittest.cc

Issue 866183002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 | « DEPS ('k') | build/all.gyp » ('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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 b.Start(); 182 b.Start();
183 183
184 base::MessageLoop::current()->Run(); 184 base::MessageLoop::current()->Run();
185 185
186 EXPECT_FALSE(did_run_a); 186 EXPECT_FALSE(did_run_a);
187 EXPECT_TRUE(did_run_b); 187 EXPECT_TRUE(did_run_b);
188 } 188 }
189 189
190 class DelayTimerTarget { 190 class DelayTimerTarget {
191 public: 191 public:
192 DelayTimerTarget()
193 : signaled_(false) {
194 }
195
196 bool signaled() const { return signaled_; } 192 bool signaled() const { return signaled_; }
197 193
198 void Signal() { 194 void Signal() {
199 ASSERT_FALSE(signaled_); 195 ASSERT_FALSE(signaled_);
200 signaled_ = true; 196 signaled_ = true;
201 } 197 }
202 198
203 private: 199 private:
204 bool signaled_; 200 bool signaled_ = false;
205 }; 201 };
206 202
207 void RunTest_DelayTimer_NoCall(base::MessageLoop::Type message_loop_type) { 203 void RunTest_DelayTimer_NoCall(base::MessageLoop::Type message_loop_type) {
208 base::MessageLoop loop(message_loop_type); 204 base::MessageLoop loop(message_loop_type);
209 205
210 // If Delay is never called, the timer shouldn't go off. 206 // If Delay is never called, the timer shouldn't go off.
211 DelayTimerTarget target; 207 DelayTimerTarget target;
212 base::DelayTimer<DelayTimerTarget> timer(FROM_HERE, 208 base::DelayTimer<DelayTimerTarget> timer(FROM_HERE,
213 TimeDelta::FromMilliseconds(1), &target, &DelayTimerTarget::Signal); 209 TimeDelta::FromMilliseconds(1), &target, &DelayTimerTarget::Signal);
214 210
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 base::Bind(&SetCallbackHappened1)); 528 base::Bind(&SetCallbackHappened1));
533 timer.Reset(); 529 timer.Reset();
534 // Since Reset happened before task ran, the user_task must not be cleared: 530 // Since Reset happened before task ran, the user_task must not be cleared:
535 ASSERT_FALSE(timer.user_task().is_null()); 531 ASSERT_FALSE(timer.user_task().is_null());
536 base::MessageLoop::current()->Run(); 532 base::MessageLoop::current()->Run();
537 EXPECT_TRUE(g_callback_happened1); 533 EXPECT_TRUE(g_callback_happened1);
538 } 534 }
539 } 535 }
540 536
541 } // namespace 537 } // namespace
OLDNEW
« no previous file with comments | « DEPS ('k') | build/all.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698