Unify the argument of dbus method caller and receiver 06/235706/7
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 9 Jun 2020 05:23:02 +0000 (14:23 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 17 Jun 2020 07:37:39 +0000 (16:37 +0900)
Change-Id: I073bdbe25b8f66eb3646535689fdc54de7e1df34
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/theme/dbus/request_broker.cc
src/theme/dbus/request_handler.h
src/theme/loader/theme_info_loader.cc
src/theme_provider/control_request_handler.cc
src/theme_provider/package_event_request_handler.cc
src/theme_provider/package_event_request_handler.h
src/theme_provider/selection_request_handler.cc
test/unit_tests/mock/glib_mock.cc [deleted file]
test/unit_tests/mock/glib_mock.h [deleted file]
test/unit_tests/test_request_handlers.cc
test/unit_tests/test_theme_info_loader.cc

index 175a23f..8175a51 100644 (file)
@@ -17,6 +17,7 @@
 #include <gio/gio.h>
 
 #include <string>
+#include <utility>
 
 #include "theme/dbus/request_broker.h"
 #include "theme/utils/logging.h"
@@ -33,6 +34,12 @@ const char kDBusMethodSendData[] = "SendData";
 namespace ttm {
 namespace dbus {
 
+static tizen_base::Bundle ErrorResultBundle() {
+  tizen_base::Bundle b;
+  b.Add(CMD_RESULT_KEY, "error");
+  return b;
+}
+
 void RequestBroker::OnReceiveDbusMethod(GDBusConnection* connection,
     const gchar* sender, const gchar* object_path, const gchar* interface_name,
     const gchar* method_name, GVariant* parameters,
@@ -54,8 +61,7 @@ void RequestBroker::OnReceiveDbusMethod(GDBusConnection* connection,
   }
 
   tizen_base::Bundle result = it->second.GetHandler()->OnRequest(cmd, b);
-  reply_body =
-      g_variant_new("(is)", Command::RESULT, result.ToRaw().first.get());
+  reply_body = g_variant_new("(s)", result.ToRaw().first.get());
   g_dbus_method_invocation_return_value(invocation, reply_body);
 }
 
@@ -125,7 +131,6 @@ bool RequestBroker::Listen() {
     "    <method name='SendData'>"
     "      <arg type='i' name='command' direction='in'/>"
     "      <arg type='s' name='serialized' direction='in'/>"
-    "      <arg type='i' name='command' direction='out'/>"
     "      <arg type='s' name='serialized' direction='out'/>"
     "    </method>"
     "  </interface>"
@@ -133,7 +138,7 @@ bool RequestBroker::Listen() {
   GError* error = nullptr;
   GDBusNodeInfo* introspection_data =
       g_dbus_node_info_new_for_xml(introspection_xml, &error);
-  if (!introspection_data) {
+  if (introspection_data == nullptr) {
     LOG(ERROR) << "g_dbus_node_info_new_for_xml is failed";
     if (error != nullptr) {
       LOG(ERROR) << "g_dbus_node_info_new_for_xml err ["
@@ -155,7 +160,7 @@ bool RequestBroker::Listen() {
   int owner_id = g_bus_own_name_on_connection(connection_,
       kDbusBusName, G_BUS_NAME_OWNER_FLAGS_NONE,
       nullptr, nullptr, nullptr, nullptr);
-  if (!owner_id) {
+  if (owner_id == 0) {
     g_object_unref(connection_);
     LOG(ERROR) << "g_bus_own_name_on_connection error";
     return false;
@@ -196,11 +201,10 @@ tizen_base::Bundle RequestBroker::SendData(Command cmd,
   GError* err = nullptr;
   GDBusMessage* msg = g_dbus_message_new_method_call(kDbusInterfaceName,
       kDbusObjectPath, kDbusInterfaceName, kDBusMethodSendData);
-  if (!msg) {
+  if (msg == nullptr) {
     LOG(ERROR) << "Can't allocate new method call";
-    return {};
+    return ErrorResultBundle();
   }
-
   g_dbus_message_set_body(msg,
       g_variant_new("(is)",
         static_cast<int>(cmd),
@@ -209,47 +213,57 @@ tizen_base::Bundle RequestBroker::SendData(Command cmd,
   GDBusMessage* reply = g_dbus_connection_send_message_with_reply_sync(
       connection_, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE,
       -1, nullptr, nullptr, &err);
+  if (reply == nullptr) {
+    LOG(ERROR) << "g_dbus_connection_send_message_with_reply_sync() is failed";
+    if (err) {
+      LOG(ERROR) << "error[" <<  err->message << "]";
+      g_error_free(err);
+    }
+    return ErrorResultBundle();
+  }
   GVariant* reply_body = g_dbus_message_get_body(reply);
-  int command;
+  if (reply_body == nullptr) {
+    LOG(ERROR) << "g_dbus_message_get_body() is failed";
+    return ErrorResultBundle();
+  }
+
   char* serialized = nullptr;
-  g_variant_get(reply_body, "(i&s)", &command, &serialized);
+  g_variant_get(reply_body, "(&s)", &serialized);
   tizen_base::Bundle result(serialized);
-
   return result;
 }
 
 void RequestBroker::OnResultReceivedCb(GObject* source_object,
     GAsyncResult* res, gpointer user_data) {
+  auto param = static_cast<std::pair<Command, RequestBroker*>*>(user_data);
   GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(source_object);
   GError* err = nullptr;
   GDBusMessage* reply = g_dbus_connection_send_message_with_reply_finish(conn,
       res, &err);
-  if (!reply) {
+  if (reply == nullptr) {
     LOG(ERROR) << "No reply . err[" << (err ? err->message : "Unknown") << "]";
     return;
   }
 
-  int command;
   char* serialized = nullptr;
 
   GVariant* reply_body = g_dbus_message_get_body(reply);
-  g_variant_get(reply_body, "(i&s)", &command, &serialized);
-  RequestBroker* broker = static_cast<RequestBroker*>(user_data);
-  Command cmd = static_cast<Command>(command);
+  g_variant_get(reply_body, "(&s)", &serialized);
+  RequestBroker* broker = param->second;
   tizen_base::Bundle b(serialized);
   g_object_unref(reply);
 
-  auto it = broker->filters_.find(cmd);
+  auto it = broker->filters_.find(param->first);
   if (it == broker->filters_.end())
     return;
 
-  it->second.GetHandler()->OnRequest(cmd, b);
+  it->second.GetHandler()->OnRequest(Command::RESULT, b);
 }
 
 void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
   GDBusMessage* msg = g_dbus_message_new_method_call(
       kDbusBusName, kDbusObjectPath, kDbusInterfaceName, kDBusMethodSendData);
-  if (!msg) {
+  if (msg == nullptr) {
     LOG(ERROR) << "Can't allocate new method call";
     return;
   }
@@ -257,9 +271,11 @@ void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
   g_dbus_message_set_body(msg, g_variant_new("(is)", static_cast<int>(cmd),
           reinterpret_cast<char*>(data.ToRaw().first.get())));
 
+  std::pair<Command, RequestBroker*> param = std::make_pair(cmd, this);
+
   g_dbus_connection_send_message_with_reply(connection_, msg,
       G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, nullptr,
-      nullptr, OnResultReceivedCb, this);
+      nullptr, OnResultReceivedCb, &param);
 }
 
 }  // namespace dbus
index 15ff033..4ec09e8 100644 (file)
 namespace ttm {
 namespace dbus {
 
+#define CMD_GET_IDS_KEY "__GET_IDS__"
+#define CMD_SET_ID_KEY "__SET_ID__"
+#define CMD_GET_KEY "__GET__"
+#define CMD_RESULT_KEY "__RESULT__"
+#define CMD_ADD_KEY "__ADD__"
+#define CMD_UPDATE_KEY "__UPDATE__"
+#define CMD_REMOVE_KEY "__REMOVE__"
+#define CMD_CHANGED_KEY "__CHANGED__"
+#define CMD_REMOVED_KEY "__REMOVED__"
+
 enum class Command : int {
   GET_IDS,
   SET_ID,
index 2f4a0cb..365ae1c 100644 (file)
@@ -29,7 +29,8 @@ tizen_base::Bundle ThemeInfoLoader::OnRequest(dbus::Command cmd,
     const tizen_base::Bundle& args) {
   switch (cmd) {
     case dbus::Command::CHANGED: {
-      const ThemeInfo* info = new ThemeInfo(args);
+      tizen_base::Bundle b(args.GetString(CMD_CHANGED_KEY));
+      const ThemeInfo* info = new ThemeInfo(b);
       for (auto& listener : listeners_) {
         std::shared_ptr<IThemeEvent> ev = listener.second;
         ev->OnThemeLoaded(info, args);
@@ -38,7 +39,7 @@ tizen_base::Bundle ThemeInfoLoader::OnRequest(dbus::Command cmd,
       break;
     }
     case dbus::Command::REMOVED: {
-      std::string id = args.GetString("__ID__");
+      std::string id = args.GetString(CMD_REMOVE_KEY);
       for (auto& listener : listeners_) {
         std::shared_ptr<IThemeEvent> ev = listener.second;
         ev->OnThemeUnloaded(id);
@@ -93,18 +94,17 @@ int ThemeInfoLoader::RemoveEvent(const std::string& id) {
 
 std::vector<std::string> ThemeInfoLoader::QueryThemeId() {
   tizen_base::Bundle b;
-  std::string val("get_ids");
-  b.Add("__QUERY__", val.c_str());
-
   tizen_base::Bundle reply =
     dbus::RequestBroker::GetInst().SendData(dbus::Command::GET_IDS, b);
+  if (reply.GetString(CMD_RESULT_KEY) == "error")
+    return {};
 
-  return reply.GetStringArray(val);
+  return reply.GetStringArray(CMD_GET_IDS_KEY);
 }
 
 void ThemeInfoLoader::SetCurrent(const std::string& id) {
   tizen_base::Bundle b;
-  b.Add("__SET_CURRENT__", id);
+  b.Add(CMD_SET_ID_KEY, id);
 
   tizen_base::Bundle reply =
     dbus::RequestBroker::GetInst().SendData(dbus::Command::SET_ID, b);
@@ -115,12 +115,14 @@ std::shared_ptr<ThemeInfo> ThemeInfoLoader::LoadCurrent() {
     return cache_;
 
   tizen_base::Bundle b;
-  b.Add("__LOAD__", "__CURRENT__");
+  b.Add(CMD_GET_KEY, "");
 
   tizen_base::Bundle reply =
     dbus::RequestBroker::GetInst().SendData(dbus::Command::GET, b);
+  std::string str = reply.GetString(CMD_GET_KEY);
+  tizen_base::Bundle serialized(str);
 
-  cache_ = std::make_shared<ThemeInfo>(reply);
+  cache_ = std::make_shared<ThemeInfo>(serialized);
 
   return cache_;
 }
@@ -130,12 +132,14 @@ std::shared_ptr<ThemeInfo> ThemeInfoLoader::Load(const std::string& id) const {
     return cache_;
 
   tizen_base::Bundle b;
-  b.Add("__LOAD__", id);
+  b.Add(CMD_GET_KEY, id);
 
   tizen_base::Bundle reply =
     dbus::RequestBroker::GetInst().SendData(dbus::Command::GET, b);
+  tizen_base::Bundle serialized(
+      reply.GetString(CMD_GET_KEY));
 
-  std::shared_ptr<ThemeInfo> info = std::make_shared<ThemeInfo>(reply);
+  std::shared_ptr<ThemeInfo> info = std::make_shared<ThemeInfo>(serialized);
 
   return info;
 }
index 6011962..0522459 100644 (file)
@@ -16,11 +16,11 @@ tizen_base::Bundle ControlRequestHandler::OnRequest(dbus::Command cmd,
   tizen_base::Bundle b;
   if (cmd != dbus::Command::SET_ID) {
     // this temporary return value should be fixed.
-    b.Add("result", "error");
+    b.Add(CMD_RESULT_KEY, "error");
     return b;
   }
-  bool r = proxy_->SetCurrentTheme(args.GetString("id"));
-  b.Add("result", r ? "ok" : "error");
+  bool r = proxy_->SetCurrentTheme(args.GetString(CMD_SET_ID_KEY));
+  b.Add(CMD_RESULT_KEY, r ? "ok" : "error");
   return b;
 }
 
index 690f319..963467b 100644 (file)
@@ -17,26 +17,29 @@ tizen_base::Bundle PackageEventRequestHandler::OnRequest(dbus::Command cmd,
     const tizen_base::Bundle& args) {
   bool result = false;
   switch (cmd) {
-    case dbus::Command::ADD:
-      result = InstallTheme(args);
+    case dbus::Command::ADD: {
+      tizen_base::Bundle b(args.GetString(CMD_ADD_KEY));
+      result = InstallTheme(b);
       break;
-    case dbus::Command::REMOVE:
-      result = UninstallTheme(args);
+    }
+    case dbus::Command::REMOVE: {
+      result = UninstallTheme(args.GetString(CMD_REMOVE_KEY));
       break;
-    case dbus::Command::UPDATE:
-      result = UpdateTheme(args);
+    }
+    case dbus::Command::UPDATE: {
+      tizen_base::Bundle b(args.GetString(CMD_UPDATE_KEY));
+      result = UpdateTheme(b);
       break;
-    default:
+    }
+    default: {
       LOG(ERROR) << "Invalid command type";
       break;
+    }
   }
 
   tizen_base::Bundle b;
   // this temporary return value should be fixed.
-  if (result)
-    b.Add("result", "ok");
-  else
-    b.Add("result", "error");
+  b.Add(CMD_RESULT_KEY, result ? "ok" : "error");
 
   return b;
 }
@@ -50,8 +53,8 @@ bool PackageEventRequestHandler::UpdateTheme(const tizen_base::Bundle& args) {
 }
 
 bool PackageEventRequestHandler::UninstallTheme(
-    const tizen_base::Bundle& args) {
-  return proxy_->RemoveTheme(args.GetString("id"));
+    const std::string& id) {
+  return proxy_->RemoveTheme(id);
 }
 
 }  // namespace provider
index fd72ac1..9dfe457 100644 (file)
@@ -27,7 +27,7 @@ class PackageEventRequestHandler : public dbus::IRequestHandler {
  private:
   bool InstallTheme(const tizen_base::Bundle& args);
   bool UpdateTheme(const tizen_base::Bundle& args);
-  bool UninstallTheme(const tizen_base::Bundle& args);
+  bool UninstallTheme(const std::string& id);
 
   std::shared_ptr<ThemeInfoProxy> proxy_;
 };
index e938b13..a15c731 100644 (file)
@@ -19,18 +19,26 @@ tizen_base::Bundle SelectionRequestHandler::OnRequest(dbus::Command cmd,
   tizen_base::Bundle b;
   switch (cmd) {
     case dbus::Command::GET: {
-      std::string id = args.GetString("id");
+      std::string id = args.GetString(CMD_GET_KEY);
       std::shared_ptr<loader::ThemeInfo> themeinfo = proxy_->LoadTheme(id);
-      return themeinfo->Serialize();
+      if (themeinfo == nullptr) {
+        b.Add(CMD_RESULT_KEY, "error");
+        return b;
+      }
+      b.Add(CMD_RESULT_KEY, "ok");
+      b.Add(CMD_GET_KEY,
+          reinterpret_cast<char*>(themeinfo->Serialize().ToRaw().first.get()));
+      return b;
     }
     case dbus::Command::GET_IDS: {
       std::vector<std::string> ids = proxy_->GetThemeIds();
-      b.Add("ids", ids);
+      b.Add(CMD_RESULT_KEY, "ok");
+      b.Add(CMD_GET_IDS_KEY, ids);
       return b;
     }
     default: {
       // this temporary return value should be fixed.
-      b.Add("result", "error");
+      b.Add(CMD_RESULT_KEY, "error");
       return b;
     }
   }
diff --git a/test/unit_tests/mock/glib_mock.cc b/test/unit_tests/mock/glib_mock.cc
deleted file mode 100644 (file)
index 4cbec6f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "unit_tests/mock/glib_mock.h"
-
-#include <cstdarg>
-#include <glib.h>
-
-#include "unit_tests/mock/mock_hook.h"
-#include "unit_tests/mock/test_fixture.h"
-
-extern "C" void g_variant_get(GVariant* value, const gchar* format_string,
-    ...) {
-  va_list ap;
-  va_start(ap, format_string);
-  int* ptr0 = va_arg(ap, int*);
-  if (!ptr0) {
-    va_end(ap);
-    return;
-  }
-  char** ptr1 = va_arg(ap, char**);
-  if (!ptr1) {
-    va_end(ap);
-    return;
-  }
-  MOCK_HOOK_P4(GlibMock, g_variant_get, value, format_string, ptr0, ptr1);
-  va_end(ap);
-}
diff --git a/test/unit_tests/mock/glib_mock.h b/test/unit_tests/mock/glib_mock.h
deleted file mode 100755 (executable)
index 96eda03..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_GLIB_MOCK_H_
-#define UNIT_TESTS_MOCK_GLIB_MOCK_H_
-
-#include <glib.h>
-#include <gmock/gmock.h>
-
-#include "mock/module_mock.h"
-
-class GlibMock : public virtual ModuleMock {
- public:
-  virtual ~GlibMock() {}
-  MOCK_METHOD4(g_variant_get, void(GVariant*, const gchar*, int*, char**));
-};
-
-#endif  // UNIT_TESTS_MOCK_GLIB_MOCK_H_
index 6469316..8e23668 100644 (file)
@@ -67,7 +67,7 @@ TEST_F(RequestHandlersTest, ControlRequestHandler_OnRequest) {
   proxy_->SaveTheme(info);
 
   tizen_base::Bundle b;
-  b.Add("id", "testid");
+  b.Add(CMD_SET_ID_KEY, "testid");
   handler.OnRequest(ttm::dbus::Command::SET_ID, b);
 
   auto cur = proxy_->GetLoadedTheme();
@@ -80,7 +80,9 @@ TEST_F(RequestHandlersTest, PackageRequestHandler_OnRequest) {
   PackageEventRequestHandler handler(proxy_);
 
   ThemeInfo info(b_);
-  tizen_base::Bundle b = info.Serialize();
+  tizen_base::Bundle b;
+  b.Add(CMD_ADD_KEY,
+      reinterpret_cast<char*>(info.Serialize().ToRaw().first.get()));
   handler.OnRequest(ttm::dbus::Command::ADD, b);
 
   auto theme = proxy_->LoadTheme("testid");
@@ -99,6 +101,8 @@ TEST_F(RequestHandlersTest, PackageRequestHandler_OnRequest) {
 
   ThemeInfo info2(v2);
   b = info2.Serialize();
+  b.Add(CMD_UPDATE_KEY,
+      reinterpret_cast<char*>(info2.Serialize().ToRaw().first.get()));
   handler.OnRequest(ttm::dbus::Command::UPDATE, b);
 
   theme = proxy_->LoadTheme("testid");
@@ -106,6 +110,7 @@ TEST_F(RequestHandlersTest, PackageRequestHandler_OnRequest) {
   EXPECT_EQ(theme->GetId(), "testid");
   EXPECT_EQ(theme->GetVersion(), "2.0");
 
+  b.Add(CMD_REMOVE_KEY, "testid");
   handler.OnRequest(ttm::dbus::Command::REMOVE, b);
   theme = proxy_->LoadTheme("testid");
   EXPECT_EQ(theme, nullptr);
@@ -131,13 +136,14 @@ TEST_F(RequestHandlersTest, SelectionRequestHandler_OnRequest) {
   proxy_->SaveTheme(info2);
 
   tizen_base::Bundle b;
-  b.Add("id", "testid");
+  b.Add(CMD_GET_KEY, "testid");
 
   auto rb = handler.OnRequest(ttm::dbus::Command::GET, b);
-  ThemeInfo theme(rb);
+  tizen_base::Bundle result(rb.GetString(CMD_GET_KEY));
+  ThemeInfo theme(result);
   EXPECT_EQ(theme.GetId(), "testid");
 
   rb = handler.OnRequest(ttm::dbus::Command::GET_IDS, {});
-  std::vector<std::string> ids = rb.GetStringArray("ids");
+  std::vector<std::string> ids = rb.GetStringArray(CMD_GET_IDS_KEY);
   EXPECT_EQ(ids.size(), 2);
 }
index 161b45b..2477a29 100644 (file)
@@ -25,7 +25,6 @@
 #include "theme/loader/theme_info.h"
 #include "theme/loader/theme_info_loader.h"
 #include "unit_tests/mock/gio_mock.h"
-#include "unit_tests/mock/glib_mock.h"
 #include "unit_tests/mock/test_fixture.h"
 
 using namespace ttm::loader;
@@ -44,8 +43,7 @@ class ThemeEvent : public IThemeEvent {
   }
 };
 
-class Mocks : public ::testing::NiceMock<GioMock>,
-              public ::testing::NiceMock<GlibMock> {};
+class Mocks : public ::testing::NiceMock<GioMock> {};
 
 class ThemeInfoLoaderTest : public TestFixture {
  public:
@@ -70,13 +68,20 @@ TEST_F(ThemeInfoLoaderTest, RemoveEvent_N) {
 TEST_F(ThemeInfoLoaderTest, QueryThemeId_N) {
   EXPECT_CALL(GetMock<GioMock>(), g_dbus_message_new_method_call(_, _, _, _)).
       WillOnce(Return(reinterpret_cast<GDBusMessage*>(1)));
+  GDBusMessage* msg =
+      reinterpret_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _)).
+          WillOnce(Return(msg));
   tizen_base::Bundle b;
   std::vector<std::string> ids_vec;
-  b.Add("ids", ids_vec);
+  b.Add(CMD_RESULT_KEY, "ok");
+  b.Add(CMD_GET_IDS_KEY, ids_vec);
   auto br = b.ToRaw();
   char* b_raw = reinterpret_cast<char*>(br.first.get());
-  EXPECT_CALL(GetMock<GlibMock>(), g_variant_get(_, _, _, _)).
-      WillOnce(SetArgPointee<3>(b_raw));
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_message_get_body(_)).WillOnce(
+          Return(reinterpret_cast<GVariant*>(g_variant_new("(s)", b_raw))));
 
   std::vector<std::string> ids = loader_->QueryThemeId();
   EXPECT_EQ(0, ids.size());
@@ -87,6 +92,25 @@ TEST_F(ThemeInfoLoaderTest, SetCurrent) {
 }
 
 TEST_F(ThemeInfoLoaderTest, LoadCurrent) {
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_message_new_method_call(_, _, _, _)).
+          WillOnce(Return(reinterpret_cast<GDBusMessage*>(1)));
+  GDBusMessage* msg =
+      reinterpret_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _)).
+          WillOnce(Return(msg));
+  tizen_base::Bundle b;
+  ThemeInfo ti;
+  b.Add(CMD_RESULT_KEY, "ok");
+  b.Add(CMD_GET_KEY,
+      reinterpret_cast<char*>(ti.Serialize().ToRaw().first.get()));
+  auto br = b.ToRaw();
+  char* b_raw = reinterpret_cast<char*>(br.first.get());
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_message_get_body(_)).WillOnce(
+          Return(reinterpret_cast<GVariant*>(g_variant_new("(s)", b_raw))));
+
   std::shared_ptr<ThemeInfo> info = loader_->LoadCurrent();
   EXPECT_NE(nullptr, info);
 }
@@ -95,7 +119,23 @@ TEST_F(ThemeInfoLoaderTest, Load) {
   EXPECT_CALL(GetMock<GioMock>(),
       g_dbus_message_new_method_call(StrEq("org.tizen.ThemeManager"),
           StrEq("/org/tizen/ThemeManager"), StrEq("org.tizen.ThemeManager"),
-          StrEq("SendData"))).Times(1);
+          StrEq("SendData"))).
+              WillOnce(Return(reinterpret_cast<GDBusMessage*>(1)));
+  GDBusMessage* msg =
+      reinterpret_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _)).
+          WillOnce(Return(msg));
+  tizen_base::Bundle b;
+  ThemeInfo ti;
+  b.Add(CMD_RESULT_KEY, "ok");
+  b.Add(CMD_GET_KEY,
+      reinterpret_cast<char*>(ti.Serialize().ToRaw().first.get()));
+  auto br = b.ToRaw();
+  char* b_raw = reinterpret_cast<char*>(br.first.get());
+  EXPECT_CALL(GetMock<GioMock>(),
+      g_dbus_message_get_body(_)).WillOnce(
+          Return(reinterpret_cast<GVariant*>(g_variant_new("(s)", b_raw))));
 
   std::shared_ptr<ThemeInfo> info = loader_->Load(std::string("id"));
   EXPECT_NE(nullptr, info);