Remove mock objects 60/206360/7
authorhyunho <hhstark.kang@samsung.com>
Fri, 17 May 2019 03:00:13 +0000 (12:00 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 22 May 2019 02:47:57 +0000 (02:47 +0000)
Let's replace mock objects with fff framework

Change-Id: Ie280e777bb365d20dffa536639297c74f0364dbc
Signed-off-by: hyunho <hhstark.kang@samsung.com>
32 files changed:
unittest/src/test-complication-provider.cc
unittest/src/test-complication.cc
unittest/src/test-design-element.cc
unittest/src/test-editables-container.cc
unittest/src/test-editables-manager.cc
unittest/src/test-editor.cc
watchface-complication-provider/complication-provider-implementation.h
watchface-complication-provider/complication-provider.cc
watchface-complication-provider/complication-provider.h
watchface-complication-provider/watchface-complication-provider.cc
watchface-complication/complication-connector.cc
watchface-complication/complication-connector.h
watchface-complication/complication-implementation.h
watchface-complication/complication.cc
watchface-complication/complication.h
watchface-complication/design-element-implementation.h
watchface-complication/design-element.cc
watchface-complication/design-element.h
watchface-complication/editables-container-implementation.h
watchface-complication/editables-container.cc
watchface-complication/editables-container.h
watchface-complication/editables-manager-implementation.h
watchface-complication/editables-manager.cc
watchface-complication/editables-manager.h
watchface-complication/gdbus-mock.h [deleted file]
watchface-complication/package-manager-mock.h [deleted file]
watchface-complication/watchface-complication.cc
watchface-complication/watchface-editable.cc
watchface-editor/editables-editor-implementation.h
watchface-editor/editables-editor.cc
watchface-editor/editables-editor.h
watchface-editor/watchface-editor.cc

index aba3f92..f2276b3 100644 (file)
 #include "unittest/mock/tzplatform_config_mock.h"
 #include "unittest/mock/app_common.h"
 #include "unittest/mock/mock_util.h"
+#include "unittest/mock/pkgmgr_mock.h"
+#include "unittest/mock/gio/gio.h"
+#include "unittest/mock/aul_mock.h"
+#include "unittest/mock/cynara_mock.h"
 
 using namespace std;
 using namespace watchface_complication;
@@ -37,6 +41,93 @@ const char* __fake_tzplatform_mkpath(
   return get_db_path();
 }
 
+int __cynara_initialize(
+      cynara** c, const cynara_configuration* conf) {
+  return 0;
+}
+
+int __cynara_finish(
+      cynara* c) {
+  return 0;
+}
+
+int __cynara_check(cynara* c, const char* client, const char* client_session,
+    const char* user,
+    const char* privilege) {
+  return CYNARA_API_ACCESS_ALLOWED;
+}
+
+int __cynara_creds_gdbus_get_user(GDBusConnection* connection,
+    const gchar* uniqueName, enum cynara_user_creds method, gchar** user) {
+  return CYNARA_API_SUCCESS;
+}
+
+int __cynara_creds_gdbus_get_client(GDBusConnection* connection,
+    const gchar* uniqueName, enum cynara_client_creds method, gchar** client) {
+  return CYNARA_API_SUCCESS;
+}
+
+gboolean __fake_g_dbus_connection_emit_signal(GDBusConnection * connection,
+                               const gchar* destination_bus_name,
+                               const gchar* object_path,
+                               const gchar* interface_name,
+                               const gchar* signal_name,
+                               GVariant* parameters,
+                               GError** error) {
+  return TRUE;
+}
+
+guint __fake_signal_subscribe_on_update(GDBusConnection* connection,
+                                    const gchar* sender,
+                                    const gchar* interface_name,
+                                    const gchar* member,
+                                    const gchar* object_path,
+                                    const gchar* arg0,
+                                    GDBusSignalFlags     flags,
+                                    GDBusSignalCallback  callback,
+                                    gpointer             user_data,
+                                    GDestroyNotify       user_data_free_func) {
+  return 1;
+}
+
+int __fake_aul_app_get_appid_bypid(int pid, char* appid, int size) {
+  snprintf(appid, size, "%s", "org.tizen.gmock_comp_provider2");
+  return 0;
+}
+
+int __fake_aul_get_app_shared_resource_path_by_appid(const char* appid,
+    char** path) {
+  *path = strdup("/opt/usr/share/org.tizen.gmock_comp_provider2/");
+  return 0;
+}
+
+
+GDBusConnection* __fake_g_bus_get_sync(GBusType type,
+        GCancellable* cancel, GError** err) {
+  return (GDBusConnection*)calloc(1, 4);
+}
+
+guint __fake_g_bus_own_name_on_connection(GDBusConnection* conn,
+        const gchar* name, GBusNameOwnerFlags flags,
+        GBusNameAcquiredCallback acquire_cb,
+        GBusNameLostCallback lost_cb, gpointer user_data,
+        GDestroyNotify noti) {
+  return 1;
+}
+
+pkgmgr_client* __fake_pkgmgr_client_new(pkgmgr_client_type type) {
+  return (pkgmgr_client*)calloc(1, 4);
+}
+
+int __fake_pkgmgr_client_free(pkgmgr_client* ) {
+  return 0;
+}
+
+char* __fake_app_get_data_path() {
+  string path = "./";
+  return strdup(path.c_str());
+}
+
 class WCP : public ::testing::Test {
  public:
   ComplicationProvider* provider;
@@ -44,7 +135,25 @@ class WCP : public ::testing::Test {
 
   virtual void SetUp(){
     tzplatform_mkpath_fake.custom_fake = __fake_tzplatform_mkpath;
-    provider = new ComplicationProvider(providerId.c_str(), true);
+    g_bus_get_sync_fake.custom_fake = __fake_g_bus_get_sync;
+    pkgmgr_client_new_fake.custom_fake = __fake_pkgmgr_client_new;
+    pkgmgr_client_free_fake.custom_fake = __fake_pkgmgr_client_free;
+    g_bus_own_name_on_connection_fake.custom_fake = __fake_g_bus_own_name_on_connection;
+    app_get_data_path_fake.custom_fake = __fake_app_get_data_path;
+
+    g_dbus_connection_signal_subscribe_fake.custom_fake = __fake_signal_subscribe_on_update;
+    aul_app_get_appid_bypid_fake.custom_fake = __fake_aul_app_get_appid_bypid;
+    aul_get_app_shared_resource_path_by_appid_fake.custom_fake =
+        __fake_aul_get_app_shared_resource_path_by_appid;
+    g_dbus_connection_emit_signal_fake.custom_fake =
+      __fake_g_dbus_connection_emit_signal;
+    cynara_initialize_fake.custom_fake = __cynara_initialize;
+    cynara_finish_fake.custom_fake = __cynara_finish;
+    cynara_check_fake.custom_fake = __cynara_check;
+    cynara_creds_gdbus_get_user_fake.custom_fake = __cynara_creds_gdbus_get_user;
+    cynara_creds_gdbus_get_client_fake.custom_fake = __cynara_creds_gdbus_get_client;
+
+    provider = new ComplicationProvider(providerId.c_str());
   }
   virtual void TearDown(){
     delete provider;
@@ -61,7 +170,6 @@ TEST_F(WCP, GetProviderId)
   EXPECT_STREQ(WCP::provider->GetProviderId().c_str(), providerId.c_str());
 }
 
-
 TEST_F(WCP, NotifyUpdate)
 {
   WCP::provider->NotifyDataUpdate();
index cb51b72..8056344 100644 (file)
@@ -55,7 +55,7 @@ class WatchComplication : public Complication {
                         const std::string& default_provider_id,
                         ComplicationType default_type)
     : Complication(id, supported_types, supported_event_types,
-        default_provider_id, default_type, false) {
+        default_provider_id, default_type) {
   }
   void OnProviderError(const std::string& provider_id,
       ComplicationType type, int error) override {
index bad826a..efd4127 100644 (file)
@@ -36,7 +36,7 @@ using namespace watchface_complication;
 class Element : public DesignElement {
  public:
   Element(int id, int cur_data_idx)
-    : DesignElement(id, cur_data_idx, true){
+    : DesignElement(id, cur_data_idx){
     SetLabel("Test");
     SetHighlight(std::unique_ptr<IEditable::Highlight>(
         new Highlight(
index 72341b9..d6a8101 100644 (file)
@@ -48,7 +48,7 @@ GMainLoop* ec_loop_ = nullptr;
 class Element : public DesignElement {
  public:
   Element(int id, int cur_data_idx)
-    : DesignElement(id, cur_data_idx, true){
+    : DesignElement(id, cur_data_idx){
     SetLabel("Test");
     SetHighlight(std::unique_ptr<IEditable::Highlight>(
         new Highlight(
@@ -64,8 +64,7 @@ class Element : public DesignElement {
 
 class MyContainer : public EditablesContainer {
  public:
-  MyContainer()
-    : EditablesContainer(false) {
+  MyContainer() : EditablesContainer() {
   }
 
   void OnUpdate(const IEditable& ed, int selected_idx,
index 1aca516..660a58e 100644 (file)
@@ -45,9 +45,9 @@ TEST_F(EDITABLES_MANAGER, StoreContext)
 {
   Bundle* bundle = new Bundle();
   bundle->Add("TEST_KEY", "TEST_VALUE");
-  EditablesManager::GetInst(true).StoreContext(10, "org.tizen.mock_provider/test",
+  EditablesManager::GetInst().StoreContext(10, "org.tizen.mock_provider/test",
         bundle);
-  int ret = EditablesManager::GetInst(true).DeleteContext(
+  int ret = EditablesManager::GetInst().DeleteContext(
         10, "org.tizen.mock_provider/test");
   EXPECT_EQ(ret, 0);
 }
\ No newline at end of file
index dcd77bb..5484591 100644 (file)
@@ -59,7 +59,7 @@ class WE : public ::testing::Test {
     cynara_finish_fake.custom_fake = __cynara_finish;
     cynara_check_fake.custom_fake = __cynara_check;
     received = nullptr;
-    editor = new EditablesEditor(true);
+    editor = new EditablesEditor();
   }
   virtual void TearDown(){
     if (received)
index 53c8491..ad6b568 100644 (file)
@@ -48,7 +48,7 @@ class ComplicationProvider::Impl : IGDBus::IGDBusEvent {
   void OnAppear(const std::string& name, const std::string& name_owner) override;
   std::list<std::string>& GetRequiredPrivileges();
   int NotifyProviderReady();
-  Impl(ComplicationProvider* parent, const std::string& provider_id, bool mock);
+  Impl(ComplicationProvider* parent, const std::string& provider_id);
   class SenderInfo {
    public:
     SenderInfo(const std::string& sender_name, const char* sender_app_id,
index ae43393..32eb92f 100644 (file)
 #include "watchface-complication-provider/complication-provider-implementation.h"
 #include "watchface-complication-provider/include/watchface-complication-provider.h"
 
+#ifdef LOGE
+#undef LOGE
+#endif
+#define LOGE printf
+
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
@@ -36,18 +41,18 @@ using namespace std;
 using namespace tizen_base;
 namespace watchface_complication {
 
-ComplicationProvider::ComplicationProvider(const std::string& provider_id, bool mock)
-                                       : impl_(new Impl(this, provider_id, mock)) {
+ComplicationProvider::ComplicationProvider(const std::string& provider_id)
+                                       : impl_(new Impl(this, provider_id)) {
   impl_->NotifyProviderReady();
 }
 
 ComplicationProvider::~ComplicationProvider() = default;
 
 ComplicationProvider::Impl::Impl(ComplicationProvider* parent,
-                                 const std::string& provider_id, bool mock)
+                                 const std::string& provider_id)
   : parent_(parent), provider_id_(provider_id),
-  gdbus_(std::unique_ptr<IGDBus>(ComplicationConnector::GetInst(mock).CreateGDBus(mock))),
-  mock_(mock) {
+  gdbus_(std::unique_ptr<IGDBus>(
+    ComplicationConnector::GetInst().CreateGDBus())) {
   int ret = util::CheckPrivilege(PRIVILEGE_DATASHARING);
   subscribe_id_ = gdbus_.get()->SubscribeSignal(
     IGDBus::Complication, provider_id_, -1, this);
index fe195d3..a8a6b11 100644 (file)
@@ -28,7 +28,7 @@ namespace watchface_complication {
 
 class EXPORT_API ComplicationProvider : public IComplicationEvent {
  public:
-  explicit ComplicationProvider(const std::string& provider_id, bool mock);
+  explicit ComplicationProvider(const std::string& provider_id);
   virtual ~ComplicationProvider(); /* LCOV_EXCL_LINE */
 
  public:
@@ -39,7 +39,8 @@ class EXPORT_API ComplicationProvider : public IComplicationEvent {
 
   int NotifyDataUpdate();
   const std::string& GetProviderId() const;
-  static bool SetupReplyToEditor(std::string editor_appid, int editable_id, const char* raw);
+  static bool SetupReplyToEditor(std::string editor_appid,
+      int editable_id, const char* raw);
 
  private:
   class Impl;
index cffd198..8564c1b 100644 (file)
@@ -93,7 +93,7 @@ class CallbackInfo {
 class WatchComplicationProviderStub : public ComplicationProvider {
  public:
   explicit WatchComplicationProviderStub(const std::string& provider_id)
-    : ComplicationProvider(provider_id, false) {
+    : ComplicationProvider(provider_id) {
   }
 
   void OnDataUpdateRequest(const std::string& sender_appid,
index 2a7e0f4..0436f90 100644 (file)
 #include "watchface-complication/complication-connector.h"
 #include "watchface-complication/complication-connector-implementation.h"
 #include "watchface-common/watchface-exception.h"
-#include "watchface-complication/gdbus-mock.h"
-#include "watchface-complication/package-manager-mock.h"
 #include "watchface-complication/package-manager.h"
 #include "watchface-complication/gdbus.h"
 
+#include <iostream>
+#ifdef LOGE
+#undef LOGE
+#endif
+#define LOGE printf
+
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
@@ -43,10 +47,10 @@ std::list<IPackageManager::IPackageEvent*> ComplicationConnector::Impl::package_
 std::list<std::string> ComplicationConnector::Impl::package_app_list_;
 std::string ComplicationConnector::Impl::current_pkg_event_;
 
-ComplicationConnector& ComplicationConnector::GetInst(bool mock) {
+ComplicationConnector& ComplicationConnector::GetInst() {
   static ComplicationConnector w_inst;
   int ret;
-  if (w_inst.impl_ == nullptr && !mock) {
+  if (w_inst.impl_ == nullptr) {
     ret = w_inst.Init();
     if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
       THROW(ret);
@@ -92,16 +96,12 @@ bool ComplicationConnector::EmitSignal(IGDBus::SigType type,
   return result;
 }
 
-IGDBus* ComplicationConnector::CreateGDBus(bool mock) {
-  return mock ?
-         static_cast<IGDBus*>(new test::GDBusMock()) :
-         static_cast<IGDBus*>(new GDBus(impl_->conn_));
+IGDBus* ComplicationConnector::CreateGDBus() {
+  return static_cast<IGDBus*>(new GDBus(impl_->conn_));
 }
 
-IPackageManager* ComplicationConnector::CreatePackageManager(bool mock) {
-  return mock ?
-         static_cast<IPackageManager*>(new test::PackageManagerMock()) :
-         static_cast<IPackageManager*>(new PackageManager());
+IPackageManager* ComplicationConnector::CreatePackageManager() {
+  return static_cast<IPackageManager*>(new PackageManager());
 }
 
 void ComplicationConnector::WatchPackageEvent(IPackageManager::IPackageEvent* pe) {
index c8dbbf1..9716ff0 100644 (file)
@@ -30,9 +30,9 @@ namespace watchface_complication {
 
 class EXPORT_API ComplicationConnector {
  public:
-  static ComplicationConnector& GetInst(bool mock = false);
-  IGDBus* CreateGDBus(bool mock);
-  IPackageManager* CreatePackageManager(bool mock);
+  static ComplicationConnector& GetInst();
+  IGDBus* CreateGDBus();
+  IPackageManager* CreatePackageManager();
   bool EmitSignal(IGDBus::SigType type, std::string target_id, std::string id,
     int sub_id, std::string cmd, GVariant* data);
   void WatchPackageEvent(IPackageManager::IPackageEvent* pe);
index 7e90542..6df44b5 100644 (file)
@@ -57,7 +57,7 @@ class Complication::Impl : IGDBus::IGDBusEvent, IPackageManager::IPackageEvent {
 
   Impl(Complication* parent, int id, int supported_types, int supported_event_types,
        const std::string& default_provider_id,
-       ComplicationType default_type, bool mock);
+       ComplicationType default_type);
   void RestoreStateOrSetDefault();
   int StoreSetting(int comp_id, std::string& provider_id,
                 ComplicationType type);
index 2753a0f..4714158 100644 (file)
@@ -48,9 +48,9 @@ const std::string Complication::Impl::supported_events_error_key_ = "__SUPPORTED
 const std::string Complication::Impl::privilege_error_key_ = "__PRIVILEGE_ERROR_KEY__";
 Complication::Complication(int id, int supported_types, int supported_event_types,
                            const std::string& default_provider_id,
-                           ComplicationType default_type, bool mock)
+                           ComplicationType default_type)
   : impl_(new Impl(this, id, supported_types, supported_event_types,
-      default_provider_id, default_type, mock)) {
+      default_provider_id, default_type)) {
 }
 
 Complication::~Complication() = default;
@@ -121,16 +121,17 @@ Complication::Impl::Impl(Complication* parent, int id,
                          int supported_types,
                          int supported_event_types,
                          const std::string& default_provider_id,
-                         ComplicationType default_type, bool mock)
+                         ComplicationType default_type)
   : parent_(parent), complication_id_(id), supported_types_(supported_types),
     supported_event_types_(supported_event_types | 1),
     default_provider_id_(default_provider_id),
     default_type_(default_type),
     cur_type_(default_type),
-    gdbus_(std::unique_ptr<IGDBus>(ComplicationConnector::GetInst(mock).CreateGDBus(mock))),
-    package_(std::unique_ptr<IPackageManager>(ComplicationConnector::GetInst(mock).CreatePackageManager(mock))),
-    editables_manager_(EditablesManager::GetInst(mock)),
-    mock_(mock) {
+    gdbus_(std::unique_ptr<IGDBus>(
+        ComplicationConnector::GetInst().CreateGDBus())),
+    package_(std::unique_ptr<IPackageManager>(
+        ComplicationConnector::GetInst().CreatePackageManager())),
+    editables_manager_(EditablesManager::GetInst()) {
   for (auto& i : complication_id_list_) {
     if (i == complication_id_) {
       LOGE("Exist complication id (%d)", complication_id_);
@@ -663,14 +664,6 @@ int Complication::SendDataUpdateRequest(bool launch_option) {
     return WATCHFACE_COMPLICATION_ERROR_PROVIDER_NOT_AVAILABLE;
   }
 
-  if (impl_->mock_) {
-    std::unique_ptr<Bundle> ptr = nullptr;
-    ptr = DBManager::GetDefaultData(impl_->cur_provider_id_.c_str(),
-        static_cast<int>(impl_->cur_type_));
-    OnDataUpdated(impl_->cur_provider_id_, impl_->cur_type_, ptr);
-    return WATCHFACE_COMPLICATION_ERROR_NONE;
-  }
-
   if (launch_option) {
     ret = aul_complication_update_request(
               util::GetAppId().c_str(),
index ed1c209..f793bff 100644 (file)
@@ -39,7 +39,7 @@ class EXPORT_API Complication : public IEditable
  public:
   Complication(int id, int supported_types, int supported_event_types,
                const std::string& default_provider_id,
-               ComplicationType default_type, bool mock);
+               ComplicationType default_type);
   virtual ~Complication();
 
  public:
index b160ad6..8f221dc 100644 (file)
@@ -36,7 +36,7 @@ class DesignElement::Impl {
 
  private:
   friend class DesignElement;
-  Impl(DesignElement* parent, int id, int cur_data_idx, bool mock);
+  Impl(DesignElement* parent, int id, int cur_data_idx);
   Impl(Impl const& other) = default;
   Impl(Impl && other) = default;
   Impl& operator=(Impl const& other) = default;
index 6a63c30..8e3715c 100644 (file)
@@ -33,8 +33,8 @@ using namespace std;
 using namespace tizen_base;
 namespace watchface_complication {
 
-DesignElement::DesignElement(int id, int cur_data_idx, bool mock)
-  : impl_(new Impl(this, id, cur_data_idx, mock)) {
+DesignElement::DesignElement(int id, int cur_data_idx)
+  : impl_(new Impl(this, id, cur_data_idx)) {
 }
 
 /* LCOV_EXCL_START */
@@ -43,10 +43,9 @@ DesignElement::~DesignElement() {
 }
 /* LCOV_EXCL_STOP */
 
-DesignElement::Impl::Impl(DesignElement* parent, int id,
-                          int cur_data_idx, bool mock)
+DesignElement::Impl::Impl(DesignElement* parent, int id, int cur_data_idx)
   : parent_(parent), id_(id), cur_data_idx_(cur_data_idx),
-    editables_manager_(EditablesManager::GetInst(mock)), mock_(mock) {
+    editables_manager_(EditablesManager::GetInst()) {
   last_data_idx_ = cur_data_idx_;
 }
 
index 7255af6..53d6963 100644 (file)
@@ -30,7 +30,7 @@ namespace watchface_complication {
 
 class EXPORT_API DesignElement : public IEditable {
  public:
-  DesignElement(int id, int cur_data_idx, bool mock);
+  DesignElement(int id, int cur_data_idx);
   virtual ~DesignElement();
   DesignElement(DesignElement const& other) = default;
   DesignElement(DesignElement && other) = default;
index 887ab8a..7e71326 100644 (file)
@@ -45,7 +45,7 @@ class EditablesContainer::Impl : IGDBus::IGDBusEvent {
   void OnVanish(const std::string& name) override;
   void OnAppear(const std::string& name, const std::string& name_owner) override;
   void CancelEditing();
-  explicit Impl(EditablesContainer* parent, bool mock);
+  explicit Impl(EditablesContainer* parent);
   Impl(Impl const& other) = default;
   Impl(Impl && other) = default;
   Impl& operator=(Impl const& other) = default;
index cbe5d59..07461bb 100644 (file)
@@ -40,14 +40,15 @@ using namespace std;
 using namespace tizen_base;
 namespace watchface_complication {
 
-EditablesContainer::EditablesContainer(bool mock)
-  : impl_(new Impl(this, mock)) {
+EditablesContainer::EditablesContainer()
+  : impl_(new Impl(this)) {
 }
 
 EditablesContainer::~EditablesContainer() = default;
-EditablesContainer::Impl::Impl(EditablesContainer* parent, bool mock)
+EditablesContainer::Impl::Impl(EditablesContainer* parent)
   : parent_(parent),
-  gdbus_(std::unique_ptr<IGDBus>(ComplicationConnector::GetInst(mock).CreateGDBus(mock))) {
+  gdbus_(std::unique_ptr<IGDBus>(
+      ComplicationConnector::GetInst().CreateGDBus())) {
   subscribe_id_ = gdbus_.get()->SubscribeSignal(
                     IGDBus::Editable,
                     util::GetAppId(), -1, this);
index 5f948bd..f3afa3c 100644 (file)
@@ -29,7 +29,7 @@ namespace watchface_complication {
 
 class EXPORT_API EditablesContainer : IEditablesEditorEvent {
  public:
-  EditablesContainer(bool mock);
+  EditablesContainer();
   virtual ~EditablesContainer(); /* LCOV_EXCL_LINE */
   int Add(std::shared_ptr<IEditable> ed, int editable_id);
   int Remove(std::shared_ptr<IEditable> ed);
index 81103dd..a1663b1 100644 (file)
@@ -41,16 +41,15 @@ class EditablesManager::Impl {
  private:
   friend class EditablesManager;
   Impl();
-  static std::string GetEditablesDataPath(bool mock) {
-    char* app_data_path = mock ? (char*)"/tmp/" : app_get_data_path();
+  static std::string GetEditablesDataPath() {
+    char* app_data_path = app_get_data_path();
     char setting_data_path[PATH_MAX] = {0, };
 
     if (app_data_path != NULL) {
       snprintf(setting_data_path, PATH_MAX, "%s.watchface_editables.db",
           app_data_path);
       LOGI("get setting data path %s", setting_data_path);
-      if (!mock)
-        free(app_data_path);
+      free(app_data_path);
     }
 
     return std::string(setting_data_path);
index 3f9e31f..f8acdff 100644 (file)
 using namespace tizen_base;
 namespace watchface_complication {
 
-EditablesManager& EditablesManager::GetInst(bool mock) {
+EditablesManager& EditablesManager::GetInst() {
   static EditablesManager w_inst;
   int ret;
 
   if (w_inst.impl_ == nullptr) {
-    ret = w_inst.Init(mock);
+    ret = w_inst.Init();
     if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
       THROW(ret);
   }
@@ -51,7 +51,7 @@ EditablesManager::EditablesManager() = default;
 EditablesManager::~EditablesManager() = default;
 EditablesManager::Impl::Impl() = default;
 
-int EditablesManager::Init(bool mock) {
+int EditablesManager::Init() {
   int ret;
   int open_flags = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
   std::unique_ptr<Impl> tmp_impl
@@ -71,7 +71,7 @@ int EditablesManager::Init(bool mock) {
     "CREATE TABLE IF NOT EXISTS editable_setting" \
     "(editable_id INTEGER NOT NULL, setting_data TEXT NOT NULL, "\
     "PRIMARY KEY(editable_id))";
-  std::string db_path = tmp_impl->GetEditablesDataPath(mock);
+  std::string db_path = tmp_impl->GetEditablesDataPath();
   if (db_path.empty()) {
     LOGE("GetSettingDataPath failed");
     return WATCHFACE_COMPLICATION_ERROR_DB;
index 09d3ee5..4b0f3e1 100644 (file)
@@ -28,7 +28,7 @@ namespace watchface_complication {
 
 class EXPORT_API EditablesManager {
  public:
-  static EditablesManager& GetInst(bool mock = false);
+  static EditablesManager& GetInst();
   int StoreSetting(int editable_id, bundle_raw* raw_data);
   std::unique_ptr<tizen_base::Bundle> LoadSetting(int editable_id);
   int StoreContext(int editable_id, const char* provider_id,
@@ -40,7 +40,7 @@ class EXPORT_API EditablesManager {
  private:
   EditablesManager();
   virtual ~EditablesManager();
-  int Init(bool mock);
+  int Init();
 
  private:
   class Impl;
diff --git a/watchface-complication/gdbus-mock.h b/watchface-complication/gdbus-mock.h
deleted file mode 100644 (file)
index 04e00ea..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-#ifndef WATCHFACE_COMPLICATION_GDBUS_MOCK_H_
-#define WATCHFACE_COMPLICATION_GDBUS_MOCK_H_
-
-#include <glib.h>
-
-#include <memory>
-
-#include "watchface-complication/gdbus-interface.h"
-
-namespace watchface_complication {
-namespace test {
-
-class GDBusMock : public IGDBus {
- public:
-  GDBusMock() { }
-
-  virtual ~GDBusMock() {
-  }
-
-  int Watch(std::string appid, IGDBus::IGDBusEvent* listener) {
-    return 0;
-  }
-
-  void UnWatch(int watcher_id) {
-  }
-
-  bool EmitSignal(SigType type, std::string target_id, std::string id,
-      int sub_id, std::string cmd, GVariant* data) {
-    return true;
-  }
-
-  void UnSubscribeSignal(int subscribe_id) {
-
-  }
-
-  int SubscribeSignal(SigType type, std::string id,
-      int sub_id, IGDBus::IGDBusEvent* listener) {
-    return 1;
-  }
-
- private:
-  static void SignalCb(GDBusConnection* connection,
-                      const gchar* sender_name,
-                      const gchar* object_path,
-                      const gchar* interface_name,
-                      const gchar* signal_name,
-                      GVariant* parameters,
-                      void* user_data) {
-    IGDBus::IGDBusEvent* rs = static_cast<IGDBus::IGDBusEvent*>(user_data);
-
-    rs->OnSignal(connection, sender_name, object_path, interface_name,
-                 signal_name, parameters);
-  }
-
-  static void VanishCb(GDBusConnection* connection,
-      const gchar* name, gpointer user_data) {
-    IGDBus::IGDBusEvent* rs = static_cast<IGDBus::IGDBusEvent*>(user_data);
-    rs->OnVanish(name);
-  }
-
-  static void AppearCb(GDBusConnection* connection,
-      const gchar* name, const gchar* name_owner, gpointer user_data) {
-    IGDBus::IGDBusEvent* rs = static_cast<IGDBus::IGDBusEvent*>(user_data);
-    rs->OnAppear(name, name_owner);
-  }
-
- private:
-};
-
-}  // namespace test
-}  // namespace watchface_complication
-
-#endif  // WATCHFACE_COMPLICATION_GDBUS_MOCK_H_
diff --git a/watchface-complication/package-manager-mock.h b/watchface-complication/package-manager-mock.h
deleted file mode 100644 (file)
index 7a50d1a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2018 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.
- */
-
-#ifndef WATCHFACE_COMPLICATION_PACKAGE_MANAGER_MOCK_H_
-#define WATCHFACE_COMPLICATION_PACKAGE_MANAGER_MOCK_H_
-
-#include <unistd.h>
-#include <dlog.h>
-
-#include <memory>
-#include <list>
-
-#include "watchface-common/watchface-util.h"
-#include "watchface-complication/gdbus-interface.h"
-
-#define COMPLICATION_INTERFACE "org.tizen.watchface_complication"
-
-namespace watchface_complication {
-namespace test {
-
-class PackageManagerMock : public IPackageManager {
- public:
-  PackageManagerMock() {
-  }
-
-  void Watch(IPackageEvent* pe) override {
-    pe_list_.push_back(pe);
-    if (event_timer_ > 0)
-      g_source_remove(event_timer_);
-
-    event_timer_ = g_timeout_add(1000, [](gpointer user_data)->gboolean {
-          PackageManagerMock* mock = static_cast<PackageManagerMock*>(user_data);
-          static int seq = 0;
-          for (IPackageManager::IPackageEvent* pe : mock->pe_list_) {
-            if (seq++ % 2 == 0)
-              pe->OnAppDisabled("org.tizen.gmock_comp_provider");
-            else
-              pe->OnAppUninstalled("org.tizen.gmock_comp_provider");
-          }
-          return G_SOURCE_CONTINUE;
-        }, this);
-  }
-
-  void UnWatch(IPackageEvent* pe) override {
-    for (IPackageManager::IPackageEvent* i : pe_list_) {
-      if (i == pe) {
-        pe_list_.remove(i);
-        if (event_timer_ > 0) {
-          g_source_remove(event_timer_);
-        }
-        return;
-      }
-    }
-  }
-
-  bool CheckDisabled(const std::string& appid) override {
-    return true;
-  }
-
-  ~PackageManagerMock() {
-  }
-
- public:
-  std::list<IPackageEvent*> pe_list_;
-
- private:
-  unsigned int event_timer_ = 0;
-};
-
-}  // namespace test
-}  // namespace watchface_complication
-
-#endif  // WATCHFACE_COMPLICATION_PACKAGE_MANAGER_MOCK_H_
\ No newline at end of file
index 7476e45..415634f 100644 (file)
@@ -132,7 +132,7 @@ class WatchComplicationStub : public Complication {
                         const std::string& default_provider_id,
                         ComplicationType default_type)
     : Complication(id, supported_types, supported_event_types,
-        default_provider_id, default_type, false) {
+        default_provider_id, default_type) {
   }
   /* LCOV_EXCL_START */
   void OnProviderError(const std::string& provider_id, ComplicationType type,
index 1d3bb79..1d245d3 100644 (file)
@@ -103,7 +103,7 @@ class UpdateCallbackInfo {
 class EditablesContainerStub : public EditablesContainer {
  public:
   EditablesContainerStub()
-    : EditablesContainer(false) {
+    : EditablesContainer() {
   }
 
   void OnEditReady(const std::string& editor_id) override {
@@ -219,7 +219,7 @@ extern "C" EXPORT_API int watchface_editable_add_design_element(
 
   try {
     auto de = std::shared_ptr<IEditable>(
-      new DesignElement(edit_id, cur_data_idx, false));
+      new DesignElement(edit_id, cur_data_idx));
     if (highlight) {
       std::unique_ptr<IEditable::Highlight> hi_ptr =
           __get_highlight_unique_ptr(highlight);
index 60b526e..290c1dc 100644 (file)
@@ -46,7 +46,7 @@ class EditablesEditor::Impl : IGDBus::IGDBusEvent {
   void OnVanish(const std::string& name) override;
   void OnAppear(const std::string& name, const std::string& name_owner) override;
   int CheckPrivilege();
-  explicit Impl(EditablesEditor* parent, bool mock);
+  explicit Impl(EditablesEditor* parent);
   Impl(Impl const& other) = default;
   Impl(Impl && other) = default;
   Impl& operator=(Impl const& other) = default;
index 0674d88..6fc3bce 100644 (file)
@@ -36,14 +36,15 @@ using namespace std;
 using namespace tizen_base;
 namespace watchface_complication {
 
-EditablesEditor::EditablesEditor(bool mock)
-  : impl_(new Impl(this, mock)) {
+EditablesEditor::EditablesEditor()
+  : impl_(new Impl(this)) {
 }
 
 EditablesEditor::~EditablesEditor() = default;
-EditablesEditor::Impl::Impl(EditablesEditor* parent, bool mock)
+EditablesEditor::Impl::Impl(EditablesEditor* parent)
   : parent_(parent),
-  gdbus_(std::unique_ptr<IGDBus>(ComplicationConnector::GetInst(mock).CreateGDBus(mock))) {
+  gdbus_(std::unique_ptr<IGDBus>(
+      ComplicationConnector::GetInst().CreateGDBus())) {
   subscribe_id_ = gdbus_.get()->SubscribeSignal(IGDBus::Editable,
                     util::GetAppId(), -1, this);
   LOGI("subscribe signal %d", subscribe_id_);
index 4b19441..ae28bc7 100644 (file)
@@ -30,7 +30,7 @@ namespace watchface_complication {
 
 class EXPORT_API EditablesEditor : IEditablesContainerEvent {
  public:
-  EditablesEditor(bool mock);
+  EditablesEditor();
   virtual ~EditablesEditor();
   void OnRequestEdit(const std::string& appid,
                      std::list<std::unique_ptr<IEditable>> e_list) override;
index a784ba7..cfb7b7d 100644 (file)
@@ -100,8 +100,7 @@ class SetupCallbackInfo {
 
 class EditablesEditorStub : public EditablesEditor {
  public:
-  EditablesEditorStub()
-    : EditablesEditor(false) {
+  EditablesEditorStub() : EditablesEditor() {
   }
 
   virtual ~EditablesEditorStub() = default;