Add the APIs of webview settings 27/255227/7
authorzhouleonlei <zhouleon.lei@samsung.com>
Mon, 15 Mar 2021 09:19:32 +0000 (17:19 +0800)
committerzhouleonlei <zhouleon.lei@samsung.com>
Fri, 9 Apr 2021 09:02:47 +0000 (17:02 +0800)
Change-Id: Id76de24b2c5a26f7f57f0e8d111c578b3b32fe2d

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-settings.cpp
dali-toolkit/devel-api/controls/web-view/web-settings.h

index 0b0c203..430615d 100755 (executable)
@@ -989,6 +989,40 @@ public:
   {
   }
 
+  bool SetViewportMetaTag(bool enable) override
+  {
+    return true;
+  }
+
+  bool SetForceZoom(bool enable) override
+  {
+    return true;
+  }
+
+  bool IsZoomForced() const override
+  {
+    return true;
+  }
+
+  bool SetTextZoomEnabled(bool enable) override
+  {
+    return true;
+  }
+
+  bool IsTextZoomEnabled() const override
+  {
+    return true;
+  }
+
+  void SetExtraFeature(const std::string& feature, bool enable) override
+  {
+  }
+
+  bool IsExtraFeatureEnabled(const std::string& feature) const override
+  {
+    return  true;
+  }
+
 private:
   int mockDefaultFontSize;
   bool mockJavaScriptEnabled;
index cf649ce..39ebd29 100755 (executable)
@@ -2207,3 +2207,78 @@ int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
   END_TEST;
 }
 
+int UtcDaliWebSettingsSetViewportMetaTag(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Check the value is true or not
+  bool value = settings->SetViewportMetaTag(true);
+  DALI_TEST_CHECK( value );
+
+  END_TEST;
+}
+
+int UtcDaliWebSettingsSetForceZoom(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Check the value is true or not
+  bool value = settings->SetForceZoom(true);
+  DALI_TEST_CHECK( value );
+
+  value = settings->IsZoomForced();
+  DALI_TEST_CHECK( value );
+
+  END_TEST;
+}
+
+int UtcDaliWebSettingsSetTextZoomEnabled(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Check the value is true or not
+  bool value = settings->SetTextZoomEnabled(true);
+  DALI_TEST_CHECK( value );
+
+  value = settings->IsTextZoomEnabled();
+  DALI_TEST_CHECK( value );
+
+  END_TEST;
+}
+
+int UtcDaliWebSettingsSetExtraFeature(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Check the value is true or not
+  settings->SetExtraFeature("test", true);
+  bool value = settings->IsExtraFeatureEnabled("test");
+  DALI_TEST_CHECK( value );
+
+  END_TEST;
+}
+
index d39a93e..b17f48d 100755 (executable)
@@ -234,6 +234,42 @@ void WebSettings::SetDefaultTextEncodingName(const std::string& defaultTextEncod
   mWebEngineSettings.SetDefaultTextEncodingName(defaultTextEncodingName);
 }
 
+bool WebSettings::SetViewportMetaTag(bool enable)
+{
+  return mWebEngineSettings.SetViewportMetaTag(enable);
+}
+
+bool WebSettings::SetForceZoom(bool enable)
+{
+  return mWebEngineSettings.SetForceZoom(enable);
+}
+
+bool WebSettings::IsZoomForced() const
+{
+  return mWebEngineSettings.IsZoomForced();
+}
+
+bool WebSettings::SetTextZoomEnabled(bool enable)
+{
+  return mWebEngineSettings.SetTextZoomEnabled(enable);
+}
+
+bool WebSettings::IsTextZoomEnabled() const
+{
+  return mWebEngineSettings.IsTextZoomEnabled();
+}
+
+void WebSettings::SetExtraFeature(const std::string& feature, bool enable)
+{
+  mWebEngineSettings.SetExtraFeature(feature, enable);
+}
+
+bool WebSettings::IsExtraFeatureEnabled(const std::string& feature) const
+{
+  return mWebEngineSettings.IsExtraFeatureEnabled(feature);
+}
+
+
 } // namespace Toolkit
 
 } // namespace Dali
index ba8b1fa..de42833 100755 (executable)
@@ -344,6 +344,69 @@ public:
    */
   void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName);
 
+  /**
+   * @brief Enables/disables the viewport meta tag.
+   *
+   * By default, the viewport meta tag is enabled on mobile and wearable,
+   * but it is disabled on TV.
+   *
+   * @param[in] enable @c true to enable the viewport meta tag
+   *               @c false to disable
+   *
+   * @return @c true on success or @c false on failure
+   */
+  bool SetViewportMetaTag(bool enable);
+
+  /**
+   * @brief Requests setting of force zoom.
+   *
+   * @param[in] enable to force zoom
+   *
+   * @return @c true on success or @c false on failure
+   */
+  bool SetForceZoom(bool enable);
+
+  /**
+   * @brief Returns the force zoom status.
+   *
+   * @return @c true if enable force zoom or @c false.
+   */
+  bool IsZoomForced() const;
+
+  /**
+   * @brief Requests setting use of text zoom.
+   *
+   * @param[in] enable to text zoom.
+   *
+   * @return @c true on success or @c false on failure
+   */
+  bool SetTextZoomEnabled(bool enable);
+
+  /**
+   * @brief Returns whether text zoom is enabled or not.
+   *
+   * @return @c true if enable text zoom or @c false.
+   */
+  bool IsTextZoomEnabled() const;
+
+  /**
+   * @brief Requests enables/disables to the specific extra feature
+   *
+   * @param[in] feature feature name
+   * @param[in] enable @c true to enable the specific extra feature
+   *        @c false to disable
+   */
+  void SetExtraFeature(const std::string& feature, bool enable);
+
+  /**
+   * @brief Returns enable/disable to the specific extra feature
+   *
+   * @param[in] feature feature name
+   *
+   * @return @c true on enable or @c false on disable
+   */
+  bool IsExtraFeatureEnabled(const std::string& feature) const;
+
 private:
   Dali::WebEngineSettings& mWebEngineSettings;
 };