Create FactoryManager to register the other factory 50/201150/3
authorJunghoon Park <jh9216.park@samsung.com>
Mon, 11 Mar 2019 02:10:28 +0000 (11:10 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 11 Mar 2019 02:33:46 +0000 (11:33 +0900)
Change-Id: Ibd3b9131be2cba08796e04d4d3be459159442134
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
30 files changed:
notification-ex/button_item.cc
notification-ex/chat_message_item.cc
notification-ex/checkbox_item.cc
notification-ex/default_item_factory.cc [moved from notification-ex/item_factory.cc with 91% similarity]
notification-ex/default_item_factory.h [new file with mode: 0644]
notification-ex/entry_item.cc
notification-ex/factory_manager.cc [new file with mode: 0644]
notification-ex/factory_manager.h [new file with mode: 0644]
notification-ex/group_item.cc
notification-ex/icon_text_item.cc
notification-ex/iitem_factory.h [moved from notification-ex/item_factory.h with 78% similarity]
notification-ex/image_item.cc
notification-ex/input_selector_item.cc
notification-ex/item_inflator.cc
notification-ex/item_inflator.h
notification-ex/progress_item.cc
notification-ex/text_item.cc
notification-ex/time_item.cc
unittest/src/test_button_item.cc
unittest/src/test_chat_message_item.cc
unittest/src/test_checkbox_item.cc
unittest/src/test_entry_item.cc
unittest/src/test_group_item.cc
unittest/src/test_icon_item.cc
unittest/src/test_icon_text_item.cc
unittest/src/test_image_item.cc
unittest/src/test_input_selector_item.cc
unittest/src/test_progress_item.cc
unittest/src/test_text_item.cc
unittest/src/test_time_item.cc

index f4a33d8..0ac2858 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "notification-ex/button_item.h"
 #include "notification-ex/button_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -66,7 +66,7 @@ void ButtonItem::Deserialize(Bundle b) {
 AbstractItem& ButtonItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 std::string ButtonItem::GetTitle() const {
index e674709..0f88986 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "notification-ex/chat_message_item.h"
 #include "notification-ex/chat_message_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -66,23 +66,25 @@ Bundle ChatMessageItem::Serialize() {
 }
 
 void ChatMessageItem::Deserialize(Bundle b) {
-  ItemFactory factory;
-
   AbstractItem::Deserialize(b);
 
-  std::shared_ptr<AbstractItem> name = factory.CreateItem(AbstractItem::Text);
+  std::shared_ptr<AbstractItem> name =
+      FactoryManager::GetInst().CreateItem(AbstractItem::Text);
   name.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_NAME_KEY)));
   impl_->name_ = std::static_pointer_cast<TextItem>(name);
 
-  std::shared_ptr<AbstractItem> text = factory.CreateItem(AbstractItem::Text);
+  std::shared_ptr<AbstractItem> text =
+      FactoryManager::GetInst().CreateItem(AbstractItem::Text);
   text.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TEXT_KEY)));
   impl_->text_ = std::static_pointer_cast<TextItem>(text);
 
-  std::shared_ptr<AbstractItem> data = factory.CreateItem(AbstractItem::Text);
+  std::shared_ptr<AbstractItem> data =
+      FactoryManager::GetInst().CreateItem(AbstractItem::Text);
   data.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_DATA_KEY)));
   impl_->data_ = std::static_pointer_cast<TextItem>(data);
 
-  std::shared_ptr<AbstractItem> time = factory.CreateItem(AbstractItem::Time);
+  std::shared_ptr<AbstractItem> time =
+      FactoryManager::GetInst().CreateItem(AbstractItem::Time);
   time.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TIME_KEY)));
   impl_->time_ = std::static_pointer_cast<TimeItem>(time);
 
@@ -93,7 +95,7 @@ AbstractItem&  ChatMessageItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
 
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 TextItem& ChatMessageItem::GetNameItem() const {
index c4e1e0c..73211d2 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "notification-ex/checkbox_item.h"
 #include "notification-ex/checkbox_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -64,7 +64,7 @@ AbstractItem& CheckBoxItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
 
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 std::string CheckBoxItem::GetTitle(void) const {
similarity index 91%
rename from notification-ex/item_factory.cc
rename to notification-ex/default_item_factory.cc
index 1dc20ee..569b4d9 100644 (file)
 
 #include <memory>
 
-#include "notification-ex/item_factory.h"
+#include "notification-ex/default_item_factory.h"
 #include "notification-ex/button_item.h"
 #include "notification-ex/group_item.h"
-#include "notification-ex/null_item.h"
 #include "notification-ex/entry_item.h"
 #include "notification-ex/text_item.h"
 #include "notification-ex/exception.h"
@@ -44,7 +43,7 @@ using namespace std;
 namespace notification {
 namespace item {
 
-unique_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
+unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(AbstractItem::Type type) {
   switch (type) {
   case AbstractItem::NullObject :
     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
@@ -80,10 +79,5 @@ unique_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
   return nullptr;
 }
 
-AbstractItem& ItemFactory::GetNullItem() {
-  static NullItem item;
-  return item;
-}
-
 }  // namespace item
 }  // namespace notification
diff --git a/notification-ex/default_item_factory.h b/notification-ex/default_item_factory.h
new file mode 100644 (file)
index 0000000..489bd40
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_
+#define NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_
+
+#include <memory>
+
+#include "notification-ex/iitem_factory.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API DefaultItemFactory : public IItemFactory {
+ public:
+  virtual ~DefaultItemFactory() = default;
+  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
+};
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_
index b3a1674..143a311 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "notification-ex/entry_item.h"
 #include "notification-ex/entry_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -69,7 +69,7 @@ void EntryItem::Deserialize(Bundle b) {
 AbstractItem& EntryItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 std::string EntryItem::GetText() const {
diff --git a/notification-ex/factory_manager.cc b/notification-ex/factory_manager.cc
new file mode 100644 (file)
index 0000000..19df26f
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2019 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 <dlog.h>
+
+#include "notification-ex/factory_manager.h"
+#include "notification-ex/default_item_factory.h"
+#include "notification-ex/null_item.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+using namespace std;
+namespace notification {
+namespace item {
+
+FactoryManager& FactoryManager::GetInst() {
+  static FactoryManager manager;
+
+  return manager;
+}
+
+void FactoryManager::RegisterFactory(std::unique_ptr<IItemFactory> factory) {
+  factory_ = std::move(factory);
+}
+
+std::unique_ptr<AbstractItem> FactoryManager::CreateItem(
+    AbstractItem::Type type) {
+  if (factory_.get() == nullptr)
+    factory_.reset(new DefaultItemFactory());
+
+  return factory_->CreateItem(type);
+}
+
+AbstractItem& FactoryManager::GetNullItem() {
+  static NullItem item;
+  return item;
+}
+
+}  // namespace item
+}  // namespace notification
diff --git a/notification-ex/factory_manager.h b/notification-ex/factory_manager.h
new file mode 100644 (file)
index 0000000..e203000
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_FACTORY_MANAGER_H_
+#define NOTIFICATION_EX_FACTORY_MANAGER_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/iitem_factory.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API FactoryManager {
+ public:
+  static FactoryManager& GetInst();
+  void RegisterFactory(std::unique_ptr<IItemFactory> factory);
+  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
+  AbstractItem& GetNullItem();
+
+ private:
+  FactoryManager() {}
+
+ private:
+  std::unique_ptr<IItemFactory> factory_;
+};
+
+}  // namespace item
+}  // namespace notification
+
+#endif  // NOTIFICATION_EX_FACTORY_MANAGER_H_
index f3fa086..2b52644 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "notification-ex/group_item.h"
 #include "notification-ex/group_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -90,13 +90,13 @@ void GroupItem::Deserialize(Bundle b) {
   if (str_arr.size() == 0)
     return;
 
-  ItemFactory factory;
   for (string str : str_arr) {
     Bundle serialized(str);
     string type_str = serialized.GetString(GROUP_CHILDREN_TYPE_KEY);
     AbstractItem::Type child_type =
         static_cast<AbstractItem::Type>(strtol(type_str.c_str(), NULL, 10));
-    shared_ptr<AbstractItem> child = factory.CreateItem(child_type);
+    shared_ptr<AbstractItem> child =
+        FactoryManager::GetInst().CreateItem(child_type);
     child.get()->Deserialize(serialized);
     AddChild(child);
   }
@@ -107,7 +107,7 @@ AbstractItem& GroupItem::FindByID(std::string id) {
     if (i.get()->GetId() == id)
       return *i;
   }
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 void GroupItem::AddChild(shared_ptr<AbstractItem> child) {
index 80c62ee..bac2a7b 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "notification-ex/icon_text_item.h"
 #include "notification-ex/icon_text_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -56,15 +56,15 @@ Bundle IconTextItem::Serialize() {
 }
 
 void IconTextItem::Deserialize(Bundle b) {
-  ItemFactory factory;
-
   AbstractItem::Deserialize(b);
 
-  std::shared_ptr<AbstractItem> icon = factory.CreateItem(AbstractItem::Icon);
+  std::shared_ptr<AbstractItem> icon =
+      FactoryManager::GetInst().CreateItem(AbstractItem::Icon);
   icon.get()->Deserialize(Bundle(b.GetString(ICONTEXT_PATH_KEY)));
   impl_->icon_ = std::static_pointer_cast<IconItem>(icon);
 
-  std::shared_ptr<AbstractItem> text = factory.CreateItem(AbstractItem::Text);
+  std::shared_ptr<AbstractItem> text =
+    FactoryManager::GetInst().CreateItem(AbstractItem::Text);
   text.get()->Deserialize(Bundle(b.GetString(ICONTEXT_TITLE_KEY)));
   impl_->text_ = std::static_pointer_cast<TextItem>(text);
 }
@@ -73,7 +73,7 @@ AbstractItem& IconTextItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
 
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 IconItem& IconTextItem::GetIconItem() const {
similarity index 78%
rename from notification-ex/item_factory.h
rename to notification-ex/iitem_factory.h
index 70249f1..aec8652 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef NOTIFICATION_EX_ITEM_FACTORY_H_
-#define NOTIFICATION_EX_ITEM_FACTORY_H_
+#ifndef NOTIFICATION_EX_IITEM_FACTORY_H_
+#define NOTIFICATION_EX_IITEM_FACTORY_H_
 
 #include <string>
 #include <memory>
 namespace notification {
 namespace item {
 
-class EXPORT_API ItemFactory {
+class EXPORT_API IItemFactory {
  public:
-  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
-  static AbstractItem& GetNullItem();
+  virtual ~IItemFactory() = default;
+  virtual std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type) = 0;
 };
 
 }  // namespace item
index 991f16c..4c437b9 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "notification-ex/image_item.h"
 #include "notification-ex/image_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -64,7 +64,7 @@ AbstractItem& ImageItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
 
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 std::string ImageItem::GetImagePath() const {
index 73f4f7b..17385a7 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "notification-ex/input_selector_item.h"
 #include "notification-ex/input_selector_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -71,7 +71,7 @@ void InputSelectorItem::Deserialize(Bundle b) {
 AbstractItem& InputSelectorItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 list<string> InputSelectorItem::GetContents() const {
index 183f940..ffb014f 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <memory>
 
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/item_inflator.h"
 
 #ifdef LOG_TAG
@@ -31,8 +31,9 @@ using namespace std;
 namespace notification {
 namespace item {
 
-shared_ptr<AbstractItem> ItemInflator::Create(ItemFactory factory, Bundle b) {
-  shared_ptr<AbstractItem> item = factory.CreateItem(AbstractItem::GetType(b));
+shared_ptr<AbstractItem> ItemInflator::Create(Bundle b) {
+  shared_ptr<AbstractItem> item =
+      FactoryManager::GetInst().CreateItem(AbstractItem::GetType(b));
   item.get()->Deserialize(b);
   return item;
 }
index b0a4122..0f2e9df 100644 (file)
 #include <list>
 
 #include "notification-ex/abstract_item.h"
-#include "notification-ex/item_factory.h"
 
 namespace notification {
 namespace item {
 
 class EXPORT_API ItemInflator {
  public:
-  static std::shared_ptr<AbstractItem> Create(ItemFactory factory, Bundle b);
+  static std::shared_ptr<AbstractItem> Create(Bundle b);
 };
 
 }  // namespace item
index 8868cfe..6520075 100644 (file)
@@ -21,7 +21,7 @@
 #include "notification-ex/exception.h"
 #include "notification-ex/progress_item.h"
 #include "notification-ex/progress_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -77,7 +77,7 @@ void ProgressItem::Deserialize(Bundle b) {
 AbstractItem& ProgressItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 float ProgressItem::GetCurrent() const {
index f01d3e0..d883782 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "notification-ex/text_item.h"
 #include "notification-ex/text_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -67,7 +67,7 @@ void TextItem::Deserialize(Bundle b) {
 AbstractItem& TextItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 void TextItem::SetContents(std::string contents) {
index c375d16..c84563a 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "notification-ex/time_item.h"
 #include "notification-ex/time_item_implementation.h"
-#include "notification-ex/item_factory.h"
+#include "notification-ex/factory_manager.h"
 #include "notification-ex/exception.h"
 
 #ifdef LOG_TAG
@@ -86,7 +86,7 @@ AbstractItem& TimeItem::FindByID(std::string id) {
   if (GetId() == id)
     return *this;
 
-  return ItemFactory::GetNullItem();
+  return FactoryManager::GetInst().GetNullItem();
 }
 
 time_t TimeItem::GetTime() const {
index 167aa95..3320832 100644 (file)
@@ -37,8 +37,7 @@ TEST_F(ButtonItemTest, FindByIDNullItemReturn) {
 TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) {
   ButtonItem item("title");
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   ButtonItem* gen_btn = static_cast<ButtonItem*>(gen_item.get());
index 6952b38..abca486 100644 (file)
@@ -63,8 +63,7 @@ TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
 TEST_F(ChatMessageItemTest, SerializeDeserialize) {
   Bundle b = ChatMessageItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ChatMessageItem* gen_message = static_cast<ChatMessageItem*>(gen_item.get());
   ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name");
   ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
index 6fd38dd..8aa0e6b 100644 (file)
@@ -55,8 +55,7 @@ TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
 TEST_F(CheckBoxItemTest, SerializeDeserialize) {
   Bundle b = CheckBoxItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item.get()->GetType());
 
   CheckBoxItem* gen_checkbox = static_cast<CheckBoxItem*>(gen_item.get());
index b81d8f9..da933d3 100644 (file)
@@ -48,8 +48,7 @@ TEST_F(EntryItemTest, FindByIDNullItemReturn) {
 TEST_F(EntryItemTest, SerializeDeserialize) {
   EntryItem item("entry_id");
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   EntryItem* gen_effect = static_cast<EntryItem*>(gen_item.get());
index cbe87ef..6288c8d 100644 (file)
@@ -43,8 +43,7 @@ TEST_F(GroupItemTest, SerializeDeserialize) {
   item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
 
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   GroupItem* gen_group = static_cast<GroupItem*>(gen_item.get());
index 8deb06d..cd2fdbf 100644 (file)
@@ -52,8 +52,7 @@ TEST_F(IconItemTest, FindByIDNullItemReturn) {
 TEST_F(IconItemTest, SerializeDeserialize) {
   Bundle b = IconItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(IconItemTest::item->GetType(), gen_item.get()->GetType());
 
   IconItem* gen_icon = static_cast<IconItem*>(gen_item.get());
index dfe8f72..423d052 100644 (file)
@@ -55,8 +55,7 @@ TEST_F(IconTextItemTest, FindByIDNullItemReturn) {
 TEST_F(IconTextItemTest, SerializeDeserialize) {
   Bundle b = IconTextItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   IconTextItem* gen_icon = static_cast<IconTextItem*>(gen_item.get());
   ASSERT_EQ(IconTextItemTest::item->GetIconItem().GetImagePath(), gen_icon->GetIconItem().GetImagePath());
   ASSERT_EQ(IconTextItemTest::item->GetTextItem().GetContents(), gen_icon->GetTextItem().GetContents());
index 42a5caa..5aa45e2 100644 (file)
@@ -53,8 +53,7 @@ TEST_F(ImageItemTest, FindByIDNullItemReturn) {
 TEST_F(ImageItemTest, SerializeDeserialize) {
   Bundle b = ImageItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(ImageItemTest::item->GetType(), gen_item.get()->GetType());
 
   ImageItem* gen_image = static_cast<ImageItem*>(gen_item.get());
index 9c56bc6..d2db27d 100644 (file)
@@ -27,8 +27,7 @@ TEST_F(InputSelectorItemTest, SerializeDeserialize) {
   item.SetContents(contents);
 
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   InputSelectorItem* gen_input = static_cast<InputSelectorItem*>(gen_item.get());
index 435ffac..d62aab3 100644 (file)
@@ -21,8 +21,7 @@ class ProgressItemTest : public ::testing::Test {
 TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
   ProgressItem item(1.0, 10.0, 100.0);
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   ProgressItem* gen_progress = static_cast<ProgressItem*>(gen_item.get());
index 316e2cd..49ea0fc 100644 (file)
@@ -50,8 +50,7 @@ TEST_F(TexttItemTest, FindByIDNullItemReturn) {
 TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
   TextItem item("text_id", "contents");
   Bundle b = item.Serialize();
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(gen_item.get()->GetType(), item.GetType());
 
   TextItem* gen_text = static_cast<TextItem*>(gen_item.get());
index e0514f3..f595277 100644 (file)
@@ -54,8 +54,7 @@ TEST_F(TimeItemTest, FindByIDNullItemReturn) {
 TEST_F(TimeItemTest, SerializeDeserialize) {
   Bundle b = TimeItemTest::item->Serialize();
 
-  ItemFactory factory;
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(factory, b);
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
   ASSERT_EQ(TimeItemTest::item->GetType(), gen_item.get()->GetType());
 
   TimeItem* gen_time = static_cast<TimeItem*>(gen_item.get());