// limitations under the License.
//
#include "ITs-webkit2-common.h"
+#include <storage.h>
/** @addtogroup itc-webkit2
* @ingroup itc
* @{
*/
+struct Ewk_Test_View {
+ Evas_Object* window;
+ Evas* evas;
+ Evas_Object* background;
+ Evas_Object* webview;
+ Evas_Smart* evas_smart_class;
+};
+static struct Ewk_Test_View test_view;
+char* EWK_CONTEXT_FAVICON_HTML_FILE = NULL;
+char* EWK_CONTEXT_FAVICON_HTML_FILENAME = "ewk_context/favicon.html";
+char* EWK_CONTEXT_FAVICON_BMP_FILE = NULL;
+char* EWK_CONTEXT_FAVICON_BMP_FILENAME = "ewk_context/favicon.bmp";
+#define FILE_PREFIX "file://"
+#define UNUSED __attribute__((unused))
+#define itc_webkit2_main_loop_quit ecore_main_loop_quit
+#define itc_webkit2_main_loop_begin ecore_main_loop_begin
static bool g_bWebkit_EFL_LoadSuccess = false;
static bool g_bWebkit_EFL_IconReceived = false;
+
+
static Eina_Bool mainLoopQuit(void* data)
{
FPRINTF("[Line : %d][%s] TimeOut Occurs\\n", __LINE__, API_NAMESPACE);
Webkit_EFL_main_loop_quit();
return EINA_FALSE;
}
+static void itc_webkit2_ewk_test_res_end(void)
+{
+ FPRINTF("[Line : %d][%s] Inside utc_webkit2_ewk_test_res_end \\n", __LINE__, API_NAMESPACE);
+ free(EWK_CONTEXT_FAVICON_HTML_FILE);
+ free(EWK_CONTEXT_FAVICON_BMP_FILE);
+}
+
+static void itc_webkit2_ewk_test_end()
+{
+ FPRINTF("[Line : %d][%s] Inside utc_webkit2_ewk_test_end \\n", __LINE__, API_NAMESPACE);
+ /* 1. Freeing resources */
+ if (test_view.webview)
+ evas_object_del(test_view.webview);
+
+ if (test_view.window)
+ evas_object_del(test_view.window);
+
+ /* 2. Closing whole EWK */
+ ewk_shutdown();
+ elm_shutdown();
+ itc_webkit2_ewk_test_res_end();
+}
+static Eina_Bool loadURL(const char* url)
+{
+ return ewk_view_url_set(test_view.webview, url);
+}
+
+bool ewk_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+{
+ if (type != STORAGE_TYPE_INTERNAL)
+ return true;
+
+ // FIX Path in ewk_storage_device_supported_cb return /home/owner/content
+ // instead of directory where package install sample files.
+ if(strcmp(path, app_get_data_path()))
+ path = app_get_data_path();
+
+
+ EWK_CONTEXT_FAVICON_HTML_FILE = (char*)malloc(strlen(path) + strlen(EWK_CONTEXT_FAVICON_HTML_FILENAME) + strlen(FILE_PREFIX) + 6);
+ snprintf(EWK_CONTEXT_FAVICON_HTML_FILE, (strlen(path) + strlen(EWK_CONTEXT_FAVICON_HTML_FILENAME) + strlen(FILE_PREFIX) + 6),
+ "%s%s/res/%s", FILE_PREFIX, path, EWK_CONTEXT_FAVICON_HTML_FILENAME);
+
+ EWK_CONTEXT_FAVICON_BMP_FILE = (char*)malloc(strlen(path) + strlen(EWK_CONTEXT_FAVICON_BMP_FILENAME) + strlen(FILE_PREFIX) + 6);
+ snprintf(EWK_CONTEXT_FAVICON_BMP_FILE, (strlen(path) + strlen(EWK_CONTEXT_FAVICON_BMP_FILENAME) + strlen(FILE_PREFIX) + 6),
+ "%s/res/%s", path, EWK_CONTEXT_FAVICON_BMP_FILENAME);
+
+ return false;
+}
+
+void itc_webkit2_ewk_test_res_init()
+{
+ if(storage_foreach_device_supported(ewk_storage_device_supported_cb, NULL) != STORAGE_ERROR_NONE) {
+ FPRINTF("Startup error at %s:%d\n", __FILE__, __LINE__);
+ }
+ if(EWK_CONTEXT_FAVICON_HTML_FILE == NULL ||
+ EWK_CONTEXT_FAVICON_BMP_FILE == NULL ) {
+ FPRINTF("Startup error at %s:%d\n", __FILE__, __LINE__);
+ }
+}
+/**
+ * Initiates objects used in the test.
+ *
+ * This function should be _always_ called before the actual test starts.
+ * @see utc_webkit2_ewk_test_end()
+ */
+static void itc_webkit2_ewk_test_init()
+{
+ elm_init(0, NULL);
+ ewk_init();
+ elm_config_accel_preference_set("opengl");
+
+ test_view.window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
+ elm_win_title_set(test_view.window, "TC Launcher");
+ test_view.evas = evas_object_evas_get(test_view.window);
+ test_view.background = evas_object_rectangle_add(test_view.evas);
+
+ evas_object_name_set(test_view.background, "view");
+ evas_object_color_set(test_view.background, 255, 0, 255, 255);
+ evas_object_move(test_view.background, 0, 0);
+ evas_object_resize(test_view.background, DEFAULT_WIDTH_OF_WINDOW, DEFAULT_HEIGHT_OF_WINDOW);
+ evas_object_layer_set(test_view.background, EVAS_LAYER_MIN);
+ //evas_object_show(test_view.background);
+
+ /* 3. Initialization of webview */
+ test_view.webview = ewk_view_add(test_view.evas);
+ evas_object_move(test_view.webview, 10, 10);
+ evas_object_resize(test_view.webview, DEFAULT_WIDTH_OF_WINDOW-20, DEFAULT_HEIGHT_OF_WINDOW-20);
+
+ //evas_object_show(test_view.webview);
+ //evas_object_show(test_view.window);
+ itc_webkit2_ewk_test_res_init();
+}
+
+static void iconReceived_Local(void* data, Evas_Object* webview, void* event_info)
+{
+ static const int PIXEL_SIZE = 4;
+ static int w = 0 , h = 0;
+ Ewk_Context* context = ewk_view_context_get(test_view.webview);
+
+
+ Evas_Object* favicon = ewk_context_icon_database_icon_object_add(context, EWK_CONTEXT_FAVICON_HTML_FILE, test_view.evas);
+
+ evas_object_image_size_get(favicon, &w, &h);
+
+ Evas_Object* img = evas_object_image_filled_add(test_view.evas);
+
+ evas_object_image_file_set(img, EWK_CONTEXT_FAVICON_BMP_FILE , NULL);
+
+ itc_webkit2_main_loop_quit();
+}
/**
* @function Webkit_EFL_LoadError
int ITc_ewk_context_icon_database_icon_object_add_p(void)
{
START_TEST;
+ FPRINTF("[Line : %d][%s] Inside TC\\n", __LINE__, API_NAMESPACE);
+
+ itc_webkit2_ewk_test_init();
+ evas_object_smart_callback_add(test_view.webview, "icon,received", iconReceived_Local, NULL);
+
+ if(!loadURL(EWK_CONTEXT_FAVICON_HTML_FILE))
+ {
+ FPRINTF("[Line : %d][%s] Not loadURL \\n", __LINE__, API_NAMESPACE);
+ return 1;
+ }
+ evas_object_smart_callback_del(test_view.webview, "icon,received", iconReceived_Local);
+ FPRINTF("[Line : %d][%s] After evas_object_smart_callback_del \\n", __LINE__, API_NAMESPACE);
+ itc_webkit2_ewk_test_end();
+ FPRINTF("[Line : %d][%s] After utc_webkit2_ewk_test_end \\n", __LINE__, API_NAMESPACE);
+
+ /*
if ( false == Webkit_EFLCreateWebKitView() )
{
return 1;
evas_object_smart_callback_del(objWebkit_EFL_view.webview, "icon,received", iconReceived);
Webkit_EFLDestroyWebKitView();
-
+*/
return 0;
+
}
//& purpose: Request for deleting all web application caches.