Add APIs to get/set state of transparent background.
authorEunmi Lee <eunmi15.lee@samsung.com>
Fri, 19 Jul 2013 12:46:39 +0000 (21:46 +0900)
committerEunmi Lee <eunmi15.lee@samsung.com>
Mon, 19 Aug 2013 08:57:33 +0000 (17:57 +0900)
[Title] Add APIs to get/set state of transparent background.
[Issue#] N/A
[Problem] We can not make pd of web-dynamic-box transparent,
      and pd is disappeared if webview's color is set to transparent.
[Cause] There is no way to set transparent background and Evas does not draws if object's color is transparent.
[Solution] Add APIs to get/set state of transparent background.

Change-Id: I9635959e4984338d5e58a240e8d1aac3a1174901

Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.h
TC/unit_test/webkit2/Makefile
TC/unit_test/webkit2/tslist
TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_get_func.c [new file with mode: 0755]
TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_set_func.c [new file with mode: 0755]

index 66868ef..b347349 100755 (executable)
@@ -4885,3 +4885,22 @@ void ewk_view_fullscreen_exit(Evas_Object* ewkView)
     UNUSED_PARAM(ewkView);
 #endif
 }
+
+Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object* ewkView, Eina_Bool enabled)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
+
+    impl->pageProxy->setDrawsTransparentBackground(enabled);
+    evas_object_image_alpha_set(smartData->image, enabled);
+
+    return true;
+}
+
+Eina_Bool ewk_view_draws_transparent_background_get(Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
+
+    return impl->pageProxy->drawsTransparentBackground();
+}
index 44caf45..41d8147 100644 (file)
@@ -1748,6 +1748,25 @@ EAPI void ewk_view_use_settings_font(Evas_Object* o);
  */
 EAPI void ewk_view_fullscreen_exit(Evas_Object* o);
 
+/**
+ * Sets whether to draw transparent background or not.
+ *
+ * @param o view object to enable/disable transparent background
+ * @param enabled a state to set
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object *o, Eina_Bool enabled);
+
+/**
+ * Queries if transparent background is enabled.
+ *
+ * @param o view object to get whether transparent background is enabled or not.
+ *
+ * @return @c EINA_TRUE on enable or @c EINA_FALSE on disable
+ */
+EAPI Eina_Bool ewk_view_draws_transparent_background_get(Evas_Object *o);
+
 #ifdef __cplusplus
 }
 #endif
index 16e9a14..f93ce06 100644 (file)
@@ -164,6 +164,8 @@ TARGETS = \
           utc_webkit2_ewk_view_contents_size_get_func \
           utc_webkit2_ewk_view_context_get_func \
           utc_webkit2_ewk_view_custom_header_add_func \
+          utc_webkit2_ewk_view_draws_transparent_background_get_func \
+          utc_webkit2_ewk_view_draws_transparent_background_set_func \
           utc_webkit2_ewk_view_feed_touch_event_func \
           utc_webkit2_ewk_view_focused_frame_get_func \
           utc_webkit2_ewk_view_forward_func \
index 3a75ccc..bfc83f8 100644 (file)
 /unit_test/webkit2/utc_webkit2_ewk_view_contents_size_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_context_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_custom_header_add_func
+/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_get_func
+/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_set_func
 /unit_test/webkit2/utc_webkit2_ewk_view_feed_touch_event_func
 /unit_test/webkit2/utc_webkit2_ewk_view_focused_frame_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_forward_func
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_get_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_get_func.c
new file mode 100755 (executable)
index 0000000..a024bf1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * WebKit2 EFL
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
+#define TESTED_FUN_NAME ewk_view_draws_transparent_background_get
+#define POSITIVE_TEST_FUN_NUM 1
+#define NEGATIVE_TEST_FUN_NUM 1
+
+#include "utc_webkit2_ewk.h"
+
+/* Startup and cleanup functions */
+static void startup(void)
+{
+    utc_webkit2_ewk_test_init();
+}
+
+static void cleanup(void)
+{
+    utc_webkit2_ewk_test_end();
+}
+
+/**
+ * @brief Checking whether the state of transparent background is returned properly.
+ */
+POS_TEST_FUN(1)
+{
+    Eina_Bool result = EINA_TRUE;
+    Eina_Bool enable_set;
+    Eina_Bool enable_get;
+
+    enable_set = EINA_TRUE;
+    ewk_view_draws_transparent_background_set(test_view.webview, enable_set);
+    enable_get = ewk_view_draws_transparent_background_get(test_view.webview);
+    if (enable_set != enable_get) {
+        result = EINA_FALSE;
+    }
+
+    enable_set = EINA_FALSE;
+    ewk_view_draws_transparent_background_set(test_view.webview, enable_set);
+    enable_get = ewk_view_draws_transparent_background_get(test_view.webview);
+    if (enable_set != enable_get) {
+        result = EINA_FALSE;
+    }
+
+    utc_check_eq(result, EINA_TRUE);
+}
+
+/**
+ * @brief There is no negative case for ewk_view_draws_transparent_background_get function.
+ */
+NEG_TEST_FUN(1)
+{
+    ewk_view_draws_transparent_background_get(test_view.webview);
+    utc_pass();
+}
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_set_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_draws_transparent_background_set_func.c
new file mode 100755 (executable)
index 0000000..79e7551
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * WebKit EFL
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
+#define TESTED_FUN_NAME ewk_view_draws_transparent_background_set
+#define POSITIVE_TEST_FUN_NUM 2
+#define NEGATIVE_TEST_FUN_NUM 1
+
+#include "utc_webkit2_ewk.h"
+
+/* Startup and cleanup functions */
+static void startup(void)
+{
+    utc_webkit2_ewk_test_init();
+}
+
+static void cleanup(void)
+{
+    utc_webkit2_ewk_test_end();
+}
+
+
+POS_TEST_FUN(1)
+{
+    Eina_Bool result = ewk_view_draws_transparent_background_set(test_view.webview, EINA_TRUE);
+    utc_check_eq(result, EINA_TRUE);
+}
+
+POS_TEST_FUN(2)
+{
+    Eina_Bool result = ewk_view_draws_transparent_background_set(test_view.webview, EINA_FALSE);
+    utc_check_eq(result, EINA_TRUE);
+}
+
+NEG_TEST_FUN(1)
+{
+    Eina_Bool result = ewk_view_draws_transparent_background_set(NULL, EINA_FALSE);
+    utc_check_eq(result, EINA_FALSE);
+}