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

Side by Side Diff: base/threading/platform_thread_unittest.cc

Issue 9055001: Change code in base (primarily unit tests) to use Sleep(TimeDelta). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Qualify windows Sleep calls to go through PlatformThread. Created 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Tests of basic thread functions --------------------------------------------- 53 // Tests of basic thread functions ---------------------------------------------
54 54
55 class FunctionTestThread : public TrivialThread { 55 class FunctionTestThread : public TrivialThread {
56 public: 56 public:
57 FunctionTestThread() : thread_id_(0) {} 57 FunctionTestThread() : thread_id_(0) {}
58 58
59 virtual void ThreadMain() { 59 virtual void ThreadMain() {
60 thread_id_ = PlatformThread::CurrentId(); 60 thread_id_ = PlatformThread::CurrentId();
61 PlatformThread::YieldCurrentThread(); 61 PlatformThread::YieldCurrentThread();
62 PlatformThread::Sleep(50); 62 PlatformThread::Sleep(TimeDelta::FromMilliseconds(50));
63 63
64 TrivialThread::ThreadMain(); 64 TrivialThread::ThreadMain();
65 } 65 }
66 66
67 PlatformThreadId thread_id() const { return thread_id_; } 67 PlatformThreadId thread_id() const { return thread_id_; }
68 68
69 private: 69 private:
70 PlatformThreadId thread_id_; 70 PlatformThreadId thread_id_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(FunctionTestThread); 72 DISALLOW_COPY_AND_ASSIGN(FunctionTestThread);
(...skipping 24 matching lines...) Expand all
97 ASSERT_TRUE(PlatformThread::Create(0, &thread[n], &handle[n])); 97 ASSERT_TRUE(PlatformThread::Create(0, &thread[n], &handle[n]));
98 for (size_t n = 0; n < arraysize(thread); n++) 98 for (size_t n = 0; n < arraysize(thread); n++)
99 PlatformThread::Join(handle[n]); 99 PlatformThread::Join(handle[n]);
100 for (size_t n = 0; n < arraysize(thread); n++) { 100 for (size_t n = 0; n < arraysize(thread); n++) {
101 ASSERT_TRUE(thread[n].did_run()); 101 ASSERT_TRUE(thread[n].did_run());
102 EXPECT_NE(thread[n].thread_id(), main_thread_id); 102 EXPECT_NE(thread[n].thread_id(), main_thread_id);
103 } 103 }
104 } 104 }
105 105
106 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_watcher_unittest.cc ('k') | base/threading/thread_collision_warner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698