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

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: s/base::ResetAndReturn/std::move/ Created 3 years, 9 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 (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"
10 #include "base/callback_helpers.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/task_runner.h" 13 #include "base/task_runner.h"
12 #include "dbus/message.h" 14 #include "dbus/message.h"
13 #include "dbus/mock_bus.h" 15 #include "dbus/mock_bus.h"
14 #include "dbus/mock_object_proxy.h" 16 #include "dbus/mock_object_proxy.h"
15 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
16 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 20
19 using ::testing::_; 21 using ::testing::_;
20 using ::testing::Invoke; 22 using ::testing::Invoke;
21 using ::testing::Return; 23 using ::testing::Return;
22 24
23 namespace chromeos { 25 namespace chromeos {
24 26
25 namespace { 27 namespace {
26 28
27 class FakeTaskRunner : public base::TaskRunner { 29 class FakeTaskRunner : public base::TaskRunner {
28 public: 30 public:
29 bool PostDelayedTask(const tracked_objects::Location& from_here, 31 bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task, 32 base::Closure task,
31 base::TimeDelta delay) override { 33 base::TimeDelta delay) override {
32 task.Run(); 34 std::move(task).Run();
33 return true; 35 return true;
34 } 36 }
35 bool RunsTasksOnCurrentThread() const override { return true; } 37 bool RunsTasksOnCurrentThread() const override { return true; }
36 38
37 protected: 39 protected:
38 ~FakeTaskRunner() override {} 40 ~FakeTaskRunner() override {}
39 }; 41 };
40 42
41 } // namespace 43 } // namespace
42 44
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Check the response. 131 // Check the response.
130 ASSERT_TRUE(response.get()); 132 ASSERT_TRUE(response.get());
131 dbus::MessageReader reader(response.get()); 133 dbus::MessageReader reader(response.get());
132 std::string text_message; 134 std::string text_message;
133 ASSERT_TRUE(reader.PopString(&text_message)); 135 ASSERT_TRUE(reader.PopString(&text_message));
134 // The text message should be echo'ed back. 136 // The text message should be echo'ed back.
135 EXPECT_EQ(kHello, text_message); 137 EXPECT_EQ(kHello, text_message);
136 } 138 }
137 139
138 } // namespace chromeos 140 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698