diff options
Diffstat (limited to 'tests/qtuitest/sys_linguist/sys_linguist.qtt')
-rw-r--r-- | tests/qtuitest/sys_linguist/sys_linguist.qtt | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/tests/qtuitest/sys_linguist/sys_linguist.qtt b/tests/qtuitest/sys_linguist/sys_linguist.qtt new file mode 100644 index 0000000..a098cc5 --- /dev/null +++ b/tests/qtuitest/sys_linguist/sys_linguist.qtt @@ -0,0 +1,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]); + } + +} |