OLD | NEW |
1 // Copyright (c) 2011 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/synchronization/cancellation_flag.h" | 7 #include "base/synchronization/cancellation_flag.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
12 #include "base/single_thread_task_runner.h" | 11 #include "base/message_loop/message_loop.h" |
13 #include "base/synchronization/spin_wait.h" | 12 #include "base/synchronization/spin_wait.h" |
14 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
18 | 17 |
19 namespace base { | 18 namespace base { |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
(...skipping 27 matching lines...) Expand all Loading... |
50 // Checks that Set() can't be called from any other thread. | 49 // Checks that Set() can't be called from any other thread. |
51 // CancellationFlag should die on a DCHECK if Set() is called from | 50 // CancellationFlag should die on a DCHECK if Set() is called from |
52 // other thread. | 51 // other thread. |
53 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 52 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
54 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); | 53 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); |
55 ASSERT_TRUE(t.Start()); | 54 ASSERT_TRUE(t.Start()); |
56 ASSERT_TRUE(t.message_loop()); | 55 ASSERT_TRUE(t.message_loop()); |
57 ASSERT_TRUE(t.IsRunning()); | 56 ASSERT_TRUE(t.IsRunning()); |
58 | 57 |
59 CancellationFlag flag; | 58 CancellationFlag flag; |
60 t.task_runner()->PostTask(FROM_HERE, base::Bind(&CancelHelper, &flag)); | 59 t.message_loop()->PostTask(FROM_HERE, base::Bind(&CancelHelper, &flag)); |
61 } | 60 } |
62 | 61 |
63 } // namespace | 62 } // namespace |
64 | 63 |
65 } // namespace base | 64 } // namespace base |
OLD | NEW |