summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/blocking_method_caller.cc8
-rw-r--r--chromeos/dbus/blocking_method_caller.h6
-rw-r--r--chromeos/dbus/blocking_method_caller_unittest.cc8
-rw-r--r--chromeos/dbus/bluetooth_agent_service_provider.cc71
-rw-r--r--chromeos/dbus/ibus/ibus_engine_factory_service.cc8
-rw-r--r--chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc22
-rw-r--r--chromeos/dbus/ibus/ibus_engine_service.cc42
-rw-r--r--chromeos/dbus/ibus/ibus_engine_service_unittest.cc60
-rw-r--r--chromeos/dbus/ibus/ibus_panel_service.cc27
-rw-r--r--chromeos/dbus/ibus/ibus_panel_service_unittest.cc23
-rw-r--r--chromeos/dbus/shill_client_unittest_base.cc4
11 files changed, 136 insertions, 143 deletions
diff --git a/chromeos/dbus/blocking_method_caller.cc b/chromeos/dbus/blocking_method_caller.cc
index 91c796c..5fc0c9a 100644
--- a/chromeos/dbus/blocking_method_caller.cc
+++ b/chromeos/dbus/blocking_method_caller.cc
@@ -15,7 +15,7 @@ namespace {
// This function is a part of CallMethodAndBlock implementation.
void CallMethodAndBlockInternal(
- dbus::Response** response,
+ scoped_ptr<dbus::Response>* response,
base::ScopedClosureRunner* signaler,
dbus::ObjectProxy* proxy,
dbus::MethodCall* method_call) {
@@ -36,7 +36,7 @@ BlockingMethodCaller::BlockingMethodCaller(dbus::Bus* bus,
BlockingMethodCaller::~BlockingMethodCaller() {
}
-dbus::Response* BlockingMethodCaller::CallMethodAndBlock(
+scoped_ptr<dbus::Response> BlockingMethodCaller::CallMethodAndBlock(
dbus::MethodCall* method_call) {
// on_blocking_method_call_->Signal() will be called when |signaler| is
// destroyed.
@@ -46,7 +46,7 @@ dbus::Response* BlockingMethodCaller::CallMethodAndBlock(
base::ScopedClosureRunner* signaler =
new base::ScopedClosureRunner(signal_task);
- dbus::Response* response = NULL;
+ scoped_ptr<dbus::Response> response;
bus_->PostTaskToDBusThread(
FROM_HERE,
base::Bind(&CallMethodAndBlockInternal,
@@ -57,7 +57,7 @@ dbus::Response* BlockingMethodCaller::CallMethodAndBlock(
// http://crbug.com/125360
base::ThreadRestrictions::ScopedAllowWait allow_wait;
on_blocking_method_call_.Wait();
- return response;
+ return response.Pass();
}
} // namespace chromeos
diff --git a/chromeos/dbus/blocking_method_caller.h b/chromeos/dbus/blocking_method_caller.h
index 95aa440..6291f47 100644
--- a/chromeos/dbus/blocking_method_caller.h
+++ b/chromeos/dbus/blocking_method_caller.h
@@ -8,13 +8,12 @@
#include "base/callback.h"
#include "base/synchronization/waitable_event.h"
#include "chromeos/chromeos_export.h"
+#include "dbus/message.h"
namespace dbus {
class Bus;
class ObjectProxy;
-class MethodCall;
-class Response;
} // namespace dbus
@@ -29,8 +28,7 @@ class CHROMEOS_EXPORT BlockingMethodCaller {
virtual ~BlockingMethodCaller();
// Calls the method and blocks until it returns.
- // The caller is responsible to delete the returned object.
- dbus::Response* CallMethodAndBlock(dbus::MethodCall* method_call);
+ scoped_ptr<dbus::Response> CallMethodAndBlock(dbus::MethodCall* method_call);
private:
dbus::Bus* bus_;
diff --git a/chromeos/dbus/blocking_method_caller_unittest.cc b/chromeos/dbus/blocking_method_caller_unittest.cc
index eb2394a..2abfd64 100644
--- a/chromeos/dbus/blocking_method_caller_unittest.cc
+++ b/chromeos/dbus/blocking_method_caller_unittest.cc
@@ -39,7 +39,7 @@ class BlockingMethodCallerTest : public testing::Test {
// Set an expectation so mock_proxy's CallMethodAndBlock() will use
// CreateMockProxyResponse() to return responses.
- EXPECT_CALL(*mock_proxy_, CallMethodAndBlock(_, _))
+ EXPECT_CALL(*mock_proxy_, MockCallMethodAndBlock(_, _))
.WillRepeatedly(Invoke(
this, &BlockingMethodCallerTest::CreateMockProxyResponse));
@@ -78,10 +78,10 @@ class BlockingMethodCallerTest : public testing::Test {
dbus::MessageReader reader(method_call);
std::string text_message;
if (reader.PopString(&text_message)) {
- dbus::Response* response = dbus::Response::CreateEmpty();
- dbus::MessageWriter writer(response);
+ scoped_ptr<dbus::Response> response = dbus::Response::CreateEmpty();
+ dbus::MessageWriter writer(response.get());
writer.AppendString(text_message);
- return response;
+ return response.release();
}
}
diff --git a/chromeos/dbus/bluetooth_agent_service_provider.cc b/chromeos/dbus/bluetooth_agent_service_provider.cc
index 9543cc5..2b3811c 100644
--- a/chromeos/dbus/bluetooth_agent_service_provider.cc
+++ b/chromeos/dbus/bluetooth_agent_service_provider.cc
@@ -139,8 +139,7 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
delegate_->Release();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called by dbus:: when the Release method is exported.
@@ -235,8 +234,7 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
delegate_->DisplayPinCode(device_path, pincode);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called by dbus:: when the DisplayPinCode method is exported.
@@ -267,8 +265,7 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
delegate_->DisplayPasskey(device_path, passkey);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called by dbus:: when the DisplayPasskey method is exported.
@@ -404,8 +401,7 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
delegate_->Cancel();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called by dbus:: when the Cancel method is exported.
@@ -425,22 +421,25 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
switch (status) {
case Delegate::SUCCESS: {
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- dbus::MessageWriter writer(response);
+ scoped_ptr<dbus::Response> response(
+ dbus::Response::FromMethodCall(method_call));
+ dbus::MessageWriter writer(response.get());
writer.AppendString(pincode);
- response_sender.Run(response);
+ response_sender.Run(response.Pass());
break;
}
case Delegate::REJECTED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorRejected, "rejected");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorRejected, "rejected")
+ .PassAs<dbus::Response>());
break;
}
case Delegate::CANCELLED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorCanceled, "canceled");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorCanceled, "canceled")
+ .PassAs<dbus::Response>());
break;
}
default:
@@ -457,22 +456,25 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
switch (status) {
case Delegate::SUCCESS: {
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- dbus::MessageWriter writer(response);
+ scoped_ptr<dbus::Response> response(
+ dbus::Response::FromMethodCall(method_call));
+ dbus::MessageWriter writer(response.get());
writer.AppendUint32(passkey);
- response_sender.Run(response);
+ response_sender.Run(response.Pass());
break;
}
case Delegate::REJECTED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorRejected, "rejected");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorRejected, "rejected")
+ .PassAs<dbus::Response>());
break;
}
case Delegate::CANCELLED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorCanceled, "canceled");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorCanceled, "canceled")
+ .PassAs<dbus::Response>());
break;
}
default:
@@ -488,20 +490,21 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
switch (status) {
case Delegate::SUCCESS: {
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
break;
}
case Delegate::REJECTED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorRejected, "rejected");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorRejected, "rejected")
+ .PassAs<dbus::Response>());
break;
}
case Delegate::CANCELLED: {
- dbus::ErrorResponse* response = dbus::ErrorResponse::FromMethodCall(
- method_call, bluetooth_agent::kErrorCanceled, "canceled");
- response_sender.Run(response);
+ response_sender.Run(
+ dbus::ErrorResponse::FromMethodCall(
+ method_call, bluetooth_agent::kErrorCanceled, "canceled")
+ .PassAs<dbus::Response>());
break;
}
default:
diff --git a/chromeos/dbus/ibus/ibus_engine_factory_service.cc b/chromeos/dbus/ibus/ibus_engine_factory_service.cc
index 936b54f..49ca041 100644
--- a/chromeos/dbus/ibus/ibus_engine_factory_service.cc
+++ b/chromeos/dbus/ibus/ibus_engine_factory_service.cc
@@ -73,19 +73,19 @@ class IBusEngineFactoryServiceImpl : public IBusEngineFactoryService {
create_engine_callback_map_[engine_name].Run(
base::Bind(&IBusEngineFactoryServiceImpl::CreateEngineSendReply,
weak_ptr_factory_.GetWeakPtr(),
- dbus::Response::FromMethodCall(method_call),
+ base::Passed(dbus::Response::FromMethodCall(method_call)),
response_sender));
}
}
// Sends reply message for CreateEngine method call.
void CreateEngineSendReply(
- dbus::Response* response,
+ scoped_ptr<dbus::Response> response,
const dbus::ExportedObject::ResponseSender response_sender,
const dbus::ObjectPath& path) {
- dbus::MessageWriter writer(response);
+ dbus::MessageWriter writer(response.get());
writer.AppendObjectPath(path);
- response_sender.Run(response);
+ response_sender.Run(response.Pass());
}
// Called when the CreateEngine method is exported.
diff --git a/chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc b/chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc
index 205422d..c3c2aa6 100644
--- a/chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc
+++ b/chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc
@@ -58,16 +58,22 @@ class MockCreateEngineResponseSender {
public:
explicit MockCreateEngineResponseSender(const dbus::ObjectPath& expected_path)
: expected_path_(expected_path) {}
- MOCK_METHOD1(Run, void(dbus::Response*));
+ // GMock doesn't support mocking methods which take scoped_ptr<>.
+ MOCK_METHOD1(MockRun, void(dbus::Response*));
+ void Run(scoped_ptr<dbus::Response> response) {
+ MockRun(response.get());
+ }
// Checks the given |response| meets expectation for the CreateEngine method.
- void CheckCreateEngineResponse(dbus::Response* response) {
- scoped_ptr<dbus::Response> response_deleter(response);
+ void CheckCreateEngineResponsePtr(dbus::Response* response) {
dbus::MessageReader reader(response);
dbus::ObjectPath actual_path;
ASSERT_TRUE(reader.PopObjectPath(&actual_path));
EXPECT_EQ(expected_path_, actual_path);
}
+ void CheckCreateEngineResponse(scoped_ptr<dbus::Response> response) {
+ CheckCreateEngineResponsePtr(response.get());
+ }
private:
dbus::ObjectPath expected_path_;
@@ -143,10 +149,11 @@ TEST_F(IBusEngineFactoryServiceTest, SyncCreateEngineTest) {
const char kSampleEngine[] = "Sample Engine";
const dbus::ObjectPath kObjectPath("/org/freedesktop/IBus/Engine/10");
MockCreateEngineResponseSender response_sender(kObjectPath);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(
Invoke(&response_sender,
- &MockCreateEngineResponseSender::CheckCreateEngineResponse));
+ &MockCreateEngineResponseSender::
+ CheckCreateEngineResponsePtr));
SynchronousCreateEngineHandler handler(kObjectPath);
// Set handler expectations.
@@ -185,10 +192,11 @@ TEST_F(IBusEngineFactoryServiceTest, AsyncCreateEngineTest) {
const char kSampleEngine[] = "Sample Engine";
const dbus::ObjectPath kObjectPath("/org/freedesktop/IBus/Engine/10");
MockCreateEngineResponseSender response_sender(kObjectPath);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(
Invoke(&response_sender,
- &MockCreateEngineResponseSender::CheckCreateEngineResponse));
+ &MockCreateEngineResponseSender::
+ CheckCreateEngineResponsePtr));
AsynchronousCreateEngineHandler handler(kObjectPath, &message_loop_);
// Set handler expectations.
diff --git a/chromeos/dbus/ibus/ibus_engine_service.cc b/chromeos/dbus/ibus/ibus_engine_service.cc
index c7ec1ae..81d37c8 100644
--- a/chromeos/dbus/ibus/ibus_engine_service.cc
+++ b/chromeos/dbus/ibus/ibus_engine_service.cc
@@ -232,8 +232,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
if (engine_handler_ == NULL)
return;
engine_handler_->FocusIn();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles FocusOut method call from ibus-daemon.
@@ -242,8 +241,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
if (engine_handler_ == NULL)
return;
engine_handler_->FocusOut();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles Enable method call from ibus-daemon.
@@ -252,8 +250,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
if (engine_handler_ == NULL)
return;
engine_handler_->Enable();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles Disable method call from ibus-daemon.
@@ -262,8 +259,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
if (engine_handler_ == NULL)
return;
engine_handler_->Disable();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles PropertyActivate method call from ibus-daemon.
@@ -287,8 +283,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
engine_handler_->PropertyActivate(
property_name,
static_cast<ibus::IBusPropertyState>(property_state));
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles PropertyShow method call from ibus-daemon.
@@ -304,8 +299,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
return;
}
engine_handler_->PropertyShow(property_name);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles PropertyHide method call from ibus-daemon.
@@ -321,8 +315,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
return;
}
engine_handler_->PropertyHide(property_name);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles SetCapability method call from ibus-daemon.
@@ -339,8 +332,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
}
engine_handler_->SetCapability(
static_cast<IBusEngineHandlerInterface::IBusCapability>(capability));
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
void Reset(dbus::MethodCall* method_call,
@@ -348,8 +340,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
if (engine_handler_ == NULL)
return;
engine_handler_->Reset();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles ProcessKeyEvent method call from ibus-daemon.
@@ -380,19 +371,18 @@ class IBusEngineServiceImpl : public IBusEngineService {
keysym, keycode, state,
base::Bind(&IBusEngineServiceImpl::KeyEventDone,
weak_ptr_factory_.GetWeakPtr(),
- base::Unretained(
- dbus::Response::FromMethodCall(method_call)),
+ base::Passed(dbus::Response::FromMethodCall(method_call)),
response_sender));
}
- void KeyEventDone(dbus::Response* response,
+ void KeyEventDone(scoped_ptr<dbus::Response> response,
const dbus::ExportedObject::ResponseSender& response_sender,
bool consume) {
if (engine_handler_ == NULL)
return;
- dbus::MessageWriter writer(response);
+ dbus::MessageWriter writer(response.get());
writer.AppendBool(consume);
- response_sender.Run(response);
+ response_sender.Run(response.Pass());
}
// Handles CandidateClicked method call from ibus-daemon.
@@ -423,8 +413,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
index,
static_cast<ibus::IBusMouseButton>(button),
state);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles SetSurroundingText method call from ibus-daemon.
@@ -454,8 +443,7 @@ class IBusEngineServiceImpl : public IBusEngineService {
}
engine_handler_->SetSurroundingText(text, cursor_pos, anchor_pos);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called when the method call is exported.
diff --git a/chromeos/dbus/ibus/ibus_engine_service_unittest.cc b/chromeos/dbus/ibus/ibus_engine_service_unittest.cc
index ae16d3c..2842401 100644
--- a/chromeos/dbus/ibus/ibus_engine_service_unittest.cc
+++ b/chromeos/dbus/ibus/ibus_engine_service_unittest.cc
@@ -56,7 +56,11 @@ class MockIBusEngineHandler : public IBusEngineHandlerInterface {
class MockResponseSender {
public:
- MOCK_METHOD1(Run, void(dbus::Response* reponse));
+ // GMock doesn't support mocking methods which take scoped_ptr<>.
+ MOCK_METHOD1(MockRun, void(dbus::Response* reponse));
+ void Run(scoped_ptr<dbus::Response> response) {
+ MockRun(response.get());
+ }
};
// Used for method call empty response evaluation.
@@ -67,7 +71,6 @@ class EmptyResponseExpectation {
// Evaluates the given |response| has no argument.
void Evaluate(dbus::Response* response) {
- scoped_ptr<dbus::Response> response_deleter(response);
EXPECT_EQ(serial_no_, response->GetReplySerial());
dbus::MessageReader reader(response);
EXPECT_FALSE(reader.HasMoreData());
@@ -89,7 +92,6 @@ class BoolResponseExpectation {
// Evaluates the given |response| has only one boolean and which is equals to
// |result_| which is given in ctor.
void Evaluate(dbus::Response* response) {
- scoped_ptr<dbus::Response> response_deleter(response);
EXPECT_EQ(serial_no_, response->GetReplySerial());
dbus::MessageReader reader(response);
bool result = false;
@@ -519,7 +521,7 @@ TEST_F(IBusEngineServiceTest, FocusInTest) {
EXPECT_CALL(*engine_handler_, FocusIn());
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -539,7 +541,7 @@ TEST_F(IBusEngineServiceTest, FocusInTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, FocusIn()).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kFocusInMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -552,7 +554,7 @@ TEST_F(IBusEngineServiceTest, FocusOutTest) {
EXPECT_CALL(*engine_handler_, FocusOut());
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -572,7 +574,7 @@ TEST_F(IBusEngineServiceTest, FocusOutTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, FocusOut()).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kFocusOutMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -585,7 +587,7 @@ TEST_F(IBusEngineServiceTest, EnableTest) {
EXPECT_CALL(*engine_handler_, Enable());
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -605,7 +607,7 @@ TEST_F(IBusEngineServiceTest, EnableTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, Enable()).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kEnableMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -618,7 +620,7 @@ TEST_F(IBusEngineServiceTest, DisableTest) {
EXPECT_CALL(*engine_handler_, Disable());
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -638,7 +640,7 @@ TEST_F(IBusEngineServiceTest, DisableTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, Disable()).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kDisableMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -655,7 +657,7 @@ TEST_F(IBusEngineServiceTest, PropertyActivateTest) {
kIBusPropertyState));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -679,7 +681,7 @@ TEST_F(IBusEngineServiceTest, PropertyActivateTest) {
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, PropertyActivate(kPropertyName,
kIBusPropertyState)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kPropertyActivateMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -692,7 +694,7 @@ TEST_F(IBusEngineServiceTest, ResetTest) {
EXPECT_CALL(*engine_handler_, Reset());
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -712,7 +714,7 @@ TEST_F(IBusEngineServiceTest, ResetTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, Reset()).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kResetMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -726,7 +728,7 @@ TEST_F(IBusEngineServiceTest, PropertyShowTest) {
EXPECT_CALL(*engine_handler_, PropertyShow(kPropertyName));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -748,7 +750,7 @@ TEST_F(IBusEngineServiceTest, PropertyShowTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, PropertyShow(kPropertyName)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kPropertyShowMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -762,7 +764,7 @@ TEST_F(IBusEngineServiceTest, PropertyHideTest) {
EXPECT_CALL(*engine_handler_, PropertyHide(kPropertyName));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -784,7 +786,7 @@ TEST_F(IBusEngineServiceTest, PropertyHideTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, PropertyHide(kPropertyName)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kPropertyHideMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -799,7 +801,7 @@ TEST_F(IBusEngineServiceTest, SetCapabilityTest) {
EXPECT_CALL(*engine_handler_, SetCapability(kIBusCapability));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -821,7 +823,7 @@ TEST_F(IBusEngineServiceTest, SetCapabilityTest) {
// Call exported function without engine.
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, SetCapability(kIBusCapability)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kSetCapabilityMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -842,7 +844,7 @@ TEST_F(IBusEngineServiceTest, ProcessKeyEventTest) {
&ProcessKeyEventHandler::ProcessKeyEvent));
MockResponseSender response_sender;
BoolResponseExpectation response_expectation(kSerialNo, kResult);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&BoolResponseExpectation::Evaluate));
@@ -867,7 +869,7 @@ TEST_F(IBusEngineServiceTest, ProcessKeyEventTest) {
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_,
ProcessKeyEvent(kKeySym, kKeyCode, kState, _)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kProcessKeyEventMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -888,7 +890,7 @@ TEST_F(IBusEngineServiceTest, DelayProcessKeyEventTest) {
&DelayProcessKeyEventHandler::ProcessKeyEvent));
MockResponseSender response_sender;
BoolResponseExpectation response_expectation(kSerialNo, kResult);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&BoolResponseExpectation::Evaluate));
@@ -916,7 +918,7 @@ TEST_F(IBusEngineServiceTest, DelayProcessKeyEventTest) {
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_,
ProcessKeyEvent(kKeySym, kKeyCode, kState, _)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kProcessKeyEventMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -933,7 +935,7 @@ TEST_F(IBusEngineServiceTest, CandidateClickedTest) {
kState));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -958,7 +960,7 @@ TEST_F(IBusEngineServiceTest, CandidateClickedTest) {
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, CandidateClicked(kIndex, kIBusMouseButton,
kState)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kCandidateClickedMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
@@ -975,7 +977,7 @@ TEST_F(IBusEngineServiceTest, SetSurroundingTextTest) {
kAnchorPos));
MockResponseSender response_sender;
EmptyResponseExpectation response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseExpectation::Evaluate));
@@ -1000,7 +1002,7 @@ TEST_F(IBusEngineServiceTest, SetSurroundingTextTest) {
service_->UnsetEngine();
EXPECT_CALL(*engine_handler_, SetSurroundingText(kText, kCursorPos,
kAnchorPos)).Times(0);
- EXPECT_CALL(response_sender, Run(_)).Times(0);
+ EXPECT_CALL(response_sender, MockRun(_)).Times(0);
method_callback_map_[ibus::engine::kSetSurroundingTextMethod].Run(
&method_call,
base::Bind(&MockResponseSender::Run,
diff --git a/chromeos/dbus/ibus/ibus_panel_service.cc b/chromeos/dbus/ibus/ibus_panel_service.cc
index 765318b..17457ba 100644
--- a/chromeos/dbus/ibus/ibus_panel_service.cc
+++ b/chromeos/dbus/ibus/ibus_panel_service.cc
@@ -211,8 +211,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
}
candidate_window_handler_->UpdateLookupTable(table, visible);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles HideLookupTable method call from ibus-daemon.
@@ -222,8 +221,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
candidate_window_handler_->HideLookupTable();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles UpdateAuxiliaryText method call from ibus-daemon.
@@ -247,8 +245,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
}
candidate_window_handler_->UpdateAuxiliaryText(text, visible);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles HideAuxiliaryText method call from ibus-daemon.
@@ -258,8 +255,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
candidate_window_handler_->HideAuxiliaryText();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles UpdatePreeditText method call from ibus-daemon.
@@ -288,8 +284,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
}
candidate_window_handler_->UpdatePreeditText(text, cursor_pos, visible);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles HidePreeditText method call from ibus-daemon.
@@ -299,8 +294,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
return;
candidate_window_handler_->HidePreeditText();
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles RegisterProperties method call from ibus-daemon.
@@ -319,8 +313,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
}
property_handler_->RegisterProperties(properties);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Handles UpdateProperty method call from ibus-daemon.
@@ -338,8 +331,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
}
property_handler_->UpdateProperty(property);
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
void SetCursorLocation(const ibus::Rect& cursor_location,
@@ -356,8 +348,7 @@ class IBusPanelServiceImpl : public IBusPanelService {
if (!property_handler_)
return;
- dbus::Response* response = dbus::Response::FromMethodCall(method_call);
- response_sender.Run(response);
+ response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
// Called when the method call is exported.
diff --git a/chromeos/dbus/ibus/ibus_panel_service_unittest.cc b/chromeos/dbus/ibus/ibus_panel_service_unittest.cc
index a90a207..edb9d2c 100644
--- a/chromeos/dbus/ibus/ibus_panel_service_unittest.cc
+++ b/chromeos/dbus/ibus/ibus_panel_service_unittest.cc
@@ -63,7 +63,11 @@ class MockIBusPanelPropertyHandler : public IBusPanelPropertyHandlerInterface {
class MockResponseSender {
public:
- MOCK_METHOD1(Run, void(dbus::Response* reponse));
+ // GMock doesn't support mocking methods which take scoped_ptr<>.
+ MOCK_METHOD1(MockRun, void(dbus::Response* reponse));
+ void Run(scoped_ptr<dbus::Response> response) {
+ MockRun(response.get());
+ }
};
// This class is used to verify that a method call response is empty. This class
@@ -76,7 +80,6 @@ class EmptyResponseVerifier {
// Verifies the given |response| has no argument.
void Verify(dbus::Response* response) {
- scoped_ptr<dbus::Response> response_deleter(response);
EXPECT_EQ(expected_serial_number_, response->GetReplySerial());
dbus::MessageReader reader(response);
EXPECT_FALSE(reader.HasMoreData());
@@ -349,7 +352,7 @@ TEST_F(IBusPanelServiceTest, HideLookupTableTest) {
EXPECT_CALL(*candidate_window_handler_, HideLookupTable());
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -373,7 +376,7 @@ TEST_F(IBusPanelServiceTest, HideAuxiliaryTextTest) {
EXPECT_CALL(*candidate_window_handler_, HideAuxiliaryText());
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -397,7 +400,7 @@ TEST_F(IBusPanelServiceTest, HidePreeditTextTest) {
EXPECT_CALL(*candidate_window_handler_, HidePreeditText());
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -430,7 +433,7 @@ TEST_F(IBusPanelServiceTest, UpdateLookupTableTest) {
&UpdateLookupTableVerifier::Verify));
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -460,7 +463,7 @@ TEST_F(IBusPanelServiceTest, UpdateAuxiliaryTextTest) {
EXPECT_CALL(*candidate_window_handler_, UpdateAuxiliaryText(text, kVisible));
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -492,7 +495,7 @@ TEST_F(IBusPanelServiceTest, UpdatePreeditTextTest) {
UpdatePreeditText(text, kCursorPos, kVisible));
MockResponseSender response_sender;
EmptyResponseVerifier response_expectation(kSerialNo);
- EXPECT_CALL(response_sender, Run(_))
+ EXPECT_CALL(response_sender, MockRun(_))
.WillOnce(Invoke(&response_expectation,
&EmptyResponseVerifier::Verify));
@@ -573,7 +576,7 @@ TEST_F(IBusPanelServiceTest, RegisterPropertiesTest) {
&PropertyListVerifier::Verify));
MockResponseSender response_sender;
- EXPECT_CALL(response_sender, Run(_));
+ EXPECT_CALL(response_sender, MockRun(_));
// Create method call;
dbus::MethodCall method_call(ibus::panel::kServiceInterface,
@@ -601,7 +604,7 @@ TEST_F(IBusPanelServiceTest, UpdatePropertyTest) {
.WillOnce(Invoke(&response_expectation, &PropertyVerifier::Verify));
MockResponseSender response_sender;
- EXPECT_CALL(response_sender, Run(_));
+ EXPECT_CALL(response_sender, MockRun(_));
// Create method call;
dbus::MethodCall method_call(ibus::panel::kServiceInterface,
diff --git a/chromeos/dbus/shill_client_unittest_base.cc b/chromeos/dbus/shill_client_unittest_base.cc
index 7488fa9..72906e5 100644
--- a/chromeos/dbus/shill_client_unittest_base.cc
+++ b/chromeos/dbus/shill_client_unittest_base.cc
@@ -115,7 +115,7 @@ void ShillClientUnittestBase::SetUp() {
// Set an expectation so mock_proxy's CallMethodAndBlock() will use
// OnCallMethodAndBlock() to return responses.
- EXPECT_CALL(*mock_proxy_, CallMethodAndBlock(_, _))
+ EXPECT_CALL(*mock_proxy_, MockCallMethodAndBlock(_, _))
.WillRepeatedly(Invoke(
this, &ShillClientUnittestBase::OnCallMethodAndBlock));
@@ -315,7 +315,7 @@ dbus::Response* ShillClientUnittestBase::OnCallMethodAndBlock(
dbus::MessageReader reader(method_call);
argument_checker_.Run(&reader);
return dbus::Response::FromRawMessage(
- dbus_message_copy(response_->raw_message()));
+ dbus_message_copy(response_->raw_message())).release();
}
} // namespace chromeos