Source/WebKit2/ChangeLog

 12014-03-16 Ryuan Choi <ryuan.choi@samsung.com>
 2
 3 [EFL][WK2] Add ewk_application_cache_manager APIs
 4 https://bugs.webkit.org/show_bug.cgi?id=102853
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implemented application cache manager to get list of origins which stores
 9 application cache and remove specified origin or all.
 10
 11 * PlatformEfl.cmake: Added newly added files.
 12 * UIProcess/API/efl/ewk_application_cache_manager.cpp: Added.
 13 (EwkApplicationCacheManager::EwkApplicationCacheManager):
 14 (EwkApplicationCacheManager::~EwkApplicationCacheManager):
 15 (Get_Origins_Data::Get_Origins_Data):
 16 (getApplicationCacheOriginsCallback):
 17 (ewk_application_cache_manager_origins_get):
 18 (ewk_application_cache_origins_free):
 19 (ewk_application_cache_manager_delete_all):
 20 (ewk_application_cache_manager_delete):
 21 * UIProcess/API/efl/ewk_application_cache_manager.h: Added.
 22 * UIProcess/API/efl/ewk_application_cache_manager_private.h: Added.
 23 (EwkApplicationCacheManager::impl):
 24 * UIProcess/API/efl/ewk_context.cpp:
 25 (EwkContext::applicationCacheManager):
 26 (ewk_context_application_cache_manager_get):
 27 * UIProcess/API/efl/ewk_context.h:
 28 * UIProcess/API/efl/ewk_context_private.h:
 29 * UIProcess/API/efl/ewk_security_origin_private.h:
 30 (EwkSecurityOrigin::wkSecurityOrigin):
 31 * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp:
 32 (EWK2UnitTestServer::port):
 33 * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h:
 34 * UIProcess/API/efl/tests/test_ewk2_application_cache_manager.cpp:
 35 Added to test application_cache_manager.
 36 (serverCallback):
 37 (getOriginsCallback):
 38 (timerCallback):
 39 (TEST_F):
 40 * UIProcess/API/efl/tests/test_ewk2_context.cpp:
 41 Added test case to test getter of application_cache_manager.
 42 (TEST_F):
 43
1442014-03-16 Zan Dobersek <zdobersek@igalia.com>
245
346 Move GTK WebKit2 code to std::unique_ptr

Source/WebKit2/PlatformEfl.cmake

@@list(APPEND WebKit2_SOURCES
7373 UIProcess/API/efl/EwkView.cpp
7474 UIProcess/API/efl/GestureRecognizer.cpp
7575 UIProcess/API/efl/SnapshotImageGL.cpp
 76 UIProcess/API/efl/ewk_application_cache_manager.cpp
7677 UIProcess/API/efl/ewk_auth_request.cpp
7778 UIProcess/API/efl/ewk_back_forward_list.cpp
7879 UIProcess/API/efl/ewk_back_forward_list_item.cpp

@@set(EWebKit2_HEADERS
336337 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_auth_request.h"
337338 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_back_forward_list.h"
338339 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_back_forward_list_item.h"
 340 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_application_cache_manager.h"
339341 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_color_picker.h"
340342 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_context.h"
341343 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_context_menu.h"

@@target_link_libraries(ewk2UnitTestUtils ${EWK2UnitTests_LIBRARIES})
448450# The "ewk" on the test name needs to be suffixed with "2", otherwise it
449451# will clash with tests from the WebKit 1 test suite.
450452set(EWK2UnitTests_BINARIES
 453 test_ewk2_application_cache_manager
451454 test_ewk2_auth_request
452455 test_ewk2_back_forward_list
453456 test_ewk2_color_picker

Source/WebKit2/UIProcess/API/efl/ewk_application_cache_manager.cpp

 1/*
 2 * Copyright (C) 2014 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "ewk_application_cache_manager.h"
 28
 29#include "WKArray.h"
 30#include "ewk_application_cache_manager_private.h"
 31#include "ewk_object.h"
 32#include "ewk_security_origin_private.h"
 33
 34using namespace WebKit;
 35
 36EwkApplicationCacheManager::EwkApplicationCacheManager(WKApplicationCacheManagerRef applicationCacheManager)
 37 : m_applicationCacheManager(applicationCacheManager)
 38{
 39}
 40
 41EwkApplicationCacheManager::~EwkApplicationCacheManager()
 42{
 43}
 44
 45struct Get_Origins_Data {
 46 Ewk_Application_Cache_Origins_Get_Cb callback;
 47 void* userData;
 48
 49 Get_Origins_Data(Ewk_Application_Cache_Origins_Get_Cb callback, void* userData)
 50 : callback(callback)
 51 , userData(userData)
 52 { }
 53};
 54
 55static void getApplicationCacheOriginsCallback(WKArrayRef wkOrigins, WKErrorRef, void* context)
 56{
 57 Eina_List* origins = nullptr;
 58 auto callbackData = std::unique_ptr<Get_Origins_Data>(static_cast<Get_Origins_Data*>(context));
 59
 60 const size_t originsCount = WKArrayGetSize(wkOrigins);
 61 for (size_t i = 0; i < originsCount; ++i) {
 62 WKSecurityOriginRef securityOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(wkOrigins, i));
 63 origins = eina_list_append(origins, EwkSecurityOrigin::create(securityOriginRef).leakRef());
 64 }
 65
 66 callbackData->callback(origins, callbackData->userData);
 67}
 68
 69void ewk_application_cache_manager_origins_get(const Ewk_Application_Cache_Manager* manager, Ewk_Application_Cache_Origins_Get_Cb callback, void* userData)
 70{
 71 EINA_SAFETY_ON_NULL_RETURN(manager);
 72 EINA_SAFETY_ON_NULL_RETURN(callback);
 73
 74 Get_Origins_Data* callbackData = new Get_Origins_Data(callback, userData);
 75 WKApplicationCacheManagerGetApplicationCacheOrigins(manager->impl(), callbackData, getApplicationCacheOriginsCallback);
 76}
 77
 78Eina_Bool ewk_application_cache_manager_delete_all(Ewk_Application_Cache_Manager* manager)
 79{
 80 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, false);
 81
 82 WKApplicationCacheManagerDeleteAllEntries(manager->impl());
 83
 84 return true;
 85}
 86
 87Eina_Bool ewk_application_cache_manager_delete(Ewk_Application_Cache_Manager* manager, Ewk_Security_Origin* origin)
 88{
 89 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, false);
 90 EWK_OBJ_GET_IMPL_OR_RETURN(EwkSecurityOrigin, origin, impl, false);
 91
 92 WKApplicationCacheManagerDeleteEntriesForOrigin(manager->impl(), impl->wkSecurityOrigin());
 93
 94 return true;
 95}

Source/WebKit2/UIProcess/API/efl/ewk_application_cache_manager.h

 1/*
 2 * Copyright (C) 2014 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26/**
 27 * @file ewk_application_cache_manager.h
 28 * @brief Describes the Ewk Application Cache Manager API.
 29 */
 30
 31#ifndef ewk_application_cache_manager_h
 32#define ewk_application_cache_manager_h
 33
 34#include "ewk_security_origin.h"
 35#include <Eina.h>
 36
 37#ifdef __cplusplus
 38extern "C" {
 39#endif
 40
 41/** Creates a type name for Ewk_Application_Cache_Manager */
 42typedef struct EwkApplicationCacheManager Ewk_Application_Cache_Manager;
 43
 44/**
 45 * @typedef Ewk_Application_Cache_Origins_Get_Cb Ewk_Application_Cache_Origins_Get_Cb
 46 * @brief Callback for ewk_application_cache_manager_origins_get
 47 *
 48 * @note The @a origins should be freed like below code after use.
 49 *
 50 * @code
 51 *
 52 * static void
 53 * _origins_get_cb(Eina_List* origins, data)
 54 * {
 55 * // ...
 56 *
 57 * void *origin;
 58 * EINA_LIST_FREE(origins, origin)
 59 * ewk_object_unref((Ewk_Object*)origin);
 60 * }
 61 *
 62 * @endcode
 63 */
 64typedef void (*Ewk_Application_Cache_Origins_Get_Cb)(Eina_List *origins, void *user_data);
 65
 66/**
 67 * Requests for getting web application cache origins.
 68 *
 69 * @param context context object
 70 * @param result_callback callback to get web application cache origins
 71 * @param user_data user_data will be passsed when result_callback is called
 72 *
 73 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
 74 *
 75 * @see Ewk_Application_Cache_Origins_Get_Cb
 76 */
 77EAPI void ewk_application_cache_manager_origins_get(const Ewk_Application_Cache_Manager *manager, Ewk_Application_Cache_Origins_Get_Cb callback, void *data);
 78
 79/**
 80 * Requests for deleting all web application caches.
 81 *
 82 * @param context context object
 83 *
 84 * @return @c EINA_TRUE on successful request or @c EINA FALSE on failure
 85 */
 86EAPI Eina_Bool ewk_application_cache_manager_delete_all(Ewk_Application_Cache_Manager *manager);
 87
 88/**
 89 * Requests for deleting web application cache for origin.
 90 *
 91 * @param context context object
 92 * @param origin application cache origin
 93 *
 94 * @return @c EINA_TRUE on successful request or @c EINA_FALSE on failure
 95 */
 96EAPI Eina_Bool ewk_application_cache_manager_delete(Ewk_Application_Cache_Manager *manager, Ewk_Security_Origin *origin);
 97
 98#ifdef __cplusplus
 99}
 100#endif
 101
 102#endif // ewk_application_cache_manager_h

Source/WebKit2/UIProcess/API/efl/ewk_application_cache_manager_private.h

 1/*
 2 * Copyright (C) 2014 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef ewk_application_cache_manager_private_h
 27#define ewk_application_cache_manager_private_h
 28
 29#include "WKApplicationCacheManager.h"
 30#include "WKRetainPtr.h"
 31#include <WebKit2/WKBase.h>
 32
 33class EwkApplicationCacheManager {
 34public:
 35 explicit EwkApplicationCacheManager(WKApplicationCacheManagerRef applicationCacheManager);
 36 ~EwkApplicationCacheManager();
 37
 38 WKApplicationCacheManagerRef impl() const { return m_applicationCacheManager.get(); }
 39
 40private:
 41 WKRetainPtr<WKApplicationCacheManagerRef> m_applicationCacheManager;
 42};
 43
 44#endif // ewk_application_cache_manager_private_h

Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

2727#include "NetworkInfoProvider.h"
2828#include "RequestManagerClientEfl.h"
2929#include "WKAPICast.h"
 30#include "WKContextPrivate.h"
3031#include "WKContextSoup.h"
3132#include "WKNumber.h"
3233#include "WKString.h"
3334#include "WebContext.h"
3435#include "WebIconDatabase.h"
 36#include "ewk_application_cache_manager_private.h"
3537#include "ewk_context_private.h"
3638#include "ewk_cookie_manager_private.h"
3739#include "ewk_database_manager_private.h"

@@EwkContext* EwkContext::defaultContext()
139141 return defaultInstance;
140142}
141143
 144EwkApplicationCacheManager* EwkContext::applicationCacheManager()
 145{
 146 if (!m_applicationCacheManager)
 147 m_applicationCacheManager = std::make_unique<EwkApplicationCacheManager>(WKContextGetApplicationCacheManager(m_context.get()));
 148
 149 return m_applicationCacheManager.get();
 150}
 151
142152EwkCookieManager* EwkContext::cookieManager()
143153{
144154 if (!m_cookieManager)

@@JSGlobalContextRef EwkContext::jsGlobalContext()
249259 return m_jsGlobalContext;
250260}
251261
 262Ewk_Application_Cache_Manager* ewk_context_application_cache_manager_get(const Ewk_Context* ewkContext)
 263{
 264 EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, nullptr);
 265
 266 return const_cast<EwkContext*>(impl)->applicationCacheManager();
 267}
 268
252269Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext)
253270{
254271 EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, nullptr);

Source/WebKit2/UIProcess/API/efl/ewk_context.h

3737#ifndef ewk_context_h
3838#define ewk_context_h
3939
 40#include "ewk_application_cache_manager.h"
4041#include "ewk_cookie_manager.h"
4142#include "ewk_database_manager.h"
4243#include "ewk_favicon_database.h"

@@EAPI Ewk_Context *ewk_context_new(void);
161162EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path);
162163
163164/**
 165 * Gets the application cache manager instance for this @a context.
 166 *
 167 * @param context context object to query.
 168 *
 169 * @return Ewk_Cookie_Manager object instance or @c NULL in case of failure.
 170 */
 171EAPI Ewk_Application_Cache_Manager *ewk_context_application_cache_manager_get(const Ewk_Context *context);
 172
 173/**
164174 * Gets the cookie manager instance for this @a context.
165175 *
166176 * @param context context object to query.

Source/WebKit2/UIProcess/API/efl/ewk_context_private.h

3030
3131using namespace WebKit;
3232
 33class EwkApplicationCacheManager;
3334class EwkCookieManager;
3435class EwkFaviconDatabase;
3536

@@public:
5758
5859 ~EwkContext();
5960
 61 EwkApplicationCacheManager* applicationCacheManager();
6062 EwkCookieManager* cookieManager();
61 
6263 EwkDatabaseManager* databaseManager();
6364
6465 bool setFaviconDatabaseDirectoryPath(const String& databaseDirectory);

@@private:
100101
101102 WKRetainPtr<WKContextRef> m_context;
102103
 104 std::unique_ptr<EwkApplicationCacheManager> m_applicationCacheManager;
103105 std::unique_ptr<EwkCookieManager> m_cookieManager;
104106 std::unique_ptr<EwkDatabaseManager> m_databaseManager;
105107 std::unique_ptr<EwkFaviconDatabase> m_faviconDatabase;

Source/WebKit2/UIProcess/API/efl/ewk_security_origin_private.h

@@public:
4949 const char* protocol() const;
5050 uint32_t port() const;
5151
 52 WKSecurityOriginRef wkSecurityOrigin() const { return m_wkOrigin.get(); }
 53
5254private:
5355 explicit EwkSecurityOrigin(WKSecurityOriginRef originRef);
5456 explicit EwkSecurityOrigin(const char* url);

Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp

@@CString EWK2UnitTestServer::getURLForPath(const char* path) const
5454
5555 return urlString;
5656}
 57
 58unsigned EWK2UnitTestServer::port() const
 59{
 60 return soup_server_get_port(m_soupServer);
 61}

Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h

@@public:
3030 virtual ~EWK2UnitTestServer();
3131
3232 CString getURLForPath(const char* path) const;
 33 unsigned port() const;
 34
3335 void run(SoupServerCallback);
3436
3537private:

Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_application_cache_manager.cpp

 1/*
 2 * Copyright (C) 2014 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27
 28#include "UnitTestUtils/EWK2UnitTestBase.h"
 29#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
 30#include "UnitTestUtils/EWK2UnitTestServer.h"
 31#include <EWebKit2.h>
 32
 33using namespace EWK2UnitTest;
 34
 35static const char applicationCacheHtml[] =
 36 "<!doctype html>"
 37 "<html manifest='test.appcache'>"
 38 "<head><link rel='stylesheet' href='clock.css'></head>"
 39 "<body>Application Cache Test</body>"
 40 "</html>";
 41static const char applicationCacheManifest[] = "CACHE MANIFEST\n"
 42 "application_cache.html\n"
 43 "clock.css";
 44static const char applicationCacheCss[] = "output { font:2em sans-serif; }";
 45static const char applicationCacheHtmlFile[] = "/application_cache.html";
 46static const char applicationCacheManifestFile[] = "/test.appcache";
 47static const char applicationCacheCssFile[] = "/clock.css";
 48
 49static void serverCallback(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
 50{
 51 if (message->method != SOUP_METHOD_GET) {
 52 soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
 53 return;
 54 }
 55
 56 soup_message_set_status(message, SOUP_STATUS_OK);
 57 Eina_Strbuf* body = eina_strbuf_new();
 58
 59 if (!strcmp(path, applicationCacheHtmlFile))
 60 eina_strbuf_append_printf(body, applicationCacheHtml);
 61 else if (!strcmp(path, applicationCacheManifestFile))
 62 eina_strbuf_append_printf(body, applicationCacheManifest);
 63 else if (!strcmp(path, applicationCacheCssFile))
 64 eina_strbuf_append_printf(body, applicationCacheCss);
 65 else {
 66 soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
 67 soup_message_body_complete(message->response_body);
 68 eina_strbuf_free(body);
 69 return;
 70 }
 71
 72 const size_t bodyLength = eina_strbuf_length_get(body);
 73 soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, eina_strbuf_string_steal(body), bodyLength);
 74 eina_strbuf_free(body);
 75
 76 soup_message_body_complete(message->response_body);
 77}
 78
 79struct OriginsData {
 80 Eina_List* items;
 81 Ewk_Application_Cache_Manager* manager;
 82};
 83
 84static void getOriginsCallback(Eina_List* origins, void* event_info)
 85{
 86 Eina_List** ret = static_cast<Eina_List**>(event_info);
 87 *ret = origins;
 88 ecore_main_loop_quit();
 89}
 90
 91static Eina_Bool timerCallback(void* userData)
 92{
 93 OriginsData* data = static_cast<OriginsData*>(userData);
 94 ewk_application_cache_manager_origins_get(data->manager, getOriginsCallback, &data->items);
 95
 96 return true;
 97}
 98
 99TEST_F(EWK2UnitTestBase, ewk_application_cache_manager)
 100{
 101 std::unique_ptr<EWK2UnitTestServer> httpServer = std::make_unique<EWK2UnitTestServer>();
 102 httpServer->run(serverCallback);
 103
 104 Ecore_Timer* applicationCacheTimer;
 105 OriginsData data;
 106 data.manager = ewk_context_application_cache_manager_get(ewk_view_context_get(webView()));
 107
 108 // Before testing, remove all caches.
 109 ewk_application_cache_manager_delete_all(data.manager);
 110
 111 applicationCacheTimer = ecore_timer_add(0.5, timerCallback, &data);
 112 ecore_main_loop_begin();
 113 ASSERT_EQ(0, eina_list_count(data.items));
 114
 115 ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath(applicationCacheHtmlFile).data()));
 116
 117 applicationCacheTimer = ecore_timer_add(0.5, timerCallback, &data);
 118 ecore_main_loop_begin();
 119 ASSERT_EQ(1, eina_list_count(data.items));
 120
 121 ewk_application_cache_manager_delete(data.manager, static_cast<Ewk_Security_Origin*>(eina_list_nth(data.items, 0)));
 122
 123 void* origin;
 124 EINA_LIST_FREE(data.items, origin)
 125 ewk_object_unref(static_cast<Ewk_Object*>(origin));
 126
 127 data.items = nullptr;
 128
 129 applicationCacheTimer = ecore_timer_add(0.5, timerCallback, &data);
 130 ecore_main_loop_begin();
 131 ASSERT_EQ(0, eina_list_count(data.items));
 132}

Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp

@@TEST_F(EWK2ContextTest, ewk_context_default_get)
5555 ASSERT_EQ(defaultContext, ewk_context_default_get());
5656}
5757
 58TEST_F(EWK2UnitTestBase, ewk_context_application_cache_manager_get)
 59{
 60 Ewk_Context* context = ewk_view_context_get(webView());
 61 Ewk_Application_Cache_Manager* applicationCacheManager = ewk_context_application_cache_manager_get(context);
 62 ASSERT_TRUE(applicationCacheManager);
 63 ASSERT_EQ(applicationCacheManager, ewk_context_application_cache_manager_get(context));
 64}
 65
5866TEST_F(EWK2ContextTest, ewk_context_cookie_manager_get)
5967{
6068 Ewk_Context* context = ewk_view_context_get(webView());