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

Side by Side Diff: webrtc/base/thread_unittest.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // There's no easy way to verify the name was set properly at this time. 236 // There's no easy way to verify the name was set properly at this time.
237 TEST(ThreadTest, Names) { 237 TEST(ThreadTest, Names) {
238 // Default name 238 // Default name
239 Thread *thread; 239 Thread *thread;
240 thread = new Thread(); 240 thread = new Thread();
241 EXPECT_TRUE(thread->Start()); 241 EXPECT_TRUE(thread->Start());
242 thread->Stop(); 242 thread->Stop();
243 delete thread; 243 delete thread;
244 thread = new Thread(); 244 thread = new Thread();
245 // Name with no object parameter 245 // Name with no object parameter
246 EXPECT_TRUE(thread->SetName("No object", NULL)); 246 EXPECT_TRUE(thread->SetName("No object", nullptr));
247 EXPECT_TRUE(thread->Start()); 247 EXPECT_TRUE(thread->Start());
248 thread->Stop(); 248 thread->Stop();
249 delete thread; 249 delete thread;
250 // Really long name 250 // Really long name
251 thread = new Thread(); 251 thread = new Thread();
252 EXPECT_TRUE(thread->SetName("Abcdefghijklmnopqrstuvwxyz1234567890", this)); 252 EXPECT_TRUE(thread->SetName("Abcdefghijklmnopqrstuvwxyz1234567890", this));
253 EXPECT_TRUE(thread->Start()); 253 EXPECT_TRUE(thread->Start());
254 thread->Stop(); 254 thread->Stop();
255 delete thread; 255 delete thread;
256 } 256 }
(...skipping 28 matching lines...) Expand all
285 }; 285 };
286 EXPECT_EQ(999, thread.Invoke<int>(RTC_FROM_HERE, &LocalFuncs::Func1)); 286 EXPECT_EQ(999, thread.Invoke<int>(RTC_FROM_HERE, &LocalFuncs::Func1));
287 thread.Invoke<void>(RTC_FROM_HERE, &LocalFuncs::Func2); 287 thread.Invoke<void>(RTC_FROM_HERE, &LocalFuncs::Func2);
288 } 288 }
289 289
290 // Verifies that two threads calling Invoke on each other at the same time does 290 // Verifies that two threads calling Invoke on each other at the same time does
291 // not deadlock. 291 // not deadlock.
292 TEST(ThreadTest, TwoThreadsInvokeNoDeadlock) { 292 TEST(ThreadTest, TwoThreadsInvokeNoDeadlock) {
293 AutoThread thread; 293 AutoThread thread;
294 Thread* current_thread = Thread::Current(); 294 Thread* current_thread = Thread::Current();
295 ASSERT_TRUE(current_thread != NULL); 295 ASSERT_TRUE(current_thread != nullptr);
296 296
297 Thread other_thread; 297 Thread other_thread;
298 other_thread.Start(); 298 other_thread.Start();
299 299
300 struct LocalFuncs { 300 struct LocalFuncs {
301 static void Set(bool* out) { *out = true; } 301 static void Set(bool* out) { *out = true; }
302 static void InvokeSet(Thread* thread, bool* out) { 302 static void InvokeSet(Thread* thread, bool* out) {
303 thread->Invoke<void>(RTC_FROM_HERE, Bind(&Set, out)); 303 thread->Invoke<void>(RTC_FROM_HERE, Bind(&Set, out));
304 } 304 }
305 }; 305 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 434 }
435 void SetExpectedThreadForIntCallback(Thread* thread) { 435 void SetExpectedThreadForIntCallback(Thread* thread) {
436 expected_thread_ = thread; 436 expected_thread_ = thread;
437 } 437 }
438 438
439 protected: 439 protected:
440 enum { kWaitTimeout = 1000 }; 440 enum { kWaitTimeout = 1000 };
441 AsyncInvokeTest() 441 AsyncInvokeTest()
442 : int_value_(0), 442 : int_value_(0),
443 invoke_started_(true, false), 443 invoke_started_(true, false),
444 expected_thread_(NULL) {} 444 expected_thread_(nullptr) {}
445 445
446 int int_value_; 446 int int_value_;
447 Event invoke_started_; 447 Event invoke_started_;
448 Thread* expected_thread_; 448 Thread* expected_thread_;
449 }; 449 };
450 450
451 TEST_F(AsyncInvokeTest, FireAndForget) { 451 TEST_F(AsyncInvokeTest, FireAndForget) {
452 AsyncInvoker invoker; 452 AsyncInvoker invoker;
453 // Create and start the thread. 453 // Create and start the thread.
454 Thread thread; 454 Thread thread;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 EXPECT_FALSE(flag1.get()); 744 EXPECT_FALSE(flag1.get());
745 EXPECT_TRUE(flag2.get()); 745 EXPECT_TRUE(flag2.get());
746 } 746 }
747 747
748 #if defined(WEBRTC_WIN) 748 #if defined(WEBRTC_WIN)
749 class ComThreadTest : public testing::Test, public MessageHandler { 749 class ComThreadTest : public testing::Test, public MessageHandler {
750 public: 750 public:
751 ComThreadTest() : done_(false) {} 751 ComThreadTest() : done_(false) {}
752 protected: 752 protected:
753 virtual void OnMessage(Message* message) { 753 virtual void OnMessage(Message* message) {
754 HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); 754 HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
755 // S_FALSE means the thread was already inited for a multithread apartment. 755 // S_FALSE means the thread was already inited for a multithread apartment.
756 EXPECT_EQ(S_FALSE, hr); 756 EXPECT_EQ(S_FALSE, hr);
757 if (SUCCEEDED(hr)) { 757 if (SUCCEEDED(hr)) {
758 CoUninitialize(); 758 CoUninitialize();
759 } 759 }
760 done_ = true; 760 done_ = true;
761 } 761 }
762 bool done_; 762 bool done_;
763 }; 763 };
764 764
765 TEST_F(ComThreadTest, ComInited) { 765 TEST_F(ComThreadTest, ComInited) {
766 Thread* thread = new ComThread(); 766 Thread* thread = new ComThread();
767 EXPECT_TRUE(thread->Start()); 767 EXPECT_TRUE(thread->Start());
768 thread->Post(RTC_FROM_HERE, this, 0); 768 thread->Post(RTC_FROM_HERE, this, 0);
769 EXPECT_TRUE_WAIT(done_, 1000); 769 EXPECT_TRUE_WAIT(done_, 1000);
770 delete thread; 770 delete thread;
771 } 771 }
772 #endif 772 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698