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

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

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 years, 8 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
« no previous file with comments | « chrome/browser/memory/tab_manager_unittest.cc ('k') | chromeos/dbus/blocking_method_caller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace chromecast { 21 namespace chromecast {
21 22
22 namespace { 23 namespace {
23 24
24 class SequencedTaskRunnerNoDelay : public base::SequencedTaskRunner { 25 class SequencedTaskRunnerNoDelay : public base::SequencedTaskRunner {
25 public: 26 public:
26 SequencedTaskRunnerNoDelay() {} 27 SequencedTaskRunnerNoDelay() {}
27 28
28 // base::SequencedTaskRunner implementation: 29 // base::SequencedTaskRunner implementation:
29 bool PostDelayedTask(const tracked_objects::Location& from_here, 30 bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task, 31 base::Closure task,
31 base::TimeDelta delay) override { 32 base::TimeDelta delay) override {
32 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, task); 33 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, std::move(task));
33 return true; 34 return true;
34 } 35 }
35 36
36 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 37 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
37 const base::Closure& task, 38 base::Closure task,
38 base::TimeDelta delay) override { 39 base::TimeDelta delay) override {
39 return true; 40 return true;
40 } 41 }
41 42
42 bool RunsTasksOnCurrentThread() const override { return true; } 43 bool RunsTasksOnCurrentThread() const override { return true; }
43 44
44 private: 45 private:
45 ~SequencedTaskRunnerNoDelay() override {} 46 ~SequencedTaskRunnerNoDelay() override {}
46 47
47 DISALLOW_COPY_AND_ASSIGN(SequencedTaskRunnerNoDelay); 48 DISALLOW_COPY_AND_ASSIGN(SequencedTaskRunnerNoDelay);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 RunPendingTasks(); 208 RunPendingTasks();
208 EXPECT_EQ(0, observer_->num_time_changed()); 209 EXPECT_EQ(0, observer_->num_time_changed());
209 210
210 // Time change detected. Expected = now - 20 + 1, actual = now - 20. 211 // Time change detected. Expected = now - 20 + 1, actual = now - 20.
211 notifier_->set_fake_now_for_testing(now - base::TimeDelta::FromSeconds(20)); 212 notifier_->set_fake_now_for_testing(now - base::TimeDelta::FromSeconds(20));
212 RunPendingTasks(); 213 RunPendingTasks();
213 EXPECT_EQ(0, observer_->num_time_changed()); 214 EXPECT_EQ(0, observer_->num_time_changed());
214 } 215 }
215 216
216 } // namespace chromecast 217 } // namespace chromecast
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager_unittest.cc ('k') | chromeos/dbus/blocking_method_caller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698