|
1 /* |
|
2 * Copyright (C) 2009 Jan Michael Alonzo |
|
3 * |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Library General Public |
|
6 * License as published by the Free Software Foundation; either |
|
7 * version 2 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This library is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * Library General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Library General Public License |
|
15 * along with this library; see the file COPYING.LIB. If not, write to |
|
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
17 * Boston, MA 02110-1301, USA. |
|
18 */ |
|
19 |
|
20 #include <glib.h> |
|
21 #include <gtk/gtk.h> |
|
22 #include <webkit/webkit.h> |
|
23 |
|
24 #if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0) |
|
25 |
|
26 typedef struct { |
|
27 WebKitWebHistoryItem* item; |
|
28 } WebHistoryItemFixture; |
|
29 |
|
30 static void web_history_item_fixture_setup(WebHistoryItemFixture* fixture, |
|
31 gconstpointer data) |
|
32 { |
|
33 fixture->item = webkit_web_history_item_new_with_data("http://example.com/", "Example1"); |
|
34 g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, == , 1); |
|
35 g_assert(fixture->item != NULL); |
|
36 } |
|
37 |
|
38 static void web_history_item_fixture_teardown(WebHistoryItemFixture* fixture, |
|
39 gconstpointer data) |
|
40 { |
|
41 g_assert(fixture->item != NULL); |
|
42 g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, ==, 1); |
|
43 } |
|
44 |
|
45 static void test_webkit_web_history_item_get_data(WebHistoryItemFixture* fixture, |
|
46 gconstpointer data) |
|
47 { |
|
48 g_assert_cmpstr(webkit_web_history_item_get_title(fixture->item), ==, "Example1"); |
|
49 g_assert_cmpstr(webkit_web_history_item_get_uri(fixture->item), ==, "http://example.com/"); |
|
50 } |
|
51 |
|
52 static void test_webkit_web_history_item_alternate_title(WebHistoryItemFixture* fixture, |
|
53 gconstpointer data) |
|
54 { |
|
55 webkit_web_history_item_set_alternate_title(fixture->item, "Alternate title"); |
|
56 g_assert_cmpstr(webkit_web_history_item_get_alternate_title(fixture->item), ==, "Alternate title"); |
|
57 } |
|
58 |
|
59 int main(int argc, char** argv) |
|
60 { |
|
61 g_thread_init(NULL); |
|
62 gtk_test_init(&argc, &argv, NULL); |
|
63 |
|
64 g_test_bug_base("https://bugs.webkit.org/"); |
|
65 g_test_add("/webkit/webhistoryitem/get_data", |
|
66 WebHistoryItemFixture, 0, web_history_item_fixture_setup, |
|
67 test_webkit_web_history_item_get_data, web_history_item_fixture_teardown); |
|
68 g_test_add("/webkit/webhistoryitem/alternate_title", |
|
69 WebHistoryItemFixture, 0, web_history_item_fixture_setup, |
|
70 test_webkit_web_history_item_alternate_title, web_history_item_fixture_teardown); |
|
71 return g_test_run (); |
|
72 } |
|
73 |
|
74 #else |
|
75 int main(int argc, char** argv) |
|
76 { |
|
77 g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now."); |
|
78 return 0; |
|
79 } |
|
80 |
|
81 #endif |