summaryrefslogtreecommitdiffstats
path: root/tests/qtuitest/sys_linguist/sys_linguist.qtt
blob: a098cc5454c6db02402f3483725807c5ad16cdc5 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of QtUiTest.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/



include("filedialog.qtt");

testcase = {

    //TODO: In Progress. Not expected to pass (or even work correctly) yet.

    init: function() {
        // Start the application
        startApplication("linguist");

        // Open file
        select("File/Open...", menuBar());
        FileDialog.openFile(baseDataPath() + "test_fr.ts");

        // Make sure all views are shown
        setChecked(true, "View/Views/Context", menuBar());
        setChecked(true, "View/Views/Strings", menuBar());
        setChecked(true, "View/Views/Phrases and guesses", menuBar());
        setChecked(true, "View/Views/Sources and Forms", menuBar());
        setChecked(true, "View/Views/Warnings", menuBar());

        // Switch on all validation
        setChecked(true, "Validation/Accelerators", menuBar());
        setChecked(true, "Validation/Ending Punctuation", menuBar());
        setChecked(true, "Validation/Phrase matches", menuBar());
        setChecked(true, "Validation/Place Marker Matches", menuBar());

        // Switch off Length Variants
        setChecked(false, "View/Length Variants", menuBar());

        // Labels are above their buddy widgets
        setLabelOrientation(LabelAbove);
    },

    check_translation_data: {
        blue:  [ "Colours",  "blue",  "bleu"      ],
        third: [ "Ordinals", "third", "troisième" ],
        nine:  [ "Numbers",  "nine",  "neuf"      ]
    },

    check_translation: function(context, sourceText, translated) {
        select( context, "Context" );
        select( sourceText, "Strings" );
        compare(getText("Source text"), sourceText);
        compare(getText("French translation"), translated);
    },

    check_warnings_data: {
        warn1: [ "Placemarkers", "Read error reading from %1: %2",
                 "Translation does not refer to the same place markers as in the source text." ],
        warn2: [ "Accelerators", "&hello world", "Accelerator possibly missing in translation." ]
    },

    check_warnings: function(context, sourceText, warning) {
        select( context, "Context" );
        select( sourceText, "Strings" );
        compare(getText("Source text"), sourceText);
        verify(getList("Warnings").contains(warning));
    },

    missing_translations: function() {
        select( "Translation/Next Unfinished" );
        var list = new Array();
        var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
        var first = val;

        do {
            list.push(val);
            select( "Translation/Next Unfinished" );
            var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
        } while (val != first);

        verify(list.contains("Numbers : four"));
        verify(list.contains("Ordinals : sixth"));
        verify(list.contains("Colours : a mauvy shade of pinky russet"));
    },

    check_statistics: function() {
        //TODO: Should also check word count, however this is not easy to do
        //      in JavaScript for Unicode strings.

        var sourceChars = 0;
        var translatedChars = 0;
        var sourceNonSpaceChars = 0;
        var translatedNonSpaceChars = 0;
        var first = getSelectedValue("Context")[1] + " : " + getText("Source text");

        do {
            var sourceText = getText("Source text");
            var translatedText = getText("French translation");
            sourceChars += sourceText.length;
            translatedChars += translatedText.length;

            sourceNonSpaceChars += sourceText.replace(/\s/g, "").length;
            translatedNonSpaceChars += translatedText.replace(/\s/g, "").length;
            select( "Translation/Next" );
            var val = getSelectedValue("Context")[1] + " : " + getText("Source text");
        } while (val != first);

        select("View/Statistics", menuBar());
        var labels = getLabels();

        compare(sourceNonSpaceChars, labels[labels.indexOf("Characters:")+1]);
        compare(translatedNonSpaceChars, labels[labels.indexOf("Characters:")+2]);
        compare(sourceChars, labels[labels.indexOf("Characters (with spaces):")+1]);
        compare(translatedChars, labels[labels.indexOf("Characters (with spaces):")+2]);
    }

}