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(); | |
67 } | 66 } |
68 | 67 |
69 protected: | 68 protected: |
70 base::Thread* other_thread() { return &other_thread_; } | 69 base::Thread* other_thread() { return &other_thread_; } |
71 | 70 |
72 const scoped_refptr<SequencedWorkerPool>& pool() { | 71 const scoped_refptr<SequencedWorkerPool>& pool() { |
73 return pool_owner_->pool(); | 72 return pool_owner_->pool(); |
74 } | 73 } |
75 | 74 |
76 void PostDoStuffToWorkerPool(SequenceCheckedObject* sequence_checked_object, | 75 void PostDoStuffToWorkerPool(SequenceCheckedObject* sequence_checked_object, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 PostDoStuffToWorkerPool(sequence_checked_object.get(), "A"); | 298 PostDoStuffToWorkerPool(sequence_checked_object.get(), "A"); |
300 pool()->FlushForTesting(); | 299 pool()->FlushForTesting(); |
301 | 300 |
302 SequencedWorkerPoolOwner second_pool_owner(kNumWorkerThreads, "test2"); | 301 SequencedWorkerPoolOwner second_pool_owner(kNumWorkerThreads, "test2"); |
303 second_pool_owner.pool()->PostNamedSequencedWorkerTask( | 302 second_pool_owner.pool()->PostNamedSequencedWorkerTask( |
304 "A", | 303 "A", |
305 FROM_HERE, | 304 FROM_HERE, |
306 base::Bind(&SequenceCheckedObject::DoStuff, | 305 base::Bind(&SequenceCheckedObject::DoStuff, |
307 base::Unretained(sequence_checked_object.get()))); | 306 base::Unretained(sequence_checked_object.get()))); |
308 second_pool_owner.pool()->FlushForTesting(); | 307 second_pool_owner.pool()->FlushForTesting(); |
309 second_pool_owner.pool()->Shutdown(); | |
310 } | 308 } |
311 | 309 |
312 #if ENABLE_SEQUENCE_CHECKER | 310 #if ENABLE_SEQUENCE_CHECKER |
313 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInDebug) { | 311 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInDebug) { |
314 // The default style "fast" does not support multi-threaded tests. | 312 // The default style "fast" does not support multi-threaded tests. |
315 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 313 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
316 ASSERT_DEATH({ | 314 ASSERT_DEATH({ |
317 TwoDifferentWorkerPoolsDeathTest(); | 315 TwoDifferentWorkerPoolsDeathTest(); |
318 }, ""); | 316 }, ""); |
319 } | 317 } |
320 #else | 318 #else |
321 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInRelease) { | 319 TEST_F(SequenceCheckerTest, TwoDifferentWorkerPoolsDeathTestInRelease) { |
322 TwoDifferentWorkerPoolsDeathTest(); | 320 TwoDifferentWorkerPoolsDeathTest(); |
323 } | 321 } |
324 #endif // ENABLE_SEQUENCE_CHECKER | 322 #endif // ENABLE_SEQUENCE_CHECKER |
325 | 323 |
326 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_SEQUENCE_CHECKER | 324 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_SEQUENCE_CHECKER |
327 | 325 |
328 } // namespace | 326 } // namespace |
329 | 327 |
330 } // namespace base | 328 } // namespace base |
331 | 329 |
332 // Just in case we ever get lumped together with other compilation units. | 330 // Just in case we ever get lumped together with other compilation units. |
333 #undef ENABLE_SEQUENCE_CHECKER | 331 #undef ENABLE_SEQUENCE_CHECKER |
OLD | NEW |