Refactor EWK APIs controlling initial value of list-style-position CSS property
authorKamil Klimek <k.klimek@partner.samsung.com>
Thu, 22 Jan 2015 14:04:06 +0000 (15:04 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
This commit re-enables the ewk_settings_initial_list_style_position_{get|set}
API calls by removing EWK_BRINGUP define guards.

This API is not implemented on engine site. It only toggles a flag
inside WebPreferences.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9533
Reviewed by: Antonio Gomes, Piotr Tworek, commitbot

Change-Id: I5e7e1c825cc1ccac305e10eb05318617c0417e9e
Signed-off-by: Kamil Klimek <k.klimek@partner.samsung.com>
tizen_src/ewk/efl_integration/public/ewk_settings.cc
tizen_src/ewk/unittest/resources/common/ul_li.html [new file with mode: 0644]
tizen_src/ewk/unittest/utc_blink_ewk_settings_initial_list_style_position_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_settings_initial_list_style_position_set_func.cpp

index 26a8e08..4a84d31 100644 (file)
@@ -547,22 +547,15 @@ Eina_Bool ewk_settings_select_word_automatically_get(const Ewk_Settings* setting
 Ewk_List_Style_Position ewk_settings_initial_list_style_position_get(const Ewk_Settings* settings)
 {
   EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EWK_LIST_STYLE_POSITION_OUTSIDE);
-  // TODO: To be used when the functionality is required.
-#if !defined(EWK_BRINGUP)
   return static_cast<Ewk_List_Style_Position>(settings->getPreferences().initial_list_style_position);
-#else
-  return static_cast<Ewk_List_Style_Position>(0);
-#endif
 }
 
 Eina_Bool ewk_settings_initial_list_style_position_set(Ewk_Settings* settings, Ewk_List_Style_Position style)
 {
-  EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
-#if !defined(EWK_BRINGUP)
-  settings->getPreferences().initial_list_style_position = static_cast<webkit_glue::ListStylePosition>(style);
-#endif
+  EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+  settings->getPreferences().initial_list_style_position = static_cast<content::ListStylePosition>(style);
   ewkUpdateWebkitPreferences(settings->getEvasObject());
-  return true;
+  return EINA_TRUE;
 }
 
 Eina_Bool ewk_settings_webkit_text_size_adjust_enabled_set(Ewk_Settings* settings, Eina_Bool enabled)
diff --git a/tizen_src/ewk/unittest/resources/common/ul_li.html b/tizen_src/ewk/unittest/resources/common/ul_li.html
new file mode 100644 (file)
index 0000000..412c6fa
--- /dev/null
@@ -0,0 +1,24 @@
+<html><head>
+    <title>List items</title>
+</head><body>
+<ul id="ul1">List items
+      <li id="li1">List item 1</li>
+      <li>List item 2</li>
+      <li>List item 3</li>
+</ul>
+<ul id="ul2" style="list-style-position: inside;">List items inside
+      <li id="li2">List item 1</li>
+      <li>List item 2</li>
+      <li>List item 3</li>
+</ul>
+<ul id="ul3" style="list-style-position: outside;">List items outside
+      <li id="li3">List item 1</li>
+      <li>List item 2</li>
+      <li>List item 3</li>
+</ul>
+<script type="text/javascript">
+  var ul1 = document.getElementById('ul1')
+  var css = window.getComputedStyle(ul1, null)
+  console.log(css.getPropertyValue('list-style-position'))
+</script>
+</body></html>
index 91bbb23..dfffcc7 100755 (executable)
@@ -4,51 +4,48 @@
 
 #include "utc_blink_ewk_base.h"
 
-class utc_blink_ewk_settings_initial_list_style_position_get : public utc_blink_ewk_base {
-};
+class utc_blink_ewk_settings_initial_list_style_position_get : public utc_blink_ewk_base
+{
+protected:
+  void PostSetUp()
+  {
+    settings = ewk_view_settings_get(GetEwkWebView());
+  }
 
+protected:
+  Ewk_Settings *settings;
+};
 
 /**
-* @brief checking if returns EWK_LIST_STYLE_POSITION_OUTSIDE when initiated with a correct webview and
-* initial list style position set to EWK_LIST_STYLE_POSITION_OUTSIDE.
+* @brief checking if returns EWK_LIST_STYLE_POSITION_OUTSIDE when initiated with NULL webview.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, POS_TEST1)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, NullArg)
 {
-  Ewk_Settings *settings = ewk_view_settings_get(GetEwkWebView());
-  if (!settings) {
-    FAIL();
-  }
-
-  Eina_Bool result = ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_OUTSIDE);
-  if (!result) {
-    FAIL();
-  }
-  EXPECT_EQ(ewk_settings_initial_list_style_position_get(settings), EWK_LIST_STYLE_POSITION_OUTSIDE);
+  EXPECT_EQ(EWK_LIST_STYLE_POSITION_OUTSIDE,
+            ewk_settings_initial_list_style_position_get(NULL));
 }
 
 /**
-* @brief checking if returns EWK_LIST_STYLE_POSITION_INSIDE when initiated with a correct webview and
-* initial list style position set to EWK_LIST_STYLE_POSITION_INSIDE.
+* @brief checking if returns EWK_LIST_STYLE_POSITION_INSIDE when initiated with a correct webview
+*  and initial list style position set to EWK_LIST_STYLE_POSITION_INSIDE.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, POS_TEST2)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, INSIDE)
 {
-  Ewk_Settings *settings = ewk_view_settings_get(GetEwkWebView());
-  if (!settings) {
-    FAIL();
-  }
-
-  Eina_Bool result = ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_INSIDE);
-  if (!result) {
-    FAIL();
-  }
-  EXPECT_EQ(ewk_settings_initial_list_style_position_get(settings), EWK_LIST_STYLE_POSITION_INSIDE);
+  ASSERT_TRUE(settings);
+  EXPECT_EQ(EINA_TRUE,
+            ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_INSIDE));
+  EXPECT_EQ(EWK_LIST_STYLE_POSITION_INSIDE, ewk_settings_initial_list_style_position_get(settings));
 }
 
 /**
-* @brief checking if returns EWK_LIST_STYLE_POSITION_OUTSIDE when initiated with NULL webview.
+* @brief checking if returns EWK_LIST_STYLE_POSITION_OUTSIDE when initiated with a correct webview
+*  and initial list style position set to EWK_LIST_STYLE_POSITION_OUTSIDE.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, NEG_TEST)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_get, OUTSIDE)
 {
-  Ewk_List_Style_Position result = ewk_settings_initial_list_style_position_get(NULL);
-  EXPECT_EQ(result, EWK_LIST_STYLE_POSITION_OUTSIDE);
+  ASSERT_TRUE(settings);
+  EXPECT_EQ(EINA_TRUE,
+           ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_OUTSIDE));
+  EXPECT_EQ(EWK_LIST_STYLE_POSITION_OUTSIDE,
+            ewk_settings_initial_list_style_position_get(settings));
 }
index 5d876fc..5d7cd5d 100755 (executable)
@@ -4,50 +4,82 @@
 
 #include "utc_blink_ewk_base.h"
 
-class utc_blink_ewk_settings_initial_list_style_position_set : public utc_blink_ewk_base {
+class utc_blink_ewk_settings_initial_list_style_position_set : public utc_blink_ewk_base
+{
+ protected:
+  utc_blink_ewk_settings_initial_list_style_position_set()
+    : settings(NULL)
+    , list_style_position(NULL)
+  {
+  }
+
+  ~utc_blink_ewk_settings_initial_list_style_position_set()
+  {
+    eina_stringshare_del(list_style_position);
+  }
+
+  void PostSetUp()
+  {
+    settings = ewk_view_settings_get(GetEwkWebView());
+    ASSERT_TRUE(settings);
+  }
+
+  virtual void ConsoleMessage(Evas_Object* webview, const Ewk_Console_Message* msg)
+  {
+    utc_blink_ewk_base::ConsoleMessage(webview, msg);
+
+    if (!list_style_position) {
+      list_style_position = eina_stringshare_add(ewk_console_message_text_get(msg));
+    }
+
+    EventLoopStop(Success);
+  }
+
+ protected:
+  Ewk_Settings *settings;
+  Eina_Stringshare *list_style_position;
 };
 
+
 /**
-* @brief checking if returns EWK_LIST_STYLE_POSITION_OUTSIDE when initiated with a correct webview and
-* initial list style position set to EWK_LIST_STYLE_POSITION_OUTSIDE.
+* @brief checking if returns FALSE when initiated with NULL webview.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, POS_TEST1)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, NullArg)
 {
-  Ewk_Settings *settings = ewk_view_settings_get(GetEwkWebView());
-  if (!settings) {
-    FAIL();
-  }
-
-  Eina_Bool result = ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_OUTSIDE);
-  if (!result) {
-    FAIL();
-  }
-  EXPECT_EQ(ewk_settings_initial_list_style_position_get(settings), EWK_LIST_STYLE_POSITION_OUTSIDE);
+  EXPECT_EQ(EINA_FALSE,
+            ewk_settings_initial_list_style_position_set(NULL, EWK_LIST_STYLE_POSITION_INSIDE));
 }
 
 /**
-* @brief checking if returns EWK_LIST_STYLE_POSITION_INSIDE when initiated with a correct webview and
-* initial list style position set to EWK_LIST_STYLE_POSITION_INSIDE.
+* @brief checking if returns EWK_LIST_STYLE_POSITION_INSIDE when initiated with a correct webview
+*  and initial list style position set to EWK_LIST_STYLE_POSITION_INSIDE.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, POS_TEST2)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, inside)
 {
-  Ewk_Settings *settings = ewk_view_settings_get(GetEwkWebView());
-  if (!settings) {
-    FAIL();
-  }
+  EXPECT_EQ(EINA_TRUE,
+            ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_INSIDE));
 
-  Eina_Bool result = ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_INSIDE);
-  if (!result) {
-    FAIL();
-  }
-  EXPECT_EQ(ewk_settings_initial_list_style_position_get(settings), EWK_LIST_STYLE_POSITION_INSIDE);
+  ASSERT_EQ(EINA_TRUE,
+            ewk_view_url_set(GetEwkWebView(), GetResourceUrl("common/ul_li.html").c_str()));
+  ASSERT_EQ(Success, EventLoopStart());
+
+  ASSERT_TRUE(list_style_position);
+  ASSERT_STREQ("inside", list_style_position);
 }
 
 /**
-* @brief checking if returns FALSE when initiated with NULL webview.
+* @brief checking if returns EWK_LIST_STYLE_POSITION_INSIDE when initiated with a correct webview
+*  and initial list style position set to EWK_LIST_STYLE_POSITION_OUTSIDE.
 */
-TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, NEG_TEST)
+TEST_F(utc_blink_ewk_settings_initial_list_style_position_set, outside)
 {
-  Eina_Bool result = ewk_settings_initial_list_style_position_set(NULL, EWK_LIST_STYLE_POSITION_INSIDE);
-  EXPECT_EQ(result, EINA_FALSE);
+  EXPECT_EQ(EINA_TRUE,
+            ewk_settings_initial_list_style_position_set(settings, EWK_LIST_STYLE_POSITION_OUTSIDE));
+
+  ASSERT_EQ(EINA_TRUE,
+            ewk_view_url_set(GetEwkWebView(), GetResourceUrl("common/ul_li.html").c_str()));
+  ASSERT_EQ(Success, EventLoopStart());
+
+  ASSERT_TRUE(list_style_position);
+  ASSERT_STREQ("outside", list_style_position);
 }