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 aba3f925fa5fb7a13258920a3d44846be3a854ab..f2276b38fa5eb19f02780d271a540e9822ad7dd6 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 cb51b722f2314cf9ca975e199647b07f8819e411..805634420e7bf588d8198b660b7be2385346309a 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 bad826a27ef1ff0c7008026ca6f514f4e7616ad7..efd412765c1bfc6a0d00c58951a8adac42e324ac 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 72341b9387dfc25461d82c6a31803be3797acf72..d6a81014aebc77b2ac73a7a58da21dce3f5abd83 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 1aca5162f39fea7c79aab74b27d444842de55cab..660a58e9e4b81056053ac158801bcb0c194a9fed 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 dcd77bb415e26fb455cd39fe3d807534093dcf19..548459197213a9d3a332cbc7d133843f3fb9eb12 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 53c84918138c08158debd5ae820cc4a03d5aeefd..ad6b56852b404b391367f6312edcb28285654d75 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 ae43393a7fd16d66ec861fdfc4891288e0aef807..32eb92f455e1a44cf070c91dd99247e65c735f62 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 fe195d351c24245b9b4e98ae0beea8488152a8a4..a8a6b1150b344e6b7f027098cfbc3456413dd362 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 cffd1982b8360b001379a113e26551556e5506a0..8564c1b1254707114bb7c97f5a1e0c03c13afb00 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 2a7e0f4cf2b0fb30364c1f009717cc8a04c46a68..0436f9086919fb0c00d2eee4e3179e3e93828f13 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 c8dbbf1cb193b73063d60c9f3101942e99d74fb5..9716ff0303da012c06409752b928add5228b6dde 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 7e90542ead1ecd60588193b36151a2f3816ead70..6df44b5ee34c822e2819fcbe3ee0e98d521a7f14 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 2753a0fc4b55f2a487feba63f6a4b4ff34156bd0..4714158ef41b60aade34801cd27bc75c2014c51a 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 ed1c2090e2e5e4ba93e3c901de541c16f29ddebf..f793bff0cac36a6bd9769f5dc480fe95858163c5 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 b160ad637582a28a5b80ce16051d7c85277f0dc1..8f221dcbd691044b6d89cad308cde7a294a1fb9e 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 6a63c30c6d1c7c8533f41cc38545f391a4efca4b..8e3715c4efcef7a037e457a72040f71d71e10660 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 7255af647e0ffa2a566c78f48b799176f8c57c7d..53d6963da10bdf3006abf8f19ac24c36077e8dc5 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 887ab8a265ff69a037e3f539f6572158dd48e6f8..7e713269b140cd927b5aa93924355e21ea3920be 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 cbe5d5977463ea01246835ec379f5af79244e6d9..07461bb2dace6c91e6d876be93fb7598a534d821 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 5f948bd11d0cf79f096b66fb785dbb4642e5542c..f3afa3cbd5d1bd640fecf650989f185352f76974 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 81103dd9ca2f6bd2cc1e80044ad4232205a40e5d..a1663b1718e37aee2d09933946ee3a94574a3ed9 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 3f9e31f5c07537d28f7419132bcea69c18105646..f8acdff2063b68b9db3b62a8ccd11121f28a779d 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 09d3ee51e875edcd1910f78f42abddfc481a6f4b..4b0f3e1de5f1f22cf6b4fe83b06bb24e27833790 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 7476e4572372fe98af628292c1531732d0e78b5d..415634f42b1161e2d93e7bd9e10e3e3e5473f983 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 1d3bb79e91c41bc310b6d0191da80a95eefa85b7..1d245d3e75ef46a407b184b97cda2bb277fd2342 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 60b526e7df885f562651f50a8e8469d3ad5cb92f..290c1dcdb702c16b139a8c7273ea139bbb1ba7ba 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 0674d889c69b358e3c8ac1988fb664b83a422257..6fc3bceb8242fd103240d8d9dee0315003379cd0 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 4b19441ff349f92623f41017efc5e06e218a6986..ae28bc71f1220d3c87503c207fd40e9278c53131 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 a784ba7f222dc139bfff025d3ac86c2cbac45290..cfb7b7d50e3115d737ee582e829777005eeccf82 100644 (file)
@@ -100,8 +100,7 @@ class SetupCallbackInfo {
 
 class EditablesEditorStub : public EditablesEditor {
  public:
-  EditablesEditorStub()
-    : EditablesEditor(false) {
+  EditablesEditorStub() : EditablesEditor() {
   }
 
   virtual ~EditablesEditorStub() = default;