Handle notification silent option
authorArnaud Renevier <a.renevier@samsung.com>
Wed, 15 Apr 2015 21:32:43 +0000 (14:32 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Add ewk api ewk_notification_silent_get

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=10487

Change-Id: Ia4ed78ab2ad82a6b976b2e391d2b9230afb4d440
Signed-off-by: Arnaud Renevier <a.renevier@samsung.com>
tizen_src/ewk/efl_integration/browser/notification/notification_controller_efl.cc
tizen_src/ewk/efl_integration/private/ewk_notification_private.cc
tizen_src/ewk/efl_integration/private/ewk_notification_private.h
tizen_src/ewk/efl_integration/public/ewk_notification.cc
tizen_src/ewk/efl_integration/public/ewk_notification.h
tizen_src/ewk/unittest/ewk-tests.gypi
tizen_src/ewk/unittest/resources/common/sample_notification_1.html
tizen_src/ewk/unittest/utc_blink_ewk_notification_silent_get_func.cpp [new file with mode: 0755]

index 07deb13..8a029fb 100644 (file)
@@ -125,6 +125,7 @@ void NotificationControllerEfl::DisplayNotification(
                            base::UTF16ToUTF8(notification_data.tag),
                            base::UTF16ToUTF8(notification_data.title),
                            icon,
+                           notification_data.silent,
                            notificationUniqueId,
                            origin);
 
index ee08dea..d9ebc9c 100644 (file)
@@ -13,12 +13,14 @@ Ewk_Notification::Ewk_Notification(
     const std::string& replaceID,
     const std::string& title,
     const SkBitmap& icon,
+    bool silent,
     uint64_t notificationID,
     const GURL& origin)
     : body_(body)
     , icon_(icon)
     , replaceID_(replaceID)
     , title_(title)
+    , silent_(silent)
     , notificationID_(notificationID)
     , origin_(new _Ewk_Security_Origin(origin)) {
 }
@@ -38,6 +40,10 @@ const char* Ewk_Notification::GetTitle() const {
   return title_.c_str();
 }
 
+bool Ewk_Notification::IsSilent() const {
+  return silent_;
+}
+
 Evas_Object* Ewk_Notification::GetIcon(Evas* evas) const {
   if (icon_.isNull()) {
     return nullptr;
index a147468..a195b93 100644 (file)
@@ -22,6 +22,7 @@ struct Ewk_Notification {
                    const std::string& replaceID,
                    const std::string& title,
                    const SkBitmap& icon,
+                   bool silent,
                    uint64_t notificationID,
                    const GURL& securityOrigin);
   ~Ewk_Notification();
@@ -29,6 +30,7 @@ struct Ewk_Notification {
   const char* GetBody() const;
   const char* GetReplaceId() const;
   const char* GetTitle() const;
+  bool IsSilent() const;
   Evas_Object* GetIcon(Evas* evas) const;
   int GetID() const;
   const _Ewk_Security_Origin* GetSecurityOrigin() const;
@@ -38,6 +40,7 @@ struct Ewk_Notification {
   SkBitmap icon_;
   std::string replaceID_;
   std::string title_;
+  bool silent_;
   uint64_t notificationID_;
   scoped_ptr<_Ewk_Security_Origin> origin_;
 
index 9fdf602..f446801 100644 (file)
@@ -187,3 +187,9 @@ const char* ewk_notification_title_get(const Ewk_Notification* ewk_notification)
   EINA_SAFETY_ON_NULL_RETURN_VAL(ewk_notification, 0);
   return ewk_notification->GetTitle();
 }
+
+Eina_Bool ewk_notification_silent_get(const Ewk_Notification* ewk_notification)
+{
+  EINA_SAFETY_ON_NULL_RETURN_VAL(ewk_notification, EINA_FALSE);
+  return ewk_notification->IsSilent();
+}
index 15c6d03..34d2ce8 100644 (file)
@@ -207,6 +207,16 @@ EAPI Eina_Bool ewk_notification_closed(uint64_t notification_id, Eina_Bool by_us
  */
 EAPI const char* ewk_notification_title_get(const Ewk_Notification* ewk_notification);
 
+/**
+ * Query if the notification is silent
+ *
+ * @param ewk_notification pointer of notification data
+ *
+ * @return @c EINA_TRUE if the notification must be silent, @c EINA_FALSE
+ *         otherwise
+ */
+EAPI Eina_Bool ewk_notification_silent_get(const Ewk_Notification* ewk_notification);
+
 #ifdef __cplusplus
 }
 #endif
index 04afc7f..d15940f 100644 (file)
         'utc_blink_ewk_notification_policies_removed_func.cpp',
         'utc_blink_ewk_notification_security_origin_get_func.cpp',
         'utc_blink_ewk_notification_showed_func.cpp',
+        'utc_blink_ewk_notification_silent_get_func.cpp',
         'utc_blink_ewk_notification_title_get_func.cpp',
         'utc_blink_ewk_policy_decision_cookie_get_func.cpp',
         'utc_blink_ewk_policy_decision_frame_get_func.cpp',
index 97db402..54b7436 100644 (file)
@@ -16,6 +16,7 @@ function testNotifications()
             body: 'Notification body content',
             icon: 'logo.png',
             tag: 'replace_tag',
+            silent: true
             });
       notification.onshow = function() { console.log('notification.show'); }
       notification.onclick = function() { console.log('notification.click'); }
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_notification_silent_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_notification_silent_get_func.cpp
new file mode 100755 (executable)
index 0000000..3a48e30
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright 2014 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/* Define those macros _before_ you include the utc_blink_ewk.h header file. */
+#include "utc_blink_ewk_notification_test_base.h"
+
+class utc_blink_ewk_notification_silent_get : public utc_blink_ewk_notification_test_base {
+ protected:
+  utc_blink_ewk_notification_silent_get()
+    : silent(NULL)
+    , notification_silent_ref(true)
+  {}
+
+  ~utc_blink_ewk_notification_silent_get()
+  {
+  }
+
+  virtual void NotificationShow(Ewk_Notification* notification) override
+  {
+    silent = ewk_notification_silent_get(notification);
+    EventLoopStop(Success);
+  }
+
+ protected:
+  bool silent;
+  const bool notification_silent_ref;
+};
+
+/**
+* @brief Positive test case for ewk_notification_silent_get(). Text returned by api is compared against expected text and result is set in notificationShow()
+*/
+TEST_F(utc_blink_ewk_notification_silent_get, POS_TEST)
+{
+  ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), notification_sample_1.c_str()));
+  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(notification_silent_ref, silent);
+}
+
+/**
+* @brief Checking whether function works properly in case of nullptr of a webview.
+*/
+TEST_F(utc_blink_ewk_notification_silent_get, NEG_TEST)
+{
+  ASSERT_FALSE(ewk_notification_silent_get(nullptr));
+}