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

Side by Side Diff: base/task_scheduler/task_tracker_unittest.cc

Issue 2213933003: Change EXPECT/ASSERT_DCHECK_DEATH macro to not expose the |regex| parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b2b0_simplethreadJoinable
Patch Set: Fix SchedulerLock unittests to actually generate a DCHECK, not an exception 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_scheduler/task_tracker.h" 5 #include "base/task_scheduler/task_tracker.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED(); 347 WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED();
348 } 348 }
349 349
350 TEST_P(TaskSchedulerTaskTrackerTest, WillPostAfterShutdown) { 350 TEST_P(TaskSchedulerTaskTrackerTest, WillPostAfterShutdown) {
351 tracker_.Shutdown(); 351 tracker_.Shutdown();
352 352
353 std::unique_ptr<Task> task(CreateTask(GetParam())); 353 std::unique_ptr<Task> task(CreateTask(GetParam()));
354 354
355 // |task_tracker_| shouldn't allow a task to be posted after shutdown. 355 // |task_tracker_| shouldn't allow a task to be posted after shutdown.
356 if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN) { 356 if (GetParam() == TaskShutdownBehavior::BLOCK_SHUTDOWN) {
357 EXPECT_DCHECK_DEATH({ tracker_.WillPostTask(task.get()); }, ""); 357 EXPECT_DCHECK_DEATH({ tracker_.WillPostTask(task.get()); });
358 } else { 358 } else {
359 EXPECT_FALSE(tracker_.WillPostTask(task.get())); 359 EXPECT_FALSE(tracker_.WillPostTask(task.get()));
360 } 360 }
361 } 361 }
362 362
363 // Verify that BLOCK_SHUTDOWN and SKIP_ON_SHUTDOWN tasks can 363 // Verify that BLOCK_SHUTDOWN and SKIP_ON_SHUTDOWN tasks can
364 // AssertSingletonAllowed() but CONTINUE_ON_SHUTDOWN tasks can't. 364 // AssertSingletonAllowed() but CONTINUE_ON_SHUTDOWN tasks can't.
365 TEST_P(TaskSchedulerTaskTrackerTest, SingletonAllowed) { 365 TEST_P(TaskSchedulerTaskTrackerTest, SingletonAllowed) {
366 const bool can_use_singletons = 366 const bool can_use_singletons =
367 (GetParam() != TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN); 367 (GetParam() != TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN);
(...skipping 11 matching lines...) Expand all
379 379
380 // Running the task should fail iff the task isn't allowed to use singletons. 380 // Running the task should fail iff the task isn't allowed to use singletons.
381 if (can_use_singletons) { 381 if (can_use_singletons) {
382 tracker.RunNextTaskInSequence( 382 tracker.RunNextTaskInSequence(
383 CreateSequenceWithTask(std::move(task)).get()); 383 CreateSequenceWithTask(std::move(task)).get());
384 } else { 384 } else {
385 EXPECT_DCHECK_DEATH( 385 EXPECT_DCHECK_DEATH(
386 { 386 {
387 tracker.RunNextTaskInSequence( 387 tracker.RunNextTaskInSequence(
388 CreateSequenceWithTask(std::move(task)).get()); 388 CreateSequenceWithTask(std::move(task)).get());
389 }, 389 });
390 "");
391 } 390 }
392 } 391 }
393 392
394 static void RunTaskRunnerHandleVerificationTask( 393 static void RunTaskRunnerHandleVerificationTask(
395 TaskTracker* tracker, 394 TaskTracker* tracker,
396 std::unique_ptr<Task> verify_task) { 395 std::unique_ptr<Task> verify_task) {
397 // Pretend |verify_task| is posted to respect TaskTracker's contract. 396 // Pretend |verify_task| is posted to respect TaskTracker's contract.
398 EXPECT_TRUE(tracker->WillPostTask(verify_task.get())); 397 EXPECT_TRUE(tracker->WillPostTask(verify_task.get()));
399 398
400 // Confirm that the test conditions are right (no TaskRunnerHandles set 399 // Confirm that the test conditions are right (no TaskRunnerHandles set
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 638
640 // Unblock shutdown by running |block_shutdown_task|. 639 // Unblock shutdown by running |block_shutdown_task|.
641 tracker_.RunNextTaskInSequence( 640 tracker_.RunNextTaskInSequence(
642 CreateSequenceWithTask(std::move(block_shutdown_task)).get()); 641 CreateSequenceWithTask(std::move(block_shutdown_task)).get());
643 EXPECT_EQ(kLoadTestNumIterations + 1, NumTasksExecuted()); 642 EXPECT_EQ(kLoadTestNumIterations + 1, NumTasksExecuted());
644 WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED(); 643 WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED();
645 } 644 }
646 645
647 } // namespace internal 646 } // namespace internal
648 } // namespace base 647 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698