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

Side by Side Diff: base/task/cancelable_task_tracker_unittest.cc

Issue 2163023002: Unify usage of logging/assert macros in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix base/android/build_info.cc compile Created 4 years, 4 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
« no previous file with comments | « base/sequence_checker.h ('k') | base/task_scheduler/scheduler_worker_pool_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/task/cancelable_task_tracker.h" 5 #include "base/task/cancelable_task_tracker.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // debug mode. 337 // debug mode.
338 338
339 class CancelableTaskTrackerDeathTest : public CancelableTaskTrackerTest { 339 class CancelableTaskTrackerDeathTest : public CancelableTaskTrackerTest {
340 protected: 340 protected:
341 CancelableTaskTrackerDeathTest() { 341 CancelableTaskTrackerDeathTest() {
342 // The default style "fast" does not support multi-threaded tests. 342 // The default style "fast" does not support multi-threaded tests.
343 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 343 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
344 } 344 }
345 }; 345 };
346 346
347 // Duplicated from base/threading/thread_checker.h so that we can be
348 // good citizens there and undef the macro.
349 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
350 #define ENABLE_THREAD_CHECKER 1
351 #else
352 #define ENABLE_THREAD_CHECKER 0
353 #endif
354
355 // Runs |fn| with |task_tracker|, expecting it to crash in debug mode. 347 // Runs |fn| with |task_tracker|, expecting it to crash in debug mode.
356 void MaybeRunDeadlyTaskTrackerMemberFunction( 348 void MaybeRunDeadlyTaskTrackerMemberFunction(
357 CancelableTaskTracker* task_tracker, 349 CancelableTaskTracker* task_tracker,
358 const Callback<void(CancelableTaskTracker*)>& fn) { 350 const Callback<void(CancelableTaskTracker*)>& fn) {
359 // CancelableTask uses DCHECKs with its ThreadChecker (itself only 351 // CancelableTask uses DCHECKs with its ThreadChecker (itself only
360 // enabled in debug mode). 352 // enabled in debug mode).
361 #if ENABLE_THREAD_CHECKER 353 #if DCHECK_IS_ON()
362 EXPECT_DEATH_IF_SUPPORTED(fn.Run(task_tracker), ""); 354 EXPECT_DEATH_IF_SUPPORTED(fn.Run(task_tracker), "");
363 #endif 355 #endif
364 } 356 }
365 357
366 void PostDoNothingTask(CancelableTaskTracker* task_tracker) { 358 void PostDoNothingTask(CancelableTaskTracker* task_tracker) {
367 ignore_result(task_tracker->PostTask( 359 ignore_result(task_tracker->PostTask(
368 scoped_refptr<TestSimpleTaskRunner>(new TestSimpleTaskRunner()).get(), 360 scoped_refptr<TestSimpleTaskRunner>(new TestSimpleTaskRunner()).get(),
369 FROM_HERE, 361 FROM_HERE,
370 Bind(&DoNothing))); 362 Bind(&DoNothing)));
371 } 363 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 407
416 bad_thread.task_runner()->PostTask( 408 bad_thread.task_runner()->PostTask(
417 FROM_HERE, 409 FROM_HERE,
418 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_), 410 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_),
419 Bind(&CancelableTaskTracker::TryCancelAll))); 411 Bind(&CancelableTaskTracker::TryCancelAll)));
420 412
421 test_task_runner->RunUntilIdle(); 413 test_task_runner->RunUntilIdle();
422 } 414 }
423 415
424 } // namespace base 416 } // namespace base
OLDNEW
« no previous file with comments | « base/sequence_checker.h ('k') | base/task_scheduler/scheduler_worker_pool_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698