1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* Copyright (C) 2011 Lukasz Slachciak
*
* 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <glib.h>
#include <glib/gprintf.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#if GTK_CHECK_VERSION(2, 14, 0)
static void test_application_cache_maximum_size()
{
unsigned long long maxSize = 8192;
webkit_application_cache_set_maximum_size(maxSize);
// Creating a WebView - make sure that it didn't change anything
WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_object_unref(webView);
g_assert(maxSize == webkit_application_cache_get_maximum_size());
}
static void test_application_cache_database_directory_path()
{
unsigned long long maxSize = 8192;
webkit_application_cache_set_maximum_size(maxSize);
gchar* databaseDirectorySet = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
webkit_application_cache_set_database_directory_path(databaseDirectorySet);
// Creating a WebView - make sure that it didn't change anything
WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
g_object_unref(webView);
const gchar* databaseDirectoryGet = webkit_application_cache_get_database_directory_path();
g_assert_cmpstr(databaseDirectorySet, ==, databaseDirectoryGet);
g_free(databaseDirectorySet);
}
int main(int argc, char** argv)
{
g_thread_init(NULL);
gtk_test_init(&argc, &argv, NULL);
g_test_bug_base("https://bugs.webkit.org/");
g_test_add_func("/webkit/application_cache/maximum_size",
test_application_cache_maximum_size);
g_test_add_func("/webkit/application_cache/database_directory_path",
test_application_cache_database_directory_path);
return g_test_run();
}
#else
int main(int argc, char** argv)
{
g_critical("You will need gtk-2.14.0 to run the unit tests. Doing nothing now.");
return 0;
}
#endif
|