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

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

Issue 2383193002: TaskScheduler: Adjust shutdown behavior of delayed tasks. (Closed)
Patch Set: no copy 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 the shutdown behavior of a BLOCK_SHUTDOWN delayed task is
17 // adjusted to SKIP_ON_SHUTDOWN. The shutown behavior of other delayed tasks
18 // should not change.
19 TEST(TaskSchedulerTaskTest, NoShutdownBehaviorChangeNoDelay) {
20 Task continue_on_shutdown(FROM_HERE, Bind(&DoNothing),
21 TaskTraits().WithShutdownBehavior(
22 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
23 TimeDelta::FromSeconds(1));
24 EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
25 continue_on_shutdown.traits.shutdown_behavior());
26
27 Task skip_on_shutdown(
28 FROM_HERE, Bind(&DoNothing),
29 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
30 TimeDelta::FromSeconds(1));
31 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
32 skip_on_shutdown.traits.shutdown_behavior());
33
34 Task block_shutdown(
35 FROM_HERE, Bind(&DoNothing),
36 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
37 TimeDelta::FromSeconds(1));
38 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
39 block_shutdown.traits.shutdown_behavior());
40 }
41
42 // Verify that the shutdown behavior of undelayed tasks is not adjusted.
43 TEST(TaskSchedulerTaskTest, ShutdownBehaviorChangeWithDelay) {
gab 2016/10/03 16:59:53 The test names are backwards (i.e. this one should
fdoray 2016/10/03 17:10:15 Done.
44 Task continue_on_shutdown(FROM_HERE, Bind(&DoNothing),
45 TaskTraits().WithShutdownBehavior(
46 TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
47 TimeDelta());
48 EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
49 continue_on_shutdown.traits.shutdown_behavior());
50
51 Task skip_on_shutdown(
52 FROM_HERE, Bind(&DoNothing),
53 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
54 TimeDelta());
55 EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
56 skip_on_shutdown.traits.shutdown_behavior());
57
58 Task block_shutdown(
59 FROM_HERE, Bind(&DoNothing),
60 TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
61 TimeDelta());
62 EXPECT_EQ(TaskShutdownBehavior::BLOCK_SHUTDOWN,
63 block_shutdown.traits.shutdown_behavior());
64 }
65
66 } // namespace internal
67 } // 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