4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation; either version 2.1 of the License, or (at your option)
11 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @file utc_webkit2_ewk_context_web_database.h
24 * @author SangYong Park <sy302.park@samsung.com>
26 * @brief A header file to be used by ewk_context_web_database unit test cases
29 #define WEB_DATABASE_PROTOCOL "http"
30 #define WEB_DATABASE_HOST "unittest.com"
31 #define WEB_DATABASE_PORT 0
33 const char* webDatabaseURL = WEB_DATABASE_PROTOCOL "://" WEB_DATABASE_HOST "/";
34 const char* webDatabaseScript = "var db = openDatabase('test', '1.0', 'test db', 1024);"
36 "db.transaction(function (tx) {"
37 "tx.executeSql('CREATE TABLE tbl(id INTEGER)');"
38 "tx.executeSql('INSERT INTO tbl(id) VALUES(1)')"
39 "}, function () { result = 1 }, function () { result = -1 });";
40 const char* webDatabaseResultScript = "result";
42 typedef void (*Web_Storage_Callback)();
44 Web_Storage_Callback finishedCallback;
45 Web_Storage_Callback errorCallback;
47 static void scriptExecuted(Evas_Object* o, const char* result, void* data)
49 int value = atoi(result);
51 if (!ewk_view_script_execute(test_view.webview, webDatabaseResultScript, scriptExecuted, 0))
59 static void loadFinished(void* data, Evas_Object* webview, void* info)
61 if (!ewk_view_script_execute(test_view.webview, webDatabaseScript, scriptExecuted, 0))
65 static void loadError(void* data, Evas_Object* webview, void* info)
70 static Eina_Bool addWebDatabase(Web_Storage_Callback finished, Web_Storage_Callback error)
72 finishedCallback = finished;
73 errorCallback = error;
75 evas_object_smart_callback_add(test_view.webview, "load,finished", loadFinished, 0);
76 evas_object_smart_callback_add(test_view.webview, "load,error", loadError, 0);
78 return ewk_view_html_contents_set(test_view.webview, "", webDatabaseURL);