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

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 9845037: Add SequencedWorkerPool.IsRunningSequenceOnCurrentThread so callers can make stronger assertions ab… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // triggered. This is a regression test for http://crbug.com/117469. 503 // triggered. This is a regression test for http://crbug.com/117469.
504 TEST_F(SequencedWorkerPoolTest, SpuriousWorkSignal) { 504 TEST_F(SequencedWorkerPoolTest, SpuriousWorkSignal) {
505 EnsureAllWorkersCreated(); 505 EnsureAllWorkersCreated();
506 int old_has_work_call_count = has_work_call_count(); 506 int old_has_work_call_count = has_work_call_count();
507 pool()->SignalHasWorkForTesting(); 507 pool()->SignalHasWorkForTesting();
508 // This is inherently racy, but can only produce false positives. 508 // This is inherently racy, but can only produce false positives.
509 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 509 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
510 EXPECT_EQ(old_has_work_call_count + 1, has_work_call_count()); 510 EXPECT_EQ(old_has_work_call_count + 1, has_work_call_count());
511 } 511 }
512 512
513 // TODO(michaeln): write a test for IsRunningSequenceOnCurrentThread
michaeln 2012/03/23 21:32:38 i'll add some tests if this method looks like a re
514
513 class SequencedWorkerPoolTaskRunnerTestDelegate { 515 class SequencedWorkerPoolTaskRunnerTestDelegate {
514 public: 516 public:
515 SequencedWorkerPoolTaskRunnerTestDelegate() {} 517 SequencedWorkerPoolTaskRunnerTestDelegate() {}
516 518
517 ~SequencedWorkerPoolTaskRunnerTestDelegate() {} 519 ~SequencedWorkerPoolTaskRunnerTestDelegate() {}
518 520
519 void StartTaskRunner() { 521 void StartTaskRunner() {
520 pool_owner_.reset( 522 pool_owner_.reset(
521 new SequencedWorkerPoolOwner(10, "SequencedWorkerPoolTaskRunnerTest")); 523 new SequencedWorkerPoolOwner(10, "SequencedWorkerPoolTaskRunnerTest"));
522 } 524 }
(...skipping 19 matching lines...) Expand all
542 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_; 544 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
543 }; 545 };
544 546
545 INSTANTIATE_TYPED_TEST_CASE_P( 547 INSTANTIATE_TYPED_TEST_CASE_P(
546 SequencedWorkerPool, TaskRunnerTest, 548 SequencedWorkerPool, TaskRunnerTest,
547 SequencedWorkerPoolTaskRunnerTestDelegate); 549 SequencedWorkerPoolTaskRunnerTestDelegate);
548 550
549 } // namespace 551 } // namespace
550 552
551 } // namespace base 553 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698