OLD | NEW |
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/lock.h" | 5 #include "base/lock.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
| 12 using base::kNullThreadHandle; |
| 13 using base::PlatformThread; |
| 14 using base::PlatformThreadHandle; |
| 15 |
12 typedef testing::Test LockTest; | 16 typedef testing::Test LockTest; |
13 | 17 |
14 // Basic test to make sure that Acquire()/Release()/Try() don't crash ---------- | 18 // Basic test to make sure that Acquire()/Release()/Try() don't crash ---------- |
15 | 19 |
16 class BasicLockTestThread : public PlatformThread::Delegate { | 20 class BasicLockTestThread : public PlatformThread::Delegate { |
17 public: | 21 public: |
18 BasicLockTestThread(Lock* lock) : lock_(lock), acquired_(0) {} | 22 BasicLockTestThread(Lock* lock) : lock_(lock), acquired_(0) {} |
19 | 23 |
20 virtual void ThreadMain() { | 24 virtual void ThreadMain() { |
21 for (int i = 0; i < 10; i++) { | 25 for (int i = 0; i < 10; i++) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 ASSERT_TRUE(PlatformThread::Create(0, &thread3, &handle3)); | 208 ASSERT_TRUE(PlatformThread::Create(0, &thread3, &handle3)); |
205 | 209 |
206 MutexLockTestThread::DoStuff(&lock, &value); | 210 MutexLockTestThread::DoStuff(&lock, &value); |
207 | 211 |
208 PlatformThread::Join(handle1); | 212 PlatformThread::Join(handle1); |
209 PlatformThread::Join(handle2); | 213 PlatformThread::Join(handle2); |
210 PlatformThread::Join(handle3); | 214 PlatformThread::Join(handle3); |
211 | 215 |
212 EXPECT_EQ(4 * 40, value); | 216 EXPECT_EQ(4 * 40, value); |
213 } | 217 } |
OLD | NEW |