Add changesWatch for webview cookie 51/255351/7
authorzhouleonlei <zhouleon.lei@samsung.com>
Wed, 17 Mar 2021 08:08:19 +0000 (16:08 +0800)
committerzhouleonlei <zhouleon.lei@samsung.com>
Fri, 16 Apr 2021 05:16:12 +0000 (13:16 +0800)
Change-Id: Ice11a906d847d8abf4fcfe5317e2d1b0935825d1

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp [changed mode: 0644->0755]
dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h

index 430615d..765d015 100755 (executable)
@@ -83,6 +83,7 @@ bool OnStorageUsageAcquired();
 bool OnFormPasswordAcquired();
 bool OnDownloadStarted();
 bool OnMimeOverridden();
 bool OnFormPasswordAcquired();
 bool OnDownloadStarted();
 bool OnMimeOverridden();
+bool OnChangesWatch();
 
 static void ConnectToGlobalSignal( bool ( *func )() )
 {
 
 static void ConnectToGlobalSignal( bool ( *func )() )
 {
@@ -256,6 +257,18 @@ public:
   {
   }
 
   {
   }
 
+  void ChangesWatch( Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback ) override
+  {
+    if ( callback )
+    {
+      ConnectToGlobalSignal( &OnChangesWatch );
+      mChangesWatchCallback = callback;
+    }
+  }
+
+public:
+  Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback mChangesWatchCallback;
+
 private:
   Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
 };
 private:
   Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
 };
@@ -1727,6 +1740,22 @@ bool OnMimeOverridden()
   return false;
 }
 
   return false;
 }
 
+bool OnChangesWatch()
+{
+  DisconnectFromGlobalSignal( &OnChangesWatch );
+
+  if ( gInstance )
+  {
+    MockWebEngineCookieManager* temp = (MockWebEngineCookieManager *)(&(gInstance->GetCookieManager()));
+    if ( temp )
+    {
+      temp->mChangesWatchCallback();
+    }
+  }
+
+  return false;
+}
+
 } // namespace
 
 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
 } // namespace
 
 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
index 39ebd29..a4ae7e1 100755 (executable)
@@ -101,6 +101,7 @@ static std::shared_ptr<Dali::WebEngineContextMenu> gContextMenuInstance = nullpt
 static int gContextMenuItemSelectedCallbackCalled = 0;
 static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = nullptr;
 static int gHitTestCreatedCallbackCalled = 0;
 static int gContextMenuItemSelectedCallbackCalled = 0;
 static std::shared_ptr<Dali::WebEngineContextMenuItem> gContextMenuItemInstance = nullptr;
 static int gHitTestCreatedCallbackCalled = 0;
+static int gCookieManagerChangsWatchCallbackCalled = 0;
 
 struct CallbackFunctor
 {
 
 struct CallbackFunctor
 {
@@ -204,6 +205,11 @@ static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
   return true;
 }
 
   return true;
 }
 
+static void OnChangesWatch()
+{
+  gCookieManagerChangsWatchCallbackCalled++;
+}
+
 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
 {
   gHovered = true;
 static bool OnHovered( Actor actor, const Dali::HoverEvent& hover )
 {
   gHovered = true;
@@ -1696,6 +1702,23 @@ int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+int UtcDaliWebCookieManagerChangesWatch(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+  DALI_TEST_CHECK( cookieManager != 0 )
+
+  cookieManager->ChangesWatch(&OnChangesWatch);
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS( gCookieManagerChangsWatchCallbackCalled, 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
 // test cases for web settings.
 
 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
 // test cases for web settings.
 
 int UtcDaliWebSettingsGetSetDefaultFontSize(void)
old mode 100644 (file)
new mode 100755 (executable)
index fba924a..61529a8
@@ -51,6 +51,11 @@ void WebCookieManager::SetPersistentStorage(const std::string& path, Dali::WebEn
   mWebEngineCookieManager.SetPersistentStorage(path, storage);
 }
 
   mWebEngineCookieManager.SetPersistentStorage(path, storage);
 }
 
+void WebCookieManager::ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback)
+{
+  mWebEngineCookieManager.ChangesWatch(callback);
+}
+
 } // namespace Toolkit
 
 } // namespace Dali
 } // namespace Toolkit
 
 } // namespace Dali
index adb133a..421db32 100755 (executable)
@@ -93,6 +93,13 @@ public:
    */
   void SetPersistentStorage(const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage);
 
    */
   void SetPersistentStorage(const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage);
 
+  /**
+   * @brief Watch for cookies' changes in @a manager.
+   *
+   * @param[in] callback cookies are added, removed or modified.
+   */
+  void ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback);
+
 private:
   Dali::WebEngineCookieManager& mWebEngineCookieManager;
 };
 private:
   Dali::WebEngineCookieManager& mWebEngineCookieManager;
 };