OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 public: | 56 public: |
57 SequenceCheckerTest() : other_thread_("sequence_checker_test_other_thread") {} | 57 SequenceCheckerTest() : other_thread_("sequence_checker_test_other_thread") {} |
58 | 58 |
59 void SetUp() override { | 59 void SetUp() override { |
60 other_thread_.Start(); | 60 other_thread_.Start(); |
61 ResetPool(); | 61 ResetPool(); |
62 } | 62 } |
63 | 63 |
64 void TearDown() override { | 64 void TearDown() override { |
65 other_thread_.Stop(); | 65 other_thread_.Stop(); |
| 66 pool()->Shutdown(); |
66 } | 67 } |
67 | 68 |
68 protected: | 69 protected: |
69 base::Thread* other_thread() { return &other_thread_; } | 70 base::Thread* other_thread() { return &other_thread_; } |
70 | 71 |
71 const scoped_refptr<SequencedWorkerPool>& pool() { | 72 const scoped_refptr<SequencedWorkerPool>& pool() { |
72 return pool_owner_->pool(); | 73 return pool_owner_->pool(); |
73 } | 74 } |
74 | 75 |
75 void PostDoStuffToWorkerPool(SequenceCheckedObject* sequence_checked_object, | 76 void PostDoStuffToWorkerPool(SequenceCheckedObject* sequence_checked_object, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 PostDoStuffToWorkerPool(sequence_checked_object.get(), "A"); | 299 PostDoStuffToWorkerPool(sequence_checked_object.get(), "A"); |
299 pool()->FlushForTesting(); | 300 pool()->FlushForTesting(); |
300 | 301 |
301 SequencedWorkerPoolOwner second_pool_owner(kNumWorkerThreads, "test2"); | 302 SequencedWorkerPoolOwner second_pool_owner(kNumWorkerThreads, "test2"); |
302 second_pool_owner.pool()->PostNamedSequencedWorkerTask( | 303 second_pool_owner.pool()->PostNamedSequencedWorkerTask( |
303 "A", | 304 "A", |
304 FROM_HERE, | 305 FROM_HERE, |
305 base::Bind(&SequenceCheckedObject::DoStuff, | 306 base::Bind(&SequenceCheckedObject::DoStuff, |
306 base::Unretained(sequence_checked_object.get()))); | 307 base::Unretained(sequence_checked_object.get()))); |
307 second_pool_owner.pool()->FlushForTesting(); | 308 second_pool_owner.pool()->FlushForTesting(); |
| 309 second_pool_owner.pool()->Shutdown(); |
308 } | 310 } |
309 | 311 |
310 #if ENABLE_SEQUENCE_CHECKER | 312 #if ENABLE_SEQUENCE_CHECKER |
311 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInDebug) { | 313 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInDebug) { |
312 // The default style "fast" does not support multi-threaded tests. | 314 // The default style "fast" does not support multi-threaded tests. |
313 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 315 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
314 ASSERT_DEATH({ | 316 ASSERT_DEATH({ |
315 TwoDifferentWorkerPoolsDeathTest(); | 317 TwoDifferentWorkerPoolsDeathTest(); |
316 }, ""); | 318 }, ""); |
317 } | 319 } |
318 #else | 320 #else |
319 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInRelease) { | 321 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInRelease) { |
320 TwoDifferentWorkerPoolsDeathTest(); | 322 TwoDifferentWorkerPoolsDeathTest(); |
321 } | 323 } |
322 #endif // ENABLE_SEQUENCE_CHECKER | 324 #endif // ENABLE_SEQUENCE_CHECKER |
323 | 325 |
324 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_SEQUENCE_CHECKER | 326 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_SEQUENCE_CHECKER |
325 | 327 |
326 } // namespace | 328 } // namespace |
327 | 329 |
328 } // namespace base | 330 } // namespace base |
329 | 331 |
330 // Just in case we ever get lumped together with other compilation units. | 332 // Just in case we ever get lumped together with other compilation units. |
331 #undef ENABLE_SEQUENCE_CHECKER | 333 #undef ENABLE_SEQUENCE_CHECKER |
OLD | NEW |