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

Unified Diff: base/task_scheduler/task_unittest.cc

Issue 2383193002: TaskScheduler: Adjust shutdown behavior of delayed tasks. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« base/task_scheduler/task.cc ('K') | « base/task_scheduler/task.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/task_unittest.cc
diff --git a/base/task_scheduler/task_unittest.cc b/base/task_scheduler/task_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..95f8e72765a22bcaec3dbc51ba5ea9fe6fdfbf35
--- /dev/null
+++ b/base/task_scheduler/task_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/task_scheduler/task.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/task_scheduler/task_traits.h"
+#include "base/time/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+namespace internal {
+
+// 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.
+// behavior, the shutdown behavior is adjusted to SKIP_ON_SHUTDOWN.
+TEST(TaskSchedulerTaskTest, AdjustShutdownBehavior) {
+ Task continue_on_shutdown_no_delay(
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(
+ TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
+ TimeDelta());
+ EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
+ continue_on_shutdown_no_delay.traits.shutdown_behavior());
+ Task skip_on_shutdown_no_delay(
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
+ TimeDelta());
+ EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
+ skip_on_shutdown_no_delay.traits.shutdown_behavior());
+ Task block_shutdown_no_delay(
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
+ TimeDelta());
+ EXPECT_EQ(TaskShutdownBehavior::BLOCK_SHUTDOWN,
+ block_shutdown_no_delay.traits.shutdown_behavior());
+
+ Task continue_on_shutdown_delayed(
robliao 2016/09/30 18:57:20 This can be separated into two tests NoBehaviorCh
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(
+ TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
+ TimeDelta::FromSeconds(1));
+ EXPECT_EQ(TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN,
+ continue_on_shutdown_delayed.traits.shutdown_behavior());
+ Task skip_on_shutdown_delayed(
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
+ TimeDelta::FromSeconds(1));
+ EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
+ skip_on_shutdown_delayed.traits.shutdown_behavior());
+ Task block_shutdown_delayed(
+ FROM_HERE, Bind(&DoNothing),
+ TaskTraits().WithShutdownBehavior(TaskShutdownBehavior::BLOCK_SHUTDOWN),
+ TimeDelta::FromSeconds(1));
+ EXPECT_EQ(TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
+ block_shutdown_delayed.traits.shutdown_behavior());
+}
+
+} // namespace internal
+} // namespace base
« 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