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

Side by Side Diff: chromeos/dbus/blocking_method_caller_unittest.cc

Issue 12092061: Code cleaning: Uses scoped_ptr<> to express ownership rather than writing ownership in comments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added chrome/browser/password_manager/native_backend_kwallet_x_unitte\ Created 7 years, 10 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 | Annotate | Revision Log
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "dbus/message.h" 10 #include "dbus/message.h"
(...skipping 21 matching lines...) Expand all
32 mock_bus_ = new dbus::MockBus(options); 32 mock_bus_ = new dbus::MockBus(options);
33 33
34 // Create a mock proxy. 34 // Create a mock proxy.
35 mock_proxy_ = new dbus::MockObjectProxy( 35 mock_proxy_ = new dbus::MockObjectProxy(
36 mock_bus_.get(), 36 mock_bus_.get(),
37 "org.chromium.TestService", 37 "org.chromium.TestService",
38 dbus::ObjectPath("/org/chromium/TestObject")); 38 dbus::ObjectPath("/org/chromium/TestObject"));
39 39
40 // Set an expectation so mock_proxy's CallMethodAndBlock() will use 40 // Set an expectation so mock_proxy's CallMethodAndBlock() will use
41 // CreateMockProxyResponse() to return responses. 41 // CreateMockProxyResponse() to return responses.
42 EXPECT_CALL(*mock_proxy_, CallMethodAndBlock(_, _)) 42 EXPECT_CALL(*mock_proxy_, MockCallMethodAndBlock(_, _))
43 .WillRepeatedly(Invoke( 43 .WillRepeatedly(Invoke(
44 this, &BlockingMethodCallerTest::CreateMockProxyResponse)); 44 this, &BlockingMethodCallerTest::CreateMockProxyResponse));
45 45
46 // Set an expectation so mock_bus's GetObjectProxy() for the given 46 // Set an expectation so mock_bus's GetObjectProxy() for the given
47 // service name and the object path will return mock_proxy_. 47 // service name and the object path will return mock_proxy_.
48 EXPECT_CALL(*mock_bus_, GetObjectProxy( 48 EXPECT_CALL(*mock_bus_, GetObjectProxy(
49 "org.chromium.TestService", 49 "org.chromium.TestService",
50 dbus::ObjectPath("/org/chromium/TestObject"))) 50 dbus::ObjectPath("/org/chromium/TestObject")))
51 .WillOnce(Return(mock_proxy_.get())); 51 .WillOnce(Return(mock_proxy_.get()));
52 52
(...skipping 18 matching lines...) Expand all
71 private: 71 private:
72 // Returns a response for the given method call. Used to implement 72 // Returns a response for the given method call. Used to implement
73 // CallMethodAndBlock() for |mock_proxy_|. 73 // CallMethodAndBlock() for |mock_proxy_|.
74 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call, 74 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call,
75 int timeout_ms) { 75 int timeout_ms) {
76 if (method_call->GetInterface() == "org.chromium.TestInterface" && 76 if (method_call->GetInterface() == "org.chromium.TestInterface" &&
77 method_call->GetMember() == "Echo") { 77 method_call->GetMember() == "Echo") {
78 dbus::MessageReader reader(method_call); 78 dbus::MessageReader reader(method_call);
79 std::string text_message; 79 std::string text_message;
80 if (reader.PopString(&text_message)) { 80 if (reader.PopString(&text_message)) {
81 dbus::Response* response = dbus::Response::CreateEmpty(); 81 scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty();
82 dbus::MessageWriter writer(response); 82 dbus::MessageWriter writer(response.get());
83 writer.AppendString(text_message); 83 writer.AppendString(text_message);
84 return response; 84 return response.release();
85 } 85 }
86 } 86 }
87 87
88 LOG(ERROR) << "Unexpected method call: " << method_call->ToString(); 88 LOG(ERROR) << "Unexpected method call: " << method_call->ToString();
89 return NULL; 89 return NULL;
90 } 90 }
91 91
92 // Runs the given task. 92 // Runs the given task.
93 void RunTask(const tracked_objects::Location& from_here, 93 void RunTask(const tracked_objects::Location& from_here,
94 const base::Closure& task) { 94 const base::Closure& task) {
(...skipping 21 matching lines...) Expand all
116 // Check the response. 116 // Check the response.
117 ASSERT_TRUE(response.get()); 117 ASSERT_TRUE(response.get());
118 dbus::MessageReader reader(response.get()); 118 dbus::MessageReader reader(response.get());
119 std::string text_message; 119 std::string text_message;
120 ASSERT_TRUE(reader.PopString(&text_message)); 120 ASSERT_TRUE(reader.PopString(&text_message));
121 // The text message should be echo'ed back. 121 // The text message should be echo'ed back.
122 EXPECT_EQ(kHello, text_message); 122 EXPECT_EQ(kHello, text_message);
123 } 123 }
124 124
125 } // namespace chromeos 125 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/blocking_method_caller.cc ('k') | chromeos/dbus/bluetooth_agent_service_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698