fixup! Implement ewk_settings_auto_fitting_set
authorGrzegorz Czajkowski <g.czajkowski@samsung.com>
Thu, 17 Dec 2015 09:49:02 +0000 (10:49 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 07:55:23 +0000 (07:55 +0000)
Auto fitting (aka Page Overview) changes the scale factor to adjust the content
width to be equal the device width. This feature is by default turned on for
mobile builds and what's more both Reference Browser and ubrowser enable it
in runtime, optionally adding the user possibility to switch it off via UI.

Disabling this feature in runtime results in not reseting the scale factor,
usually from ~0.4f to 1.0f. This causes bad user experience as the scale is
small but user is able to scroll the (empty) content.

Android exposes WebSettings::setLoadWithOverviewMode(boolean overview) [1] which
in Blink resets the scale when auto fit gets disabled. See
adjustForAndroidWebViewQuirks() for details.

This commit sets setLoadWithOverviewMode along with
setShrinksViewportContentToFit when ewk_settings_auto_fitting_set is called.

Not all utc_blink_ewk_settings_scripts_* tests has been fixed. This patch
fixes them, change comments and test names accordingly to their behaviour.

This is squash of two commits from beta/m47 branch:
- http://web.sec.samsung.net/gerrit/#/c/99946/
Reviewed by: sns.park

Change-Id: I00745a5b1de2252c9259fe9d5c21062a40f62c6d
Author: Grzegorz Czajkowski<g.czajkowski@samsung.com>

- http://web.sec.samsung.net/gerrit/#/c/102256/
Reviewed by: sns.park

Change-Id: I576a465d8ac5702e446df95d210707158c5af36c
Author: Marcin Niesluchowski<m.niesluchow@samsung.com>

[1] http://developer.android.com/reference/android/webkit/WebSettings.html

Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=15298
Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=15197

Reviewed by: sns.park

Change-Id: I00745a5b1de2252c9259fe9d5c21062a40f62c6d
Signed-off-by: Grzegorz Czajkowski <g.czajkowski@samsung.com>
tizen_src/ewk/efl_integration/renderer/render_view_observer_efl.cc
tizen_src/ewk/unittest/utc_blink_ewk_settings_scripts_can_open_windows_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_settings_scripts_can_open_windows_set_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_settings_scripts_window_open_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_settings_scripts_window_open_set_func.cpp

index 0d4a2c9..b9259dc 100644 (file)
@@ -540,7 +540,10 @@ void RenderViewObserverEfl::OnUpdateWebKitPreferencesEfl(const WebPreferencesEfl
 {
   blink::WebView* view = render_view()->GetWebView();
   if (view && view->settings()) {
-    view->settings()->setShrinksViewportContentToFit(web_preferences_efl.shrinks_viewport_content_to_fit);
+    blink::WebSettings* settings = view->settings();
+    settings->setShrinksViewportContentToFit(web_preferences_efl.shrinks_viewport_content_to_fit);
+    // Allows resetting the scale factor when "auto fitting" gets disabled.
+    settings->setLoadWithOverviewMode(web_preferences_efl.shrinks_viewport_content_to_fit);
     // and more if they exist in web_preferences_efl.
   }
 
index 0c2e0dc..e8448a2 100644 (file)
@@ -16,7 +16,7 @@ protected:
     settings = ewk_view_settings_get(GetEwkWebView());
     ASSERT_TRUE(settings);
     // make sure default value is proper
-    ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
+    ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
   }
 
 protected:
@@ -26,12 +26,12 @@ protected:
 /**
  * @brief Positive test case of ewk_settings_scripts_can_open_windows_get()
  */
-TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_get, SetTrue)
+TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_get, SetFalse)
 {
   // toggle option
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_FALSE));
   // check if option was toggled
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
+  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
 }
 
 /**
index 0e94d9a..e62b934 100644 (file)
@@ -47,9 +47,9 @@ protected:
 /**
  * @brief Positive test case of ewk_settings_scripts_can_open_windows_set()
  */
-TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, SetTrue)
+TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, SetFalse)
 {
-  // first check if new windows are blocked
+  // first check if new windows are created
   char htmlBuffer[] = "<html>"
                         "<head></head>"
                         "<body onload=\"window.open('http://www.google.com/')\"></body>"
@@ -64,7 +64,7 @@ TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, SetTrue)
   // check if option was toggled
   ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
 
-  // reload page and expect create window smart callback
+  // reload page and expect popup,blocked window smart callback
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
   ASSERT_EQ(Success, EventLoopStart());
 }
@@ -75,10 +75,10 @@ TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, ToggleBeforeLoad)
   // it may not work. This TC checks such case and tests provided solution
 
   // toggle option
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_FALSE));
 
   // check if option was toggled
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
+  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
 
   char htmlBuffer[] = "<html>"
                         "<head></head>"
@@ -86,19 +86,18 @@ TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, ToggleBeforeLoad)
                       "</html>";
 
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  // Expect that window,create is called - option did work
-  ASSERT_EQ(Failure, EventLoopStart());
+  // Expect that popup,blocked is called - option did work
+  ASSERT_EQ(Success, EventLoopStart());
 
   // toggle option again
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_FALSE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE));
 
   // check if option was toggled
-  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
 
-  // reload page and expect create window smart callback
+  // reload page and expect create,window smart callback
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  // window.open should be blocked again - popup,blocked smart callback should be invoked
-  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(Failure, EventLoopStart());
 }
 
 /**
index 2131c64..8881d6b 100644 (file)
@@ -16,7 +16,7 @@ protected:
     settings = ewk_view_settings_get(GetEwkWebView());
     ASSERT_TRUE(settings);
     // make sure default value is proper
-    ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
+    ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
   }
 
 protected:
@@ -26,12 +26,12 @@ protected:
 /**
  * @brief Positive test case of ewk_settings_scripts_window_open_get()
  */
-TEST_F(utc_blink_ewk_settings_scripts_window_open_get, SetTrue)
+TEST_F(utc_blink_ewk_settings_scripts_window_open_get, SetFalse)
 {
   // toggle option
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_TRUE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_FALSE));
   // check if option was toggled
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
+  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
 }
 
 /**
index 747a52f..a26bc60 100644 (file)
@@ -16,7 +16,7 @@ protected:
     settings = ewk_view_settings_get(GetEwkWebView());
     ASSERT_TRUE(settings);
     // make sure default value is proper
-    ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
+    ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
 
     evas_object_smart_callback_add(GetEwkWebView(), "popup,blocked", ToSmartCallback(popup_blocked_cb), this);
     evas_object_smart_callback_add(GetEwkWebView(), "create,window", ToSmartCallback(create_window_cb), this);
@@ -47,26 +47,26 @@ protected:
 /**
  * @brief Positive test case of ewk_settings_scripts_window_open_set()
  */
-TEST_F(utc_blink_ewk_settings_scripts_window_open_set, SetTrue)
+TEST_F(utc_blink_ewk_settings_scripts_window_open_set, SetFalse)
 {
-  // first check if new windows are blocked
+  // first check if new windows are created
   char htmlBuffer[] = "<html>"
                         "<head></head>"
                         "<body onload=\"window.open('http://www.google.com/')\"></body>"
                       "</html>";
 
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(Failure, EventLoopStart());
 
   // now toggle option
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_TRUE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_FALSE));
 
   // check if option was toggled
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
+  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
 
-  // reload page and expect create window smart callback
+  // reload page and expect popup,blocked smart callback
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  ASSERT_EQ(Failure, EventLoopStart());
+  ASSERT_EQ(Success, EventLoopStart());
 }
 
 TEST_F(utc_blink_ewk_settings_scripts_window_open_set, ToggleBeforeLoad)
@@ -75,10 +75,10 @@ TEST_F(utc_blink_ewk_settings_scripts_window_open_set, ToggleBeforeLoad)
   // it may not work. This TC checks such case and tests provided solution
 
   // toggle option
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_TRUE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_FALSE));
 
   // check if option was toggled
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
+  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
 
   char htmlBuffer[] = "<html>"
                         "<head></head>"
@@ -86,19 +86,18 @@ TEST_F(utc_blink_ewk_settings_scripts_window_open_set, ToggleBeforeLoad)
                       "</html>";
 
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  // Expect that window,create is called - option did work
-  ASSERT_EQ(Failure, EventLoopStart());
+  // Expect that popup,blocked is called - option did work
+  ASSERT_EQ(Success, EventLoopStart());
 
   // toggle option again
-  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_FALSE));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_set(settings, EINA_TRUE));
 
   // check if option was toggled
-  ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_window_open_get(settings));
+  ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_window_open_get(settings));
 
-  // reload page and expect create window smart callback
+  // reload page and expect create,window smart callback
   ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
-  // window.open should be blocked again - popup,blocked smart callback should be invoked
-  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(Failure, EventLoopStart());
 }
 
 /**