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

Side by Side Diff: chromecast/base/system_time_change_notifier_unittest.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/base/system_time_change_notifier.h" 5 #include "chromecast/base/system_time_change_notifier.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace chromecast { 20 namespace chromecast {
21 21
22 namespace { 22 namespace {
23 23
24 class SequencedTaskRunnerNoDelay : public base::SequencedTaskRunner { 24 class SequencedTaskRunnerNoDelay : public base::SequencedTaskRunner {
25 public: 25 public:
26 SequencedTaskRunnerNoDelay() {} 26 SequencedTaskRunnerNoDelay() {}
27 27
28 // base::SequencedTaskRunner implementation: 28 // base::SequencedTaskRunner implementation:
29 bool PostDelayedTask(const tracked_objects::Location& from_here, 29 bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task, 30 base::OnceClosure task,
31 base::TimeDelta delay) override { 31 base::TimeDelta delay) override {
32 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, task); 32 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, std::move(task));
33 return true; 33 return true;
34 } 34 }
35 35
36 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 36 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
37 const base::Closure& task, 37 base::OnceClosure task,
38 base::TimeDelta delay) override { 38 base::TimeDelta delay) override {
39 return true; 39 return true;
40 } 40 }
41 41
42 bool RunsTasksOnCurrentThread() const override { return true; } 42 bool RunsTasksOnCurrentThread() const override { return true; }
43 43
44 private: 44 private:
45 ~SequencedTaskRunnerNoDelay() override {} 45 ~SequencedTaskRunnerNoDelay() override {}
46 46
47 DISALLOW_COPY_AND_ASSIGN(SequencedTaskRunnerNoDelay); 47 DISALLOW_COPY_AND_ASSIGN(SequencedTaskRunnerNoDelay);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 RunPendingTasks(); 207 RunPendingTasks();
208 EXPECT_EQ(0, observer_->num_time_changed()); 208 EXPECT_EQ(0, observer_->num_time_changed());
209 209
210 // Time change detected. Expected = now - 20 + 1, actual = now - 20. 210 // Time change detected. Expected = now - 20 + 1, actual = now - 20.
211 notifier_->set_fake_now_for_testing(now - base::TimeDelta::FromSeconds(20)); 211 notifier_->set_fake_now_for_testing(now - base::TimeDelta::FromSeconds(20));
212 RunPendingTasks(); 212 RunPendingTasks();
213 EXPECT_EQ(0, observer_->num_time_changed()); 213 EXPECT_EQ(0, observer_->num_time_changed());
214 } 214 }
215 215
216 } // namespace chromecast 216 } // namespace chromecast
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager_unittest.cc ('k') | chromeos/dbus/blocking_method_caller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698