Add SetAction() for AbstractItem 82/202382/1
authorjusung son <jusung07.son@samsung.com>
Thu, 28 Mar 2019 00:48:59 +0000 (09:48 +0900)
committerjusung son <jusung07.son@samsung.com>
Thu, 28 Mar 2019 00:50:37 +0000 (09:50 +0900)
Change-Id: Ib9e49663fcc0937fdaefd2626bcfdd5b89523be9
Signed-off-by: jusung son <jusung07.son@samsung.com>
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
unittest/src/test_abstract_item.cc

index a676553..5a171b3 100644 (file)
@@ -318,6 +318,10 @@ shared_ptr<AbstractAction> AbstractItem::GetAction() const {
   return impl_->action_;
 }
 
+void AbstractItem::SetAction(std::shared_ptr<AbstractAction> action) {
+  impl_->action_ = action;
+}
+
 shared_ptr<Style> AbstractItem::GetStyle() const {
   return impl_->style_;
 }
index cb136a8..252d8ba 100644 (file)
@@ -230,7 +230,7 @@ class EXPORT_API AbstractItem {
   std::string GetId() const;
   void SetId(std::string id);
   std::shared_ptr<AbstractAction> GetAction() const;
-  void SetAction(std::shared_ptr<AbstractAction> action) const;
+  void SetAction(std::shared_ptr<AbstractAction> action);
   std::shared_ptr<Style> GetStyle() const;
   void SetStyle(std::shared_ptr<Style> style);
   void SetVisible(bool visible);
index 252340b..2c1e6da 100644 (file)
@@ -82,7 +82,7 @@ class AbstractItemTest : public ::testing::Test {
 
 TEST_F(AbstractItemTest, SerializeDeserialize) {
   /* Serialize */
-  app_control_h app_control;
+  app_control_h app_control, app_control_1;
   char* app_id = NULL;
   time_t current_time;
 
@@ -91,6 +91,11 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   std::shared_ptr<AppControlAction> action = std::make_shared<AppControlAction>(app_control);
   app_control_destroy(app_control);
 
+  app_control_create(&app_control_1);
+  app_control_set_app_id(app_control_1, "new_appid_1");
+  std::shared_ptr<AppControlAction> action_1 = std::make_shared<AppControlAction>(app_control_1);
+  app_control_destroy(app_control_1);
+
   TestItem item("test_id", action);
 
   Color color(50, 100,150,200);
@@ -199,6 +204,17 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   app_control_get_app_id(ac->GetAppControl(), &app_id);
 
   ASSERT_STREQ(app_id, "new_appid");
+
+  item.SetAction(action_1);
+
+  b = item.Serialize();
+  gen_item = ItemInflator::Create(b);
+  gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ac = std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
+  app_control_get_app_id(ac->GetAppControl(), &app_id);
+
+  ASSERT_STREQ(app_id, "new_appid_1");
 }
 
 }  // namespace
\ No newline at end of file