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_unittest.cc

Issue 2383193002: TaskScheduler: Adjust shutdown behavior of delayed tasks. (Closed)
Patch Set: Created 4 years, 2 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
« base/task_scheduler/task.cc ('K') | « base/task_scheduler/task.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/task_scheduler/task.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/task_scheduler/task_traits.h"
10 #include "base/time/time.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace base {
14 namespace internal {
15
16 // Verify that iff a task is created with a delay and a BLOCK_SHUTDOWN shutdown
robliao 2016/09/30 18:57:20 s/iff/if/
fdoray 2016/10/03 15:43:30 Done.
17 // behavior, the shutdown behavior is adjusted to SKIP_ON_SHUTDOWN.
18 TEST(TaskSchedulerTaskTest, AdjustShutdownBehavior) {
19 Task continue_on_shutdown_no_delay(
20 FROM_HERE, Bind(&DoNothing),
21 TaskTraits().WithShutdownBehavior(
22 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
23 TimeDelta());
24 EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
25 continue_on_shutdown_no_delay.traits.shutdown_behavior());
26 Task skip_on_shutdown_no_delay(
27 FROM_HERE, Bind(&DoNothing),
28 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
29 TimeDelta());
30 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
31 skip_on_shutdown_no_delay.traits.shutdown_behavior());
32 Task block_shutdown_no_delay(
33 FROM_HERE, Bind(&DoNothing),
34 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
35 TimeDelta());
36 EXPECT_EQ(TaskShutdownBehavior::BLOCK_SHUTDOWN,
37 block_shutdown_no_delay.traits.shutdown_behavior());
38
39 Task continue_on_shutdown_delayed(
robliao 2016/09/30 18:57:20 This can be separated into two tests NoBehaviorCh
40 FROM_HERE, Bind(&DoNothing),
41 TaskTraits().WithShutdownBehavior(
42 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
43 TimeDelta::FromSeconds(1));
44 EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
45 continue_on_shutdown_delayed.traits.shutdown_behavior());
46 Task skip_on_shutdown_delayed(
47 FROM_HERE, Bind(&DoNothing),
48 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
49 TimeDelta::FromSeconds(1));
50 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
51 skip_on_shutdown_delayed.traits.shutdown_behavior());
52 Task block_shutdown_delayed(
53 FROM_HERE, Bind(&DoNothing),
54 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
55 TimeDelta::FromSeconds(1));
56 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
57 block_shutdown_delayed.traits.shutdown_behavior());
58 }
59
60 } // namespace internal
61 } // namespace base
OLDNEW
« base/task_scheduler/task.cc ('K') | « base/task_scheduler/task.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698