~phablet-team/webbrowser-app/15.04

« back to all changes in this revision

Viewing changes to tests/unittests/qml/tst_UserAgent01.qml

  • Committer: CI Train Bot
  • Author(s): Alexandre Abreu
  • Date: 2015-04-10 13:33:10 UTC
  • mfrom: (955.3.2 remove-qtwebkit)
  • Revision ID: ci-train-bot@canonical.com-20150410133310-x2mbbmfuml090wqh
remove qtwebkit deps (LP: #1362640) Fixes: #1362640
Approved by: Timo Jyrinki, PS Jenkins bot, Olivier Tilloy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
4
 
 * This file is part of webbrowser-app.
5
 
 *
6
 
 * webbrowser-app is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; version 3.
9
 
 *
10
 
 * webbrowser-app is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
import QtQuick 2.0
20
 
import QtTest 1.0
21
 
 
22
 
TestCase {
23
 
    name: "UserAgent"
24
 
 
25
 
    function test_get_domain_data() {
26
 
        return [
27
 
            {url: "http://ubuntu.com", domain: "ubuntu.com"},
28
 
            {url: "http://www.ubuntu.com", domain: "www.ubuntu.com"},
29
 
            {url: "http://ubuntu.com/", domain: "ubuntu.com"},
30
 
            {url: "http://www.ubuntu.com/", domain: "www.ubuntu.com"},
31
 
            {url: "ubuntu.com", domain: "ubuntu.com"},
32
 
            {url: "ubuntu.com/", domain: "ubuntu.com"},
33
 
            {url: "ubuntu.com/phone", domain: "ubuntu.com"},
34
 
            {url: "http://ubuntu.com/phone", domain: "ubuntu.com"},
35
 
            {url: "www.ubuntu.com/phone", domain: "www.ubuntu.com"},
36
 
            {url: "http://ubuntu.com/phone/index.html", domain: "ubuntu.com"},
37
 
            {url: "ubuntu.com/phone/index.html", domain: "ubuntu.com"},
38
 
            {url: "www.ubuntu.com/phone/index.html", domain: "www.ubuntu.com"},
39
 
            {url: "http://ubuntu.com/phone/index.html?foo=bar&baz=bleh", domain: "ubuntu.com"},
40
 
        ]
41
 
    }
42
 
    function test_get_domain(data) {
43
 
        compare(userAgent.getDomain(data.url), data.domain)
44
 
    }
45
 
 
46
 
    function test_get_domains_data() {
47
 
        return [
48
 
            {domain: "ubuntu.com", domains: ["ubuntu.com", "com"]},
49
 
            {domain: "test.example.org", domains: ["test.example.org", "example.org", "org"]},
50
 
        ]
51
 
    }
52
 
    function test_get_domains(data) {
53
 
        compare(userAgent.getDomains(data.domain), data.domains)
54
 
    }
55
 
 
56
 
    function test_get_ua_string_data() {
57
 
        return [
58
 
            {url: "http://ubuntu.com", ua: userAgent.defaultUA},
59
 
            {url: "http://example.org", ua: "full override"},
60
 
            {url: "http://example.com/test", ua: "Mozilla/5.0 (Ubuntu Edge; Mobile) WebKit/537.21"},
61
 
            {url: "http://www.google.com/", ua: "Mozilla/5.0 (Ubuntu; ble) WebKit/537.21"},
62
 
            {url: "https://mail.google.com/", ua: "Mozilla/5.0 (Ubuntu; Touch) WebKit/537.21"},
63
 
        ]
64
 
    }
65
 
    function test_get_ua_string(data) {
66
 
        compare(userAgent.getUAString(data.url), data.ua)
67
 
    }
68
 
 
69
 
    readonly property Item userAgent: loader.item
70
 
    Loader {
71
 
        id: loader
72
 
        source: Qt.resolvedUrl("../../../src/Ubuntu/Components/Extras/Browser/UserAgent01.qml")
73
 
        onLoaded : {
74
 
            item.defaultUA = "Mozilla/5.0 (Ubuntu; Mobile) WebKit/537.21"
75
 
            item.overrides = {
76
 
                "example.org": "full override",
77
 
                "example.com": ["Ubuntu", "Ubuntu Edge"],
78
 
                "google.com": [/mobi/i, "b"],
79
 
                "mail.google.com": [/mobile/i, "Touch"],
80
 
            }
81
 
        }
82
 
    }
83
 
}