[EFL][WK2] Add APIs to create, delete and get ewk_context.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Sep 2012 14:39:23 +0000 (14:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Sep 2012 14:39:23 +0000 (14:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89186

Patch by Eunmi Lee <eunmi15.lee@samsung.com> on 2012-09-20
Reviewed by Kenneth Rohde Christiansen.

Provide APIs to create ewk_context with or without injected bundle path
and delete created ewk_context.
Additionally, the ewk_view can be created with ewk_context which is not
default context, so we have to get ewk_context from ewk_view.

* PlatformEfl.cmake:
* UIProcess/API/efl/PageClientImpl.cpp:
(WebKit::PageClientImpl::handleDownloadRequest):
* UIProcess/API/efl/ewk_context.cpp:
(_Ewk_Context):
(_Ewk_Context::_Ewk_Context):
(ewk_context_ref):
(ewk_context_unref):
(ewk_context_new):
(ewk_context_new_with_injected_bundle_path):
* UIProcess/API/efl/ewk_context.h:
* UIProcess/API/efl/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_Ewk_View_Private_Data::_Ewk_View_Private_Data):
(_ewk_view_priv_del):
(_ewk_view_initialize):
(ewk_view_context_get):
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp: Added.
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp:
(EWK2UnitTest::EWK2UnitTestEnvironment::injectedBundleSample):
(EWK2UnitTest):
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h:
(EWK2UnitTestEnvironment):
* UIProcess/API/efl/tests/test_ewk2_context.cpp:
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
Source/WebKit2/UIProcess/API/efl/ewk_context.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.h
Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp
Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

index 310e5fe..0cd3218 100644 (file)
@@ -1,3 +1,46 @@
+2012-09-20  Eunmi Lee  <eunmi15.lee@samsung.com>
+
+        [EFL][WK2] Add APIs to create, delete and get ewk_context.
+        https://bugs.webkit.org/show_bug.cgi?id=89186
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide APIs to create ewk_context with or without injected bundle path
+        and delete created ewk_context.
+        Additionally, the ewk_view can be created with ewk_context which is not
+        default context, so we have to get ewk_context from ewk_view.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::handleDownloadRequest):
+        * UIProcess/API/efl/ewk_context.cpp:
+        (_Ewk_Context):
+        (_Ewk_Context::_Ewk_Context):
+        (ewk_context_ref):
+        (ewk_context_unref):
+        (ewk_context_new):
+        (ewk_context_new_with_injected_bundle_path):
+        * UIProcess/API/efl/ewk_context.h:
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_Ewk_View_Private_Data::_Ewk_View_Private_Data):
+        (_ewk_view_priv_del):
+        (_ewk_view_initialize):
+        (ewk_view_context_get):
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp: Added.
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp:
+        (EWK2UnitTest::EWK2UnitTestEnvironment::injectedBundleSample):
+        (EWK2UnitTest):
+        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h:
+        (EWK2UnitTestEnvironment):
+        * UIProcess/API/efl/tests/test_ewk2_context.cpp:
+        (TEST_F):
+        * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:
+        (TEST_F):
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        (TEST_F):
+
 2012-09-20  KwangYong Choi  <ky0.choi@samsung.com>
 
         [EFL][WK2] Implemented color picker API
index 80210b9..1a3fa0c 100644 (file)
@@ -261,6 +261,7 @@ ENDIF()
 
 SET(WEBKIT2_EFL_TEST_DIR "${WEBKIT2_DIR}/UIProcess/API/efl/tests")
 SET(TEST_RESOURCES_DIR ${WEBKIT2_EFL_TEST_DIR}/resources)
+SET(TEST_INJECTED_BUNDLE_DIR ${WEBKIT2_EFL_TEST_DIR}/InjectedBundle)
 
 ADD_DEFINITIONS(-DTEST_RESOURCES_DIR=\"${TEST_RESOURCES_DIR}\"
     -DTEST_THEME_DIR=\"${THEME_BINARY_DIR}\"
@@ -300,6 +301,9 @@ IF (ENABLE_API_TESTS)
         SET_TESTS_PROPERTIES(${testName} PROPERTIES TIMEOUT 60)
         TARGET_LINK_LIBRARIES(${testName} ${EWK2UnitTests_LIBRARIES} ewk2UnitTestUtils)
     ENDFOREACH ()
+
+    ADD_LIBRARY(ewk2UnitTestInjectedBundleSample SHARED ${TEST_INJECTED_BUNDLE_DIR}/injected_bundle_sample.cpp)
+    SET_TARGET_PROPERTIES(ewk2UnitTestInjectedBundleSample PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TEST_RESOURCES_DIR}")
 ENDIF ()
 
 IF (ENABLE_INSPECTOR)
index 1006339..ef2ce60 100644 (file)
@@ -285,10 +285,7 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin
 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
 {
     Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget);
-    // For now we only support one default context, but once we support
-    // multiple contexts, we will need to retrieve the context from the
-    // view.
-    ewk_context_download_job_add(ewk_context_default_get(), ewkDownload);
+    ewk_context_download_job_add(ewk_view_context_get(m_viewWidget), ewkDownload);
     ewk_download_job_unref(ewkDownload);
 }
 
index e23f6b0..b34ff77 100644 (file)
 #include "WKNumber.h"
 #include "WKRetainPtr.h"
 #include "WKString.h"
+#include "WebContext.h"
 #include "ewk_context_download_client_private.h"
 #include "ewk_context_private.h"
 #include "ewk_context_request_manager_client_private.h"
 #include "ewk_cookie_manager_private.h"
 #include "ewk_download_job.h"
 #include "ewk_download_job_private.h"
+#include <WebCore/FileSystem.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/WTFString.h>
 
+using namespace WebCore;
 using namespace WebKit;
 
 struct _Ewk_Url_Scheme_Handler {
@@ -57,6 +60,7 @@ struct _Ewk_Url_Scheme_Handler {
 typedef HashMap<String, _Ewk_Url_Scheme_Handler> URLSchemeHandlerMap;
 
 struct _Ewk_Context {
+    unsigned __ref; /**< the reference count of the object */
     WKRetainPtr<WKContextRef> context;
 
     Ewk_Cookie_Manager* cookieManager;
@@ -72,7 +76,8 @@ struct _Ewk_Context {
     URLSchemeHandlerMap urlSchemeHandlers;
 
     _Ewk_Context(WKRetainPtr<WKContextRef> contextRef)
-        : context(contextRef)
+        : __ref(1)
+        , context(contextRef)
         , cookieManager(0)
         , requestManager(WKContextGetSoupRequestManager(contextRef.get()))
     {
@@ -112,6 +117,25 @@ struct _Ewk_Context {
     }
 };
 
+Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
+    ++ewkContext->__ref;
+
+    return ewkContext;
+}
+
+void ewk_context_unref(Ewk_Context* ewkContext)
+{
+    EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+    EINA_SAFETY_ON_FALSE_RETURN(ewkContext->__ref > 0);
+
+    if (--ewkContext->__ref)
+        return;
+
+    delete ewkContext;
+}
+
 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
@@ -215,6 +239,22 @@ Ewk_Context* ewk_context_default_get()
     return &defaultContext;
 }
 
+Ewk_Context* ewk_context_new()
+{
+    return new Ewk_Context(adoptWK(WKContextCreate()));
+}
+
+Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
+
+    WKRetainPtr<WKStringRef> pathRef(AdoptWK, WKStringCreateWithUTF8CString(path));
+    if (!fileExists(toImpl(pathRef.get())->string()))
+        return 0;
+
+    return new Ewk_Context(adoptWK(WKContextCreateWithInjectedBundlePath(pathRef.get())));
+}
+
 Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData)
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
index 5e4d342..e6e9e0c 100644 (file)
  * @brief   Describes the context API.
  *
  * @note ewk_context encapsulates all pages related to specific use of WebKit.
- * All pages in this context share the same visited link set,
- * local storage set, and preferences.
+ *
+ * Applications have the option of creating a context different than the default one
+ * and use it for a group of pages. All pages in the same context share the same
+ * preferences, visited link set, local storage, etc.
+ *
+ * A process model can be specified per context. The default one is the shared model
+ * where the web-engine process is shared among the pages in the context. The second
+ * model allows each page to use a separate web-engine process. This latter model is
+ * currently not supported by WebKit2/EFL.
+ *
  */
 
 #ifndef ewk_context_h
@@ -61,11 +69,58 @@ typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *u
 typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data);
 
 /**
+ * Increases the reference count of the given object.
+ *
+ * @param context context object to increase the reference count
+ *
+ * @return Ewk_Context object on success or @c NULL on failure
+ */
+EAPI Ewk_Context *ewk_context_ref(Ewk_Context *context);
+
+/**
+ * Decreases the reference count of the given object, possibly freeing it.
+ *
+ * When the reference count it's reached 0, the Ewk_Context is freed.
+ *
+ * @param context context object to decrease the reference count
+ */
+EAPI void ewk_context_unref(Ewk_Context *context);
+
+/**
  * Gets default Ewk_Context instance.
  *
+ * The returned Ewk_Context object @b should not be unref'ed if application
+ * does not call ewk_context_ref() for that.
+ *
  * @return Ewk_Context object.
  */
-EAPI Ewk_Context *ewk_context_default_get();
+EAPI Ewk_Context *ewk_context_default_get(void);
+
+/**
+ * Creates a new Ewk_Context.
+ *
+ * The returned Ewk_Context object @b should be unref'ed after use.
+ *
+ * @return Ewk_Context object on success or @c NULL on failure
+ *
+ * @see ewk_context_unref
+ * @see ewk_context_new_with_injected_bundle_path
+ */
+EAPI Ewk_Context *ewk_context_new(void);
+
+/**
+ * Creates a new Ewk_Context.
+ *
+ * The returned Ewk_Context object @b should be unref'ed after use.
+ *
+ * @param path path of injected bundle library
+ *
+ * @return Ewk_Context object on success or @c NULL on failure
+ *
+ * @see ewk_context_unref
+ * @see ewk_context_new
+ */
+EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path);
 
 /**
  * Gets the cookie manager instance for this @a context.
index bbbfc18..0eab8b5 100644 (file)
@@ -100,6 +100,7 @@ struct _Ewk_View_Private_Data {
     OwnPtr<Ewk_Settings> settings;
     bool areMouseEventsEnabled;
     WKColorPickerResultListenerRef colorPickerResultListener;
+    Ewk_Context* context;
 
     WebPopupMenuProxyEfl* popupMenuProxy;
     Eina_List* popupMenuItems;
@@ -119,6 +120,7 @@ struct _Ewk_View_Private_Data {
         , backForwardList(0)
         , areMouseEventsEnabled(false)
         , colorPickerResultListener(0)
+        , context(0)
         , popupMenuProxy(0)
         , popupMenuItems(0)
 #ifdef HAVE_ECORE_X
@@ -384,6 +386,7 @@ static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingR
 
 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
 {
+    ewk_context_unref(priv->context);
     delete priv;
 }
 
@@ -714,6 +717,7 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP
 
     priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList()));
     priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
+    priv->context = ewk_context_ref(context);
 
 #if USE(COORDINATED_GRAPHICS)
     priv->viewportHandler = EflViewportHandler::create(ewkView);
@@ -798,6 +802,14 @@ Evas_Object* ewk_view_add(Evas* canvas)
     return ewk_view_add_with_context(canvas, ewk_context_default_get());
 }
 
+Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
+{
+    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+    return priv->context;
+}
+
 /**
  * @internal
  * The uri of view was changed by the frame loader.
index 13b8daf..3149751 100644 (file)
@@ -319,6 +319,15 @@ EAPI Evas_Object *ewk_view_add(Evas *e);
 EAPI Evas_Object *ewk_view_add_with_context(Evas *e, Ewk_Context *context);
 
 /**
+ * Gets the Ewk_Context of this view.
+ *
+ * @param o the view object to get the Ewk_Context
+ *
+ * @return the Ewk_Context of this view or @c NULL on failure
+ */
+EAPI Ewk_Context *ewk_view_context_get(const Evas_Object *o);
+
+/**
  * Asks the object to load the given URI.
  *
  * @param o view object to load @a URI
diff --git a/Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp b/Source/WebKit2/UIProcess/API/efl/tests/InjectedBundle/injected_bundle_sample.cpp
new file mode 100644 (file)
index 0000000..55f0f19
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <WebKit2/WKBundleInitialize.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void WKBundleInitialize(WKBundleRef bundle, WKTypeRef initializationUserData)
+{
+}
+
+#ifdef __cplusplus
+}
+#endif
index 814f8c2..cd3c55d 100644 (file)
@@ -43,6 +43,11 @@ const char* EWK2UnitTestEnvironment::defaultTheme() const
     return TEST_THEME_DIR"/default.edj";
 }
 
+const char* EWK2UnitTestEnvironment::injectedBundleSample() const
+{
+    return TEST_RESOURCES_DIR "/libewk2UnitTestInjectedBundleSample.so";
+}
+
 CString EWK2UnitTestEnvironment::urlForResource(const char* resource)
 {
     return makeString("file://"TEST_RESOURCES_DIR"/", resource).utf8();
index fb3a309..4255b01 100644 (file)
@@ -32,6 +32,7 @@ public:
     bool useX11Window() const { return m_useX11Window; }
     const char* defaultTestPageUrl() const;
     const char* defaultTheme() const;
+    const char* injectedBundleSample() const;
     CString urlForResource(const char* resource);
     CString pathForResource(const char* resource);
 
index b5ce2ee..82ded55 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,9 +47,10 @@ TEST_F(EWK2UnitTestBase, ewk_context_default_get)
 
 TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get)
 {
-    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    Ewk_Context* context = ewk_view_context_get(webView());
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(context);
     ASSERT_TRUE(cookieManager);
-    ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(ewk_context_default_get()));
+    ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(context));
 }
 
 static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData)
@@ -64,7 +66,7 @@ static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userDat
 
 TEST_F(EWK2UnitTestBase, ewk_context_uri_scheme_register)
 {
-    ewk_context_uri_scheme_register(ewk_context_default_get(), "fooscheme", schemeRequestCallback, 0);
+    ewk_context_uri_scheme_register(ewk_view_context_get(webView()), "fooscheme", schemeRequestCallback, 0);
     loadUrlSync("fooscheme:MyPath");
     ASSERT_STREQ(ewk_view_title_get(webView()), "Foo");
 }
@@ -114,7 +116,7 @@ static void loadVibrationHTMLString(Evas_Object* webView, const char* vibrationP
 TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set)
 {
     VibrationCbData data = { false, false, 0, 5000 };
-    ewk_context_vibration_client_callbacks_set(ewk_context_default_get(), vibrateCallback, cancelVibrationCallback, &data);
+    ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), vibrateCallback, cancelVibrationCallback, &data);
 
     // Vibrate for 5 seconds.
     loadVibrationHTMLString(webView(), "5000", true, &data);
@@ -134,7 +136,7 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set)
     ASSERT_TRUE(data.didReceiveCancelVibrationCallback);
 
     // Stop listening for vibration events, by calling the function with null for the callbacks.
-    ewk_context_vibration_client_callbacks_set(ewk_context_default_get(), 0, 0, &data);
+    ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), 0, 0, &data);
 
     // Make sure we don't receive vibration event.
     loadVibrationHTMLString(webView(), "[5000]", false, &data);
@@ -148,3 +150,25 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set)
     ASSERT_STREQ(ewk_view_title_get(webView()), "Loaded");
     ASSERT_FALSE(data.didReceiveCancelVibrationCallback);
 }
+
+TEST_F(EWK2UnitTestBase, ewk_context_new)
+{
+    Ewk_Context* context = ewk_context_new();
+    ASSERT_TRUE(context);
+    ewk_context_unref(context);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_context_new_with_injected_bundle_path)
+{
+    Ewk_Context* context = ewk_context_new_with_injected_bundle_path(environment->injectedBundleSample());
+    ASSERT_TRUE(context);
+    ewk_context_unref(context);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_context_ref)
+{
+    Ewk_Context* context = ewk_context_new();
+    ASSERT_EQ(context, ewk_context_ref(context));
+    ewk_context_unref(context);
+    ewk_context_unref(context);
+}
index e0319f7..4353ced 100644 (file)
@@ -121,7 +121,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy)
     OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
     httpServer->run(serverCallback);
 
-    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView()));
     ASSERT_TRUE(cookieManager);
 
     // Default policy is EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY.
@@ -164,7 +164,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch)
     OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
     httpServer->run(serverCallback);
 
-    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView()));
     ASSERT_TRUE(cookieManager);
 
     ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
@@ -227,7 +227,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete)
     OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
     httpServer->run(serverCallback);
 
-    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView()));
     ASSERT_TRUE(cookieManager);
 
     ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
@@ -269,7 +269,7 @@ TEST_F(EWK2UnitTestBase, DISABLED_ewk_cookie_manager_permanent_storage)
     char sqliteStorage[] = "/tmp/sqlite-cookie.XXXXXX";
     ASSERT_TRUE(mktemp(sqliteStorage));
 
-    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_context_default_get());
+    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView()));
     ASSERT_TRUE(cookieManager);
 
     ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
index 25f62fc..8c258ba 100644 (file)
@@ -714,4 +714,11 @@ TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set)
         ecore_main_loop_iterate();
     evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone);
 }
+
+TEST_F(EWK2UnitTestBase, ewk_view_context_get)
+{
+    Ewk_Context* context = ewk_view_context_get(webView());
+    ASSERT_TRUE(context);
+    ASSERT_EQ(context, ewk_view_context_get(webView()));
+}
 #endif // ENABLE(INPUT_TYPE_COLOR)