~midori/midori/trunk

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
/*
 Copyright (C) 2012 Christian Dywan <christian@twotoasts.de>

 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.

 See the file COPYING for the full license text.
*/

/*
struct FormSpec {
    public string html;
    public Pango.EllipsizeMode ellipsize;
    public string? uri;
    public string? title;
}

const FormSpec[] forms = {
    { "<form></form>", Pango.EllipsizeMode.END, null, null },
    { "<form><input></form>", Pango.EllipsizeMode.END, null, null }
};
*/

void searchaction_form () {
    /*
    foreach (var form in forms) {
        var view = new Midori.View.with_title ();
        view.get_web_view ().load_html_string (form.html, "");
        Katze.Item? result = Midori.SearchAction.get_engine_for_form (
            view.get_web_view (), form.ellipsize);
        Katze.assert_str_equal (form.html,
            result != null ? result.uri : null, form.uri);
        Katze.assert_str_equal (form.html,
            result != null ? result.name : null, form.title);
    }
    */
}

struct TokenSpec {
    public string uri;
    public string expected_token;
}

const TokenSpec[] tokens = {
    { "https://bugs.launchpad.net/midori/+bugs", "lnch" },
    { "https://duckduckgo.com/search", "dckd" },
    { "http://en.wikipedia.org/w/index.php?title=Special:Search&profile=default&search=%s&fulltext=Search&", "wkpd" },
    { "about:blank", "" },
    { "", "" },
    { "file:///", "" },
    { "file:///form.html", "" }
};

void searchaction_token () {
    foreach(var token in tokens)
    {
        Katze.assert_str_equal (token.uri,
            Midori.SearchAction.token_for_uri(token.uri), token.expected_token);
    }
}

void main (string[] args) {
    Test.init (ref args);
    Midori.App.setup (ref args, null);
    Test.add_func ("/searchaction/form", searchaction_form);
    Test.add_func ("/searchaction/token", searchaction_token);
    Test.run ();
}