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
3 // found in the LICENSE file.
5 #include "chromeos/dbus/ibus/ibus_config_client.h"
10 #include "base/message_loop.h"
11 #include "base/values.h"
12 #include "chromeos/dbus/ibus/ibus_constants.h"
13 #include "dbus/message.h"
14 #include "dbus/mock_bus.h"
15 #include "dbus/mock_object_proxy.h"
16 #include "dbus/object_path.h"
17 #include "dbus/values_util.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h"
21 using testing::Invoke
;
22 using testing::Return
;
26 const char kSection
[] = "IBus/Section";
27 const char kKey
[] = "key";
29 enum HandlerBehavior
{
37 class MockErrorCallback
{
39 MOCK_METHOD0(Run
, void());
42 class MockOnIBusConfigReadyCallback
{
44 MOCK_METHOD0(Run
, void());
47 // The base class of each type specified SetValue function handler. This class
48 // checks "section" and "key" field in SetValue message and callback success or
49 // error callback based on given |success| flag.
50 class SetValueVerifierBase
{
52 SetValueVerifierBase(const std::string
& expected_section
,
53 const std::string
& expected_key
,
54 HandlerBehavior behavior
)
55 : expected_section_(expected_section
),
56 expected_key_(expected_key
),
57 behavior_(behavior
) {}
59 virtual ~SetValueVerifierBase() {}
61 // Handles SetValue method call. This function checks "section" and "key"
62 // field. For the "value" field, subclass checks it with over riding
63 // VeirfyVariant member function.
64 void Run(dbus::MethodCall
* method_call
,
66 const dbus::ObjectProxy::ResponseCallback
& callback
,
67 const dbus::ObjectProxy::ErrorCallback
& error_callback
) {
68 dbus::MessageReader
reader(method_call
);
72 EXPECT_TRUE(reader
.PopString(§ion
));
73 EXPECT_EQ(expected_section_
, section
);
74 EXPECT_TRUE(reader
.PopString(&key
));
75 EXPECT_EQ(expected_key_
, key
);
76 dbus::MessageReader
variant_reader(NULL
);
77 EXPECT_TRUE(reader
.PopVariant(&variant_reader
));
79 VerifyVariant(&variant_reader
);
81 EXPECT_FALSE(reader
.HasMoreData());
82 if (behavior_
== HANDLER_SUCCESS
) {
83 scoped_ptr
<dbus::Response
> response(
84 dbus::Response::FromMethodCall(method_call
));
85 callback
.Run(response
.get());
87 scoped_ptr
<dbus::ErrorResponse
> error_response(
88 dbus::ErrorResponse::FromMethodCall(method_call
, "Error",
90 error_callback
.Run(error_response
.get());
94 // Verifies "value" field in SetValue method call.
95 virtual void VerifyVariant(dbus::MessageReader
* reader
) = 0;
98 const std::string expected_section_
;
99 const std::string expected_key_
;
100 const HandlerBehavior behavior_
;
102 DISALLOW_COPY_AND_ASSIGN(SetValueVerifierBase
);
105 // The class to verify SetStringValue method call arguments.
106 class SetStringValueHandler
: public SetValueVerifierBase
{
108 SetStringValueHandler(const std::string
& expected_key
,
109 const std::string
& expected_section
,
110 const std::string
& expected_value
,
111 HandlerBehavior behavior
)
112 : SetValueVerifierBase(expected_section
, expected_key
, behavior
),
113 expected_value_(expected_value
) {}
116 // SetValueVerifierBase override.
117 virtual void VerifyVariant(dbus::MessageReader
* reader
) OVERRIDE
{
119 EXPECT_TRUE(reader
->PopString(&value
));
120 EXPECT_EQ(expected_value_
, value
);
124 const std::string expected_value_
;
126 DISALLOW_COPY_AND_ASSIGN(SetStringValueHandler
);
129 // The class to verify SetIntValue method call arguments.
130 class SetIntValueHandler
: public SetValueVerifierBase
{
132 SetIntValueHandler(const std::string
& expected_key
,
133 const std::string
& expected_section
,
135 HandlerBehavior behavior
)
136 : SetValueVerifierBase(expected_section
, expected_key
, behavior
),
137 expected_value_(expected_value
) {}
139 // SetValueVerifierBase override.
140 virtual void VerifyVariant(dbus::MessageReader
* reader
) OVERRIDE
{
142 EXPECT_TRUE(reader
->PopInt32(&value
));
143 EXPECT_EQ(expected_value_
, value
);
147 const int expected_value_
;
149 DISALLOW_COPY_AND_ASSIGN(SetIntValueHandler
);
152 // The class to verify SetBoolValue method call arguments.
153 class SetBoolValueHandler
: public SetValueVerifierBase
{
155 SetBoolValueHandler(const std::string
& expected_key
,
156 const std::string
& expected_section
,
158 HandlerBehavior behavior
)
159 : SetValueVerifierBase(expected_section
, expected_key
, behavior
),
160 expected_value_(expected_value
) {}
162 // SetValueVerifierBase override.
163 virtual void VerifyVariant(dbus::MessageReader
* reader
) OVERRIDE
{
165 EXPECT_TRUE(reader
->PopBool(&value
));
166 EXPECT_EQ(expected_value_
, value
);
170 const bool expected_value_
;
172 DISALLOW_COPY_AND_ASSIGN(SetBoolValueHandler
);
175 // The class to verify SetStringListValue method call arguments.
176 class SetStringListValueHandler
: public SetValueVerifierBase
{
178 SetStringListValueHandler(const std::string
& expected_key
,
179 const std::string
& expected_section
,
180 const std::vector
<std::string
>& expected_value
,
181 HandlerBehavior behavior
)
182 : SetValueVerifierBase(expected_section
, expected_key
, behavior
),
183 expected_value_(expected_value
) {}
185 // SetValueVerifierBase override
186 virtual void VerifyVariant(dbus::MessageReader
* reader
) OVERRIDE
{
187 dbus::MessageReader
array_reader(NULL
);
188 ASSERT_TRUE(reader
->PopArray(&array_reader
));
189 for (size_t i
= 0; i
< expected_value_
.size(); ++i
) {
191 ASSERT_TRUE(array_reader
.HasMoreData());
192 EXPECT_TRUE(array_reader
.PopString(&value
));
193 EXPECT_EQ(expected_value_
[i
], value
);
195 EXPECT_FALSE(array_reader
.HasMoreData());
199 const std::vector
<std::string
>& expected_value_
;
201 DISALLOW_COPY_AND_ASSIGN(SetStringListValueHandler
);
204 // The class verifies GetNameOwner method call and emits response callback
206 class MockGetNameOwnerMethodCallHandler
{
208 MockGetNameOwnerMethodCallHandler() {}
210 // Handles CallMethod function.
211 void Run(dbus::MethodCall
* method_call
,
213 const dbus::ObjectProxy::ResponseCallback
& callback
,
214 const dbus::ObjectProxy::ErrorCallback
& error_callback
) {
215 dbus::MessageReader
reader(method_call
);
216 std::string target_name
;
217 EXPECT_TRUE(reader
.PopString(&target_name
));
218 EXPECT_EQ(ibus::config::kServiceName
, target_name
);
219 EXPECT_FALSE(reader
.HasMoreData());
221 callback_
= callback
;
224 // Invokes reply with given |callback_| in Run method.
225 void EmitReplyCallback(const std::string
& owner
) {
226 scoped_ptr
<dbus::Response
> response(dbus::Response::CreateEmpty());
227 dbus::MessageWriter
writer(response
.get());
228 writer
.AppendString(owner
);
229 callback_
.Run(response
.get());
233 dbus::ObjectProxy::ResponseCallback callback_
;
235 DISALLOW_COPY_AND_ASSIGN(MockGetNameOwnerMethodCallHandler
);
239 // The class emulate GetNameOwner signal.
240 class NameOwnerChangedHandler
{
242 NameOwnerChangedHandler() {}
244 // OnConnectToSignal mock function.
245 void OnConnectToSignal(
246 const std::string
& interface_name
,
247 const std::string
& signal_name
,
248 const dbus::ObjectProxy::SignalCallback
& signal_callback
,
249 const dbus::ObjectProxy::OnConnectedCallback
& on_connected_callback
) {
250 callback_
= signal_callback
;
251 on_connected_callback
.Run(interface_name
, signal_name
, true);
254 // Invokes reply with given |callback_| in Run method.
255 void InvokeSignal(const std::string
& name
,
256 const std::string
& old_owner
,
257 const std::string
& new_owner
) {
258 dbus::Signal
signal(ibus::kDBusInterface
, ibus::kGetNameOwnerMethod
);
259 dbus::MessageWriter
writer(&signal
);
260 writer
.AppendString(name
);
261 writer
.AppendString(old_owner
);
262 writer
.AppendString(new_owner
);
263 callback_
.Run(&signal
);
267 dbus::ObjectProxy::SignalCallback callback_
;
269 DISALLOW_COPY_AND_ASSIGN(NameOwnerChangedHandler
);
273 class IBusConfigClientTest
: public testing::Test
{
275 IBusConfigClientTest() {}
278 virtual void SetUp() OVERRIDE
{
279 dbus::Bus::Options options
;
280 mock_bus_
= new dbus::MockBus(options
);
281 mock_proxy_
= new dbus::MockObjectProxy(mock_bus_
.get(),
284 ibus::config::kServicePath
));
285 EXPECT_CALL(*mock_bus_
, ShutdownAndBlock());
286 client_
.reset(IBusConfigClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION
,
289 // Surpress uninteresting mock function call warning.
290 EXPECT_CALL(*mock_bus_
.get(), AssertOnOriginThread())
291 .WillRepeatedly(Return());
294 virtual void TearDown() OVERRIDE
{
295 mock_bus_
->ShutdownAndBlock();
298 // Initialize |client_| by replying valid owner name synchronously.
299 void InitializeSync() {
300 EXPECT_CALL(*mock_bus_
, GetObjectProxy(ibus::config::kServiceName
,
302 ibus::config::kServicePath
)))
303 .WillOnce(Return(mock_proxy_
.get()));
305 scoped_refptr
<dbus::MockObjectProxy
> mock_dbus_proxy
306 = new dbus::MockObjectProxy(mock_bus_
.get(),
307 ibus::kDBusServiceName
,
308 dbus::ObjectPath(ibus::kDBusObjectPath
));
309 EXPECT_CALL(*mock_bus_
,
310 GetObjectProxy(ibus::kDBusServiceName
,
311 dbus::ObjectPath(ibus::kDBusObjectPath
)))
312 .WillOnce(Return(mock_dbus_proxy
.get()));
314 MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call
;
315 EXPECT_CALL(*mock_dbus_proxy
, CallMethodWithErrorCallback(_
, _
, _
, _
))
316 .WillOnce(Invoke(&mock_get_name_owner_method_call
,
317 &MockGetNameOwnerMethodCallHandler::Run
));
318 NameOwnerChangedHandler handler
;
319 EXPECT_CALL(*mock_dbus_proxy
, ConnectToSignal(
320 ibus::kDBusInterface
,
321 ibus::kNameOwnerChangedSignal
,
323 _
)).WillOnce(Invoke(&handler
,
324 &NameOwnerChangedHandler::OnConnectToSignal
));
325 client_
->InitializeAsync(base::Bind(&base::DoNothing
));
326 mock_get_name_owner_method_call
.EmitReplyCallback(":0.1");
329 // The IBus config client to be tested.
330 scoped_ptr
<IBusConfigClient
> client_
;
332 // A message loop to emulate asynchronous behavior.
333 MessageLoop message_loop_
;
334 scoped_refptr
<dbus::MockBus
> mock_bus_
;
335 scoped_refptr
<dbus::MockObjectProxy
> mock_proxy_
;
338 TEST_F(IBusConfigClientTest
, SetStringValueTest
) {
341 const char value
[] = "value";
342 SetStringValueHandler
handler(kSection
, kKey
, value
, HANDLER_SUCCESS
);
343 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
344 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
345 MockErrorCallback error_callback
;
346 EXPECT_CALL(error_callback
, Run()).Times(0);
348 // Call SetStringValue.
349 client_
->SetStringValue(kKey
, kSection
, value
,
350 base::Bind(&MockErrorCallback::Run
,
351 base::Unretained(&error_callback
)));
354 TEST_F(IBusConfigClientTest
, SetStringValueTest_Fail
) {
357 const char value
[] = "value";
358 SetStringValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
359 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
360 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
361 MockErrorCallback error_callback
;
362 EXPECT_CALL(error_callback
, Run());
364 // Call SetStringValue.
365 client_
->SetStringValue(kKey
, kSection
, value
,
366 base::Bind(&MockErrorCallback::Run
,
367 base::Unretained(&error_callback
)));
370 TEST_F(IBusConfigClientTest
, SetIntValueTest
) {
373 const int value
= 1234;
374 SetIntValueHandler
handler(kSection
, kKey
, value
, HANDLER_SUCCESS
);
375 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
376 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
377 MockErrorCallback error_callback
;
378 EXPECT_CALL(error_callback
, Run()).Times(0);
381 client_
->SetIntValue(kKey
, kSection
, value
,
382 base::Bind(&MockErrorCallback::Run
,
383 base::Unretained(&error_callback
)));
386 TEST_F(IBusConfigClientTest
, SetIntValueTest_Fail
) {
389 const int value
= 1234;
390 SetIntValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
391 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
392 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
393 MockErrorCallback error_callback
;
394 EXPECT_CALL(error_callback
, Run());
397 client_
->SetIntValue(kKey
, kSection
, value
,
398 base::Bind(&MockErrorCallback::Run
,
399 base::Unretained(&error_callback
)));
402 TEST_F(IBusConfigClientTest
, SetBoolValueTest
) {
405 const bool value
= true;
406 SetBoolValueHandler
handler(kSection
, kKey
, value
, HANDLER_SUCCESS
);
407 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
408 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
409 MockErrorCallback error_callback
;
410 EXPECT_CALL(error_callback
, Run()).Times(0);
412 // Call SetBoolValue.
413 client_
->SetBoolValue(kKey
, kSection
, value
,
414 base::Bind(&MockErrorCallback::Run
,
415 base::Unretained(&error_callback
)));
418 TEST_F(IBusConfigClientTest
, SetBoolValueTest_Fail
) {
421 const bool value
= true;
422 SetBoolValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
423 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
424 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
425 MockErrorCallback error_callback
;
426 EXPECT_CALL(error_callback
, Run());
428 // Call SetBoolValue.
429 client_
->SetBoolValue(kKey
, kSection
, value
,
430 base::Bind(&MockErrorCallback::Run
,
431 base::Unretained(&error_callback
)));
434 TEST_F(IBusConfigClientTest
, SetStringListValueTest
) {
437 std::vector
<std::string
> value
;
438 value
.push_back("Sample value 1");
439 value
.push_back("Sample value 2");
441 SetStringListValueHandler
handler(kSection
, kKey
, value
, HANDLER_SUCCESS
);
442 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
443 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
444 MockErrorCallback error_callback
;
445 EXPECT_CALL(error_callback
, Run()).Times(0);
447 // Call SetStringListValue.
448 client_
->SetStringListValue(kKey
, kSection
, value
,
449 base::Bind(&MockErrorCallback::Run
,
450 base::Unretained(&error_callback
)));
453 TEST_F(IBusConfigClientTest
, SetStringListValueTest_Fail
) {
456 std::vector
<std::string
> value
;
457 value
.push_back("Sample value 1");
458 value
.push_back("Sample value 2");
460 SetStringListValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
461 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
462 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
463 MockErrorCallback error_callback
;
464 EXPECT_CALL(error_callback
, Run());
466 // Call SetStringListValue.
467 client_
->SetStringListValue(kKey
, kSection
, value
,
468 base::Bind(&MockErrorCallback::Run
,
469 base::Unretained(&error_callback
)));
472 TEST_F(IBusConfigClientTest
, IBusConfigDaemon_NotAvailableTest
) {
473 MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call
;
475 EXPECT_CALL(*mock_bus_
, GetObjectProxy(ibus::kServiceName
,
477 ibus::config::kServicePath
)))
480 scoped_refptr
<dbus::MockObjectProxy
> mock_dbus_proxy
481 = new dbus::MockObjectProxy(mock_bus_
.get(),
482 ibus::kDBusServiceName
,
483 dbus::ObjectPath(ibus::kDBusObjectPath
));
484 EXPECT_CALL(*mock_bus_
,
485 GetObjectProxy(ibus::kDBusServiceName
,
486 dbus::ObjectPath(ibus::kDBusObjectPath
)))
487 .WillOnce(Return(mock_dbus_proxy
.get()));
488 EXPECT_CALL(*mock_dbus_proxy
, CallMethodWithErrorCallback(_
, _
, _
, _
))
489 .WillOnce(Invoke(&mock_get_name_owner_method_call
,
490 &MockGetNameOwnerMethodCallHandler::Run
));
491 NameOwnerChangedHandler handler
;
492 EXPECT_CALL(*mock_dbus_proxy
, ConnectToSignal(
493 ibus::kDBusInterface
,
494 ibus::kNameOwnerChangedSignal
,
496 _
)).WillOnce(Invoke(&handler
,
497 &NameOwnerChangedHandler::OnConnectToSignal
));
498 client_
->InitializeAsync(base::Bind(&base::DoNothing
));
500 // Passing empty string means there is no owner, thus ibus-config daemon is
502 mock_get_name_owner_method_call
.EmitReplyCallback("");
504 // Make sure not crashing by function call without initialize.
505 const bool value
= true;
506 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
)).Times(0);
507 MockErrorCallback error_callback
;
508 EXPECT_CALL(error_callback
, Run()).Times(0);
509 client_
->SetBoolValue(kKey
, kSection
, value
,
510 base::Bind(&MockErrorCallback::Run
,
511 base::Unretained(&error_callback
)));
514 TEST_F(IBusConfigClientTest
, IBusConfigDaemon_SlowInitializeTest
) {
515 MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call
;
517 EXPECT_CALL(*mock_bus_
, GetObjectProxy(ibus::config::kServiceName
,
519 ibus::config::kServicePath
)))
520 .WillOnce(Return(mock_proxy_
.get()));
522 scoped_refptr
<dbus::MockObjectProxy
> mock_dbus_proxy
523 = new dbus::MockObjectProxy(mock_bus_
.get(),
524 ibus::kDBusServiceName
,
525 dbus::ObjectPath(ibus::kDBusObjectPath
));
526 EXPECT_CALL(*mock_bus_
,
527 GetObjectProxy(ibus::kDBusServiceName
,
528 dbus::ObjectPath(ibus::kDBusObjectPath
)))
529 .WillOnce(Return(mock_dbus_proxy
.get()));
530 EXPECT_CALL(*mock_dbus_proxy
, CallMethodWithErrorCallback(_
, _
, _
, _
))
531 .WillOnce(Invoke(&mock_get_name_owner_method_call
,
532 &MockGetNameOwnerMethodCallHandler::Run
));
533 NameOwnerChangedHandler name_owner_changed_handler
;
534 EXPECT_CALL(*mock_dbus_proxy
, ConnectToSignal(
535 ibus::kDBusInterface
,
536 ibus::kNameOwnerChangedSignal
,
538 _
)).WillOnce(Invoke(&name_owner_changed_handler
,
539 &NameOwnerChangedHandler::OnConnectToSignal
));
540 client_
->InitializeAsync(base::Bind(&base::DoNothing
));
542 // Passing empty string means there is no owner, thus ibus-config daemon is
544 mock_get_name_owner_method_call
.EmitReplyCallback("");
546 // Fire NameOwnerChanged signal to emulate ibus-config daemon was acquired
548 name_owner_changed_handler
.InvokeSignal(ibus::config::kServiceName
,
552 // Make sure it is possible to emit method calls.
553 const bool value
= true;
554 SetBoolValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
555 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
556 .WillOnce(Invoke(&handler
, &SetValueVerifierBase::Run
));
557 MockErrorCallback error_callback
;
558 EXPECT_CALL(error_callback
, Run());
560 // Call SetBoolValue.
561 client_
->SetBoolValue(kKey
, kSection
, value
,
562 base::Bind(&MockErrorCallback::Run
,
563 base::Unretained(&error_callback
)));
566 TEST_F(IBusConfigClientTest
, IBusConfigDaemon_ShutdownTest
) {
567 MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call
;
569 EXPECT_CALL(*mock_bus_
, GetObjectProxy(ibus::config::kServiceName
,
571 ibus::config::kServicePath
)))
572 .WillRepeatedly(Return(mock_proxy_
.get()));
574 scoped_refptr
<dbus::MockObjectProxy
> mock_dbus_proxy
575 = new dbus::MockObjectProxy(mock_bus_
.get(),
576 ibus::kDBusServiceName
,
577 dbus::ObjectPath(ibus::kDBusObjectPath
));
578 EXPECT_CALL(*mock_bus_
,
579 GetObjectProxy(ibus::kDBusServiceName
,
580 dbus::ObjectPath(ibus::kDBusObjectPath
)))
581 .WillOnce(Return(mock_dbus_proxy
.get()));
582 EXPECT_CALL(*mock_dbus_proxy
, CallMethodWithErrorCallback(_
, _
, _
, _
))
583 .WillOnce(Invoke(&mock_get_name_owner_method_call
,
584 &MockGetNameOwnerMethodCallHandler::Run
));
585 NameOwnerChangedHandler name_owner_changed_handler
;
586 EXPECT_CALL(*mock_dbus_proxy
, ConnectToSignal(
587 ibus::kDBusInterface
,
588 ibus::kNameOwnerChangedSignal
,
590 _
)).WillOnce(Invoke(&name_owner_changed_handler
,
591 &NameOwnerChangedHandler::OnConnectToSignal
));
592 client_
->InitializeAsync(base::Bind(&base::DoNothing
));
594 const bool value
= true;
595 SetBoolValueHandler
handler(kSection
, kKey
, value
, HANDLER_FAIL
);
596 EXPECT_CALL(*mock_proxy_
, CallMethodWithErrorCallback(_
, _
, _
, _
))
597 .WillRepeatedly(Invoke(&handler
, &SetValueVerifierBase::Run
));
598 MockErrorCallback error_callback
;
599 EXPECT_CALL(error_callback
, Run()).WillRepeatedly(Return());
601 // Initialize succeeded sucessfully.
602 mock_get_name_owner_method_call
.EmitReplyCallback(":0.2");
604 // Call SetBoolValue.
605 client_
->SetBoolValue(kKey
, kSection
, value
,
606 base::Bind(&MockErrorCallback::Run
,
607 base::Unretained(&error_callback
)));
609 // Fire NameOwnerChanged signal to emulate shutting down the ibus-config
611 name_owner_changed_handler
.InvokeSignal(ibus::config::kServiceName
,
615 // Make sure not crashing on emitting method call.
616 client_
->SetBoolValue(kKey
, kSection
, value
,
617 base::Bind(&MockErrorCallback::Run
,
618 base::Unretained(&error_callback
)));
620 // Fire NameOwnerChanged signal to emulate that ibus-daemon is revived.
621 name_owner_changed_handler
.InvokeSignal(ibus::config::kServiceName
,
625 // Make sure it is possible to emit method calls.
626 client_
->SetBoolValue(kKey
, kSection
, value
,
627 base::Bind(&MockErrorCallback::Run
,
628 base::Unretained(&error_callback
)));
631 } // namespace chromeos