summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKitGtk/testwebhistoryitem.c
blob: 82e191c208c753980deb5bb9e6075cfb64c1ab9d (plain)
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
/*
 * Copyright (C) 2009 Jan Michael Alonzo
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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 "config.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <webkit/webkit.h>

typedef struct {
    WebKitWebHistoryItem* item;
} WebHistoryItemFixture;

static void web_history_item_fixture_setup(WebHistoryItemFixture* fixture,
                                           gconstpointer data)
{
    fixture->item = webkit_web_history_item_new_with_data("http://example.com/", "Example1");
    g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, == , 1);
    g_assert(fixture->item != NULL);
}

static void web_history_item_fixture_teardown(WebHistoryItemFixture* fixture,
                                              gconstpointer data)
{
    g_assert(fixture->item != NULL);
    g_assert_cmpint(G_OBJECT(fixture->item)->ref_count, ==, 1);
}

static void test_webkit_web_history_item_get_data(WebHistoryItemFixture* fixture,
                                                  gconstpointer data)
{
    g_assert_cmpstr(webkit_web_history_item_get_title(fixture->item), ==, "Example1");
    g_assert_cmpstr(webkit_web_history_item_get_uri(fixture->item), ==, "http://example.com/");
}

static void test_webkit_web_history_item_alternate_title(WebHistoryItemFixture* fixture,
                                                         gconstpointer data)
{
    webkit_web_history_item_set_alternate_title(fixture->item, "Alternate title");
    g_assert_cmpstr(webkit_web_history_item_get_alternate_title(fixture->item), ==, "Alternate title");
}

int main(int argc, char** argv)
{
    gtk_test_init(&argc, &argv, NULL);

    g_test_bug_base("https://bugs.webkit.org/");
    g_test_add("/webkit/webhistoryitem/get_data",
               WebHistoryItemFixture, 0, web_history_item_fixture_setup,
               test_webkit_web_history_item_get_data, web_history_item_fixture_teardown);
    g_test_add("/webkit/webhistoryitem/alternate_title",
               WebHistoryItemFixture, 0, web_history_item_fixture_setup,
               test_webkit_web_history_item_alternate_title, web_history_item_fixture_teardown);
    return g_test_run ();
}