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

Side by Side Diff: mojo/edk/util/mutex_unittest.cc

Issue 1420713006: Revert "EDK: Move //mojo/edk/system/waitable_event* to edk/util." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/edk/util/cond_var_unittest.cc ('k') | mojo/edk/util/ref_counted_perftest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/edk/util/mutex.h" 5 #include "mojo/edk/util/mutex.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <thread> 9 #include <thread>
10 10
11 #include "mojo/edk/system/test/sleep.h" 11 #include "mojo/edk/system/test/sleep.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 using mojo::system::test::SleepMilliseconds;
15
16 namespace mojo { 14 namespace mojo {
17 namespace util { 15 namespace util {
18 namespace { 16 namespace {
19 17
20 // Sleeps for a "very small" amount of time. 18 // Sleeps for a "very small" amount of time.
21 void EpsilonRandomSleep() { 19 void EpsilonRandomSleep() {
22 SleepMilliseconds(static_cast<unsigned>(rand()) % 20u); 20 system::test::SleepMilliseconds(static_cast<unsigned>(rand()) % 20u);
23 } 21 }
24 22
25 // Basic test to make sure that Lock()/Unlock()/TryLock() don't crash ---------- 23 // Basic test to make sure that Lock()/Unlock()/TryLock() don't crash ----------
26 24
27 TEST(MutexTest, Basic) { 25 TEST(MutexTest, Basic) {
28 Mutex mutex; 26 Mutex mutex;
29 27
30 int thread_acquired = 0; 28 int thread_acquired = 0;
31 auto thread = std::thread([&mutex, &thread_acquired]() { 29 auto thread = std::thread([&mutex, &thread_acquired]() {
32 for (int i = 0; i < 10; i++) { 30 for (int i = 0; i < 10; i++) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 192
195 // The destruction of |locker| should unlock |mutex|. 193 // The destruction of |locker| should unlock |mutex|.
196 ASSERT_TRUE(mutex.TryLock()); 194 ASSERT_TRUE(mutex.TryLock());
197 mutex.AssertHeld(); 195 mutex.AssertHeld();
198 mutex.Unlock(); 196 mutex.Unlock();
199 } 197 }
200 198
201 } // namespace 199 } // namespace
202 } // namespace util 200 } // namespace util
203 } // namespace mojo 201 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/util/cond_var_unittest.cc ('k') | mojo/edk/util/ref_counted_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698