~mhr3/unity8/fix-1297246

« back to all changes in this revision

Viewing changes to tests/qmltests/Hud/tst_Result.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import QtTest 1.0
 
19
import ".."
 
20
import "../../../Hud"
 
21
import Unity.Test 0.1 as UT
 
22
 
 
23
Rectangle {
 
24
    width: 600
 
25
    height: 600
 
26
    color: "black"
 
27
    Column {
 
28
        anchors.fill: parent
 
29
        Repeater {
 
30
            model: test.test_highlightedText_data().length
 
31
            Result {
 
32
                width: parent.width
 
33
                height: units.gu(4)
 
34
                nameText: test.test_highlightedText_data()[index].text
 
35
                nameHighlights: test.test_highlightedText_data()[index].highlights
 
36
            }
 
37
        }
 
38
    }
 
39
 
 
40
    UT.UnityTestCase {
 
41
        name: "Result"
 
42
        id: test
 
43
 
 
44
        Result {
 
45
            id: result
 
46
        }
 
47
 
 
48
        function test_highlightedText_data() {
 
49
            return [
 
50
                    {
 
51
                     text: "Copy",
 
52
                     highlights: [],
 
53
                     result: "Copy"
 
54
                    },
 
55
                    {
 
56
                     text: "Copy",
 
57
                     highlights: [0, 0],
 
58
                     result: "<font color=\"#ffffff\">C</font>opy"
 
59
                    },
 
60
                    {
 
61
                     text: "Copy",
 
62
                     highlights: [1, 1],
 
63
                     result: "C<font color=\"#ffffff\">o</font>py"
 
64
                    },
 
65
                    {
 
66
                     text: "Pastel",
 
67
                     highlights: [1, 1, 3, 4],
 
68
                     result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l"
 
69
                    },
 
70
                    {
 
71
                     text: "Pastel",
 
72
                     highlights: [1, 1, 3, 5],
 
73
                     result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>"
 
74
                    },
 
75
                    {
 
76
                     text: "Pastel",
 
77
                     highlights: [0, 0, 3, 5],
 
78
                     result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>"
 
79
                    },
 
80
                    {
 
81
                     text: "Pastel",
 
82
                     highlights: [5, 5],
 
83
                     result: "Paste<font color=\"#ffffff\">l</font>"
 
84
                    },
 
85
                    {
 
86
                     text: "Two Words",
 
87
                     highlights: [1, 2, 5, 5],
 
88
                     result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds"
 
89
                    }
 
90
                ]
 
91
        }
 
92
 
 
93
        function test_highlightedText(data) {
 
94
            var hText = result.highlightedText(data.text, data.highlights);
 
95
            compare(hText, data.result);
 
96
        }
 
97
    }
 
98
}