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

Side by Side Diff: chromeos/dbus/blocking_method_caller_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 | « chromeos/dbus/blocking_method_caller.h ('k') | chromeos/tpm/tpm_token_info_getter_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/dbus/blocking_method_caller.h" 5 #include "chromeos/dbus/blocking_method_caller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/task_runner.h" 12 #include "base/task_runner.h"
12 #include "dbus/message.h" 13 #include "dbus/message.h"
13 #include "dbus/mock_bus.h" 14 #include "dbus/mock_bus.h"
14 #include "dbus/mock_object_proxy.h" 15 #include "dbus/mock_object_proxy.h"
15 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using ::testing::_; 20 using ::testing::_;
20 using ::testing::Invoke; 21 using ::testing::Invoke;
21 using ::testing::Return; 22 using ::testing::Return;
22 23
23 namespace chromeos { 24 namespace chromeos {
24 25
25 namespace { 26 namespace {
26 27
27 class FakeTaskRunner : public base::TaskRunner { 28 class FakeTaskRunner : public base::TaskRunner {
28 public: 29 public:
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 task.Run(); 33 std::move(task).Run();
33 return true; 34 return true;
34 } 35 }
35 bool RunsTasksOnCurrentThread() const override { return true; } 36 bool RunsTasksOnCurrentThread() const override { return true; }
36 37
37 protected: 38 protected:
38 ~FakeTaskRunner() override {} 39 ~FakeTaskRunner() override {}
39 }; 40 };
40 41
41 } // namespace 42 } // namespace
42 43
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Check the response. 130 // Check the response.
130 ASSERT_TRUE(response.get()); 131 ASSERT_TRUE(response.get());
131 dbus::MessageReader reader(response.get()); 132 dbus::MessageReader reader(response.get());
132 std::string text_message; 133 std::string text_message;
133 ASSERT_TRUE(reader.PopString(&text_message)); 134 ASSERT_TRUE(reader.PopString(&text_message));
134 // The text message should be echo'ed back. 135 // The text message should be echo'ed back.
135 EXPECT_EQ(kHello, text_message); 136 EXPECT_EQ(kHello, text_message);
136 } 137 }
137 138
138 } // namespace chromeos 139 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/blocking_method_caller.h ('k') | chromeos/tpm/tpm_token_info_getter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698