Add ongoing state for abstract item 50/209450/3
authorSukHyung, Kang <shine.kang@samsung.com>
Mon, 8 Jul 2019 05:57:00 +0000 (14:57 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Tue, 9 Jul 2019 01:28:54 +0000 (10:28 +0900)
Change-Id: Ib7e25a14b53c119875263ed3ecf3094b567a8226
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/abstract_item_implementation.h
unittest/src/test_abstract_item.cc

index c24cd17..d1444ab 100644 (file)
@@ -79,6 +79,7 @@
 #define ABSTRACT_ITEM_ACTION_KEY "__ABSTRACT_ITEM_ACTION_KEY__"
 #define ABSTRACT_ITEM_HIDE_VIEWER_KEY "__ABSTRACT_ITEM_HIDE_VIEWER_KEY__"
 #define ABSTRACT_ITEM_TRUE "TRUE"
+#define ABSTRACT_ITEM_ONGOING_KEY "__ABSTRACT_ITEM_ONGOING_KEY__"
 
 using namespace std;
 namespace notification {
@@ -167,6 +168,7 @@ Bundle AbstractItem::Serialize() const {
   b.Add(ABSTRACT_ITEM_VISIBLE_KEY, to_string((int)impl_->visible_));
   b.Add(ABSTRACT_ITEM_ENABLE_KEY, to_string((int)impl_->enable_));
   b.Add(ABSTRACT_ITEM_POLICY_KEY, to_string((int)impl_->policy_));
+  b.Add(ABSTRACT_ITEM_ONGOING_KEY, to_string((int)impl_->ongoing_));
 
   if (impl_->receiver_group_list_.size() != 0) {
     vector<string> arr;
@@ -288,10 +290,9 @@ void AbstractItem::Deserialize(Bundle b) {
   string policy_str = b.GetString(ABSTRACT_ITEM_POLICY_KEY);
 
   impl_->policy_ = static_cast<Policy>(stoi(policy_str));
-
   impl_->visible_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_VISIBLE_KEY)));
-
   impl_->enable_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_ENABLE_KEY)));
+  impl_->ongoing_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_ONGOING_KEY)));
 
   vector<string> receiver_group = b.GetStringArray(ABSTRACT_ITEM_RECEIVER_GROUP_KEY);
   if (receiver_group.size() != 0) {
@@ -500,5 +501,13 @@ void AbstractItem::SetTag(std::string tag) {
   impl_->tag_ = tag;
 }
 
+void AbstractItem::SetOnGoingState(bool ongoing) {
+  impl_->ongoing_ = ongoing;
+}
+
+bool AbstractItem::GetOnGoingState() const {
+  return impl_->ongoing_;
+}
+
 }  // namespace item
 }  // namespace notification
index 4a9f3b7..08a6d95 100644 (file)
@@ -1000,6 +1000,20 @@ class EXPORT_API AbstractItem {
    */
   void SetTag(std::string tag);
 
+  /**
+   * @brief Sets the ongoing state of notification item.
+   * @since_tizen 5.5
+   * @param[in] ongoing The ongoing state of notification item
+   */
+  void SetOnGoingState(bool ongoing);
+
+  /**
+   * @brief Gets the ongoing state of notification item.
+   * @since_tizen 5.5
+   * @return The ongoing state of notification item
+   */
+  bool GetOnGoingState() const;
+
  private:
   class Impl;
   std::unique_ptr<Impl> impl_;
index 86753c5..d4ea8d6 100644 (file)
@@ -65,6 +65,7 @@ class AbstractItem::Impl {
   uid_t uid_ = 0;
   int request_id_ = 0;
   std::string background_;
+  bool ongoing_ = false;
 };
 
 }  // namespace item
index 3a205c3..2ede761 100644 (file)
@@ -135,6 +135,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   led->SetOffPeriod(20);
 
   item.SetLEDInfo(led);
+  item.SetOnGoingState(true);
 
   /* Deserialize */
   Bundle b = item.Serialize();
@@ -229,6 +230,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) {
   app_control_get_app_id(ac->GetAppControl(), &app_id);
 
   ASSERT_STREQ(app_id, "new_appid_1");
+  ASSERT_EQ(gen_test->GetOnGoingState(), true);
 }
 
 TEST_F(AbstractItemTest, SerializeDeserialize2) {
@@ -277,4 +279,14 @@ TEST_F(AbstractItemTest, ItemInfoCanReceive) {
   ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
 }
 
+TEST_F(AbstractItemTest, SetGetOnGoingState) {
+  TestItem item("test_id");
+
+  ASSERT_EQ(item.GetOnGoingState(), false);
+
+  item.SetOnGoingState(true);
+
+  ASSERT_EQ(item.GetOnGoingState(), true);
+}
+
 }  // namespace
\ No newline at end of file