OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Tests of CancellationFlag class. | 5 // Tests of CancellationFlag class. |
6 | 6 |
7 #include "base/cancellation_flag.h" | 7 #include "base/synchronization/cancellation_flag.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/spin_wait.h" | 11 #include "base/spin_wait.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
16 | 16 |
17 using base::CancellationFlag; | 17 namespace base { |
18 using base::TimeDelta; | |
19 using base::Thread; | |
20 | 18 |
21 namespace { | 19 namespace { |
22 | 20 |
23 //------------------------------------------------------------------------------ | 21 //------------------------------------------------------------------------------ |
24 // Define our test class. | 22 // Define our test class. |
25 //------------------------------------------------------------------------------ | 23 //------------------------------------------------------------------------------ |
26 | 24 |
27 class CancelTask : public Task { | 25 class CancelTask : public Task { |
28 public: | 26 public: |
29 explicit CancelTask(CancellationFlag* flag) : flag_(flag) {} | 27 explicit CancelTask(CancellationFlag* flag) : flag_(flag) {} |
(...skipping 28 matching lines...) Expand all Loading... |
58 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); | 56 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); |
59 ASSERT_TRUE(t.Start()); | 57 ASSERT_TRUE(t.Start()); |
60 ASSERT_TRUE(t.message_loop()); | 58 ASSERT_TRUE(t.message_loop()); |
61 ASSERT_TRUE(t.IsRunning()); | 59 ASSERT_TRUE(t.IsRunning()); |
62 | 60 |
63 CancellationFlag flag; | 61 CancellationFlag flag; |
64 t.message_loop()->PostTask(FROM_HERE, new CancelTask(&flag)); | 62 t.message_loop()->PostTask(FROM_HERE, new CancelTask(&flag)); |
65 } | 63 } |
66 | 64 |
67 } // namespace | 65 } // namespace |
| 66 |
| 67 } // namespace base |
OLD | NEW |