diff options
author | Damian Jansen <damian.jansen@nokia.com> | 2011-03-03 15:42:36 +1000 |
---|---|---|
committer | Damian Jansen <damian.jansen@nokia.com> | 2011-03-03 15:42:36 +1000 |
commit | cf0f3ca828527d3f4f91808e7bab3a9b1c94ce9c (patch) | |
tree | f253127e505d71fd724dc3cb8ceef81e1a71d189 | |
parent | c2c36ff85b07923a04ff77af38a4cb12322ac1ca (diff) |
Add right to left tests
-rw-r--r-- | Qt/examples/declarative/declarative.pro | 2 | ||||
-rw-r--r-- | Qt/examples/declarative/rtl/rtl.pro | 2 | ||||
-rw-r--r-- | Qt/examples/declarative/rtl/rtltext.qml | 263 | ||||
-rw-r--r-- | Qt/examples/declarative/rtl/sys_rtl/sys_rtl.pro | 2 | ||||
-rw-r--r-- | Qt/examples/declarative/rtl/sys_rtl/sys_rtl.qtt | 93 |
5 files changed, 361 insertions, 1 deletions
diff --git a/Qt/examples/declarative/declarative.pro b/Qt/examples/declarative/declarative.pro index 466f620..b264bdc 100644 --- a/Qt/examples/declarative/declarative.pro +++ b/Qt/examples/declarative/declarative.pro @@ -1,2 +1,2 @@ TEMPLATE=subdirs -SUBDIRS+=dial parallax pincharea textinput textedit +SUBDIRS+=dial parallax pincharea textinput textedit rtl diff --git a/Qt/examples/declarative/rtl/rtl.pro b/Qt/examples/declarative/rtl/rtl.pro new file mode 100644 index 0000000..c0fbba7 --- /dev/null +++ b/Qt/examples/declarative/rtl/rtl.pro @@ -0,0 +1,2 @@ +TEMPLATE=subdirs +SUBDIRS+=sys_rtl diff --git a/Qt/examples/declarative/rtl/rtltext.qml b/Qt/examples/declarative/rtl/rtltext.qml new file mode 100644 index 0000000..c517671 --- /dev/null +++ b/Qt/examples/declarative/rtl/rtltext.qml @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +import QtQuick 1.1 + +Flickable { + height: 640; width: 360; contentHeight: root.height; contentWidth: 360; boundsBehavior: Flickable.StopAtBounds + Rectangle { + id: root + width: 240; height: containerColumn.height+containerColumn.anchors.topMargin; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + property variant text: ["", " ", "Hello world!", "مرحبا العالم"] + property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text"] + property variant editorType: ["Text", "TextInput", "TextEdit"] + property variant horizontalAlignment: undefined + Column { + id: containerColumn + spacing: 10 + width: parent.width + anchors.top: parent.top + anchors.topMargin: 5 + Column { + id: editorTypeColumn + spacing: 5 + width: parent.width + Repeater { + model: root.resources.length-1 + Item { + width: yetAnotherColumn.width + height: yetAnotherColumn.height + anchors.horizontalCenter: parent.horizontalCenter + Column { + id: yetAnotherColumn + width: textColumn.width+20 + spacing: 5 + Text { + text: root.editorType[index] + font.pixelSize: 20 + anchors.horizontalCenter: parent.horizontalCenter + } + Column { + id: textColumn + spacing: 10 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: root.text.length + delegate: root.resources[index+1] + } + } + } + } + } + } + Text { + text: "Default application\ndirection is " + (Qt.application.layoutDirection == Qt.RightToLeft ? "Right-to-left" : "Left-to-right") + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 15 + anchors.horizontalCenter: parent.horizontalCenter + } + Rectangle { + id: button + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Text { + text: { + if (root.horizontalAlignment == undefined) + return "Implict alignment"; + switch (root.horizontalAlignment) { + case Text.AlignLeft: + return "Left alignment"; + case Text.AlignRight: + return "Right alignment"; + case Text.AlignHCenter: + return "Center alignment"; + case Text.AlignJustify: + return "Justify alignment"; + } + } + color: "white" + font.pixelSize: 16 + anchors.centerIn: parent + } + MouseArea { + id: mouseArea + property int index: 0 + onClicked: { + if (index < 0) { + root.horizontalAlignment = undefined; + } else { + root.horizontalAlignment = Math.pow(2, index); + } + index = (index + 2) % 5 - 1; + } + anchors.fill: parent + } + } + } + Component { + id: textComponent + Text { + width: 200 + text: root.text[index] + font.pixelSize: 30 + horizontalAlignment: root.horizontalAlignment + Rectangle { + z: -1 + anchors.fill: parent + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + anchors { fill: parent; margins: -3 } + color: Qt.rgba(0.3, 0, 0, 0.3) + } + } + Text { + color: "white" + text: { + if (parent.horizontalAlignment == undefined) + return "I"; + switch (parent.horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + } + } + anchors{ top: parent.top; right: parent.right; margins: 2 } + } + } + } + Component { + id: textInputComponent + TextInput { + width: 200 + text: root.text[index] + font.pixelSize: 30 + horizontalAlignment: root.horizontalAlignment + Rectangle { + z: -1 + anchors.fill: parent + color: Qt.rgba(0.6, 0.4, 0.2, 0.3) + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + anchors { fill: parent; margins: -3 } + color: Qt.rgba(0.3, 0, 0, 0.3) + } + } + Text { + color: "white" + text: { + if (parent.horizontalAlignment == undefined) + return "I"; + switch (parent.horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + } + } + anchors{ top: parent.top; right: parent.right; margins: 2 } + } + } + } + Component { + id: textEditComponent + TextEdit { + width: 200 + text: root.text[index] + font.pixelSize: 30 + horizontalAlignment: root.horizontalAlignment + Rectangle { + z: -1 + anchors.fill: parent + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + anchors { fill: parent; margins: -3 } + color: Qt.rgba(0.3, 0, 0, 0.3) + } + } + Text { + color: "white" + text: { + if (parent.horizontalAlignment == undefined) + return "I"; + switch (parent.horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + } + } + anchors{ top: parent.top; right: parent.right; margins: 2 } + } + } + } + } +}
\ No newline at end of file diff --git a/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.pro b/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.pro new file mode 100644 index 0000000..1837d72 --- /dev/null +++ b/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.pro @@ -0,0 +1,2 @@ +CONFIG+=systemtest +SOURCES=sys_rtl.qtt diff --git a/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.qtt b/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.qtt new file mode 100644 index 0000000..e33faa7 --- /dev/null +++ b/Qt/examples/declarative/rtl/sys_rtl/sys_rtl.qtt @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + + +testcase = { + + implicit_text_alignment: function() + { + prompt(twiki('---++ Implicit Text alignment + +| *Step* | *Verification* | +| Execute systemtests/Qt/examples/declarative/rtl/rtltext.qml | Verify that the indicator at the bottom shows Implicit alignment | +| Observe the three different element types - Text, TextInput, TextEdit | Verify that for each case where the text box shows right-to-left text, the text is aligned to the right | +| (Skip this on devices with no Home/End key) In the right-to-left TextInput, press Home, then End | Verify the cursor moves fully to the right, and fully to the left respectively | +| In the TextEdit field, copy some of the Arabic text | | +| At the leftmost position of the text, press Enter | Verify the text cursor moves the right on the next line | +| Paste the copied text | The text is pasted into the box, also right aligned |')); + }, + + left_center_and_right_text_alignment_data: + { + left: ["Left", "left"], + center: ["Center", "center"], + right: ["Right", "right"] + }, + + left_center_and_right_text_alignment: function(name,alignment) + { + prompt(twiki('---++ '+name+' Text alignment + +| *Step* | *Verification* | +| Execute systemtests/Qt/examples/declarative/rtl/rtltext.qml | Verify that the indicator at the bottom shows Left alignment | +| Press the indicator until '+name+' alignment shows | Verify that the indicator at the bottom shows '+name+' alignment | +| Observe the three different element types - Text, TextInput, TextEdit | Verify that for each case where the text box shows right-to-left text, the text is aligned to the '+alignment+' | +| (Skip this on devices with no Home/End key) In the right-to-left TextInput, press Home, then End | Verify the cursor moves fully to the right of the text only, and then fully to the left side respectively | +| In the TextEdit field, copy some of the Arabic text | | +| At the leftmost position of the text, press Enter | Verify the text cursor moves the '+alignment+' on the next line | +| Paste the copied text | The text is pasted into the box, also '+alignment+' aligned |')); + }, + + justified_text_alignment: function() + { + prompt(twiki('---++ Justified Text alignment +Note that this only applies to Text and TextEdit. AlignJustify is not available for TextInput +| *Step* | *Verification* | +| Execute systemtests/Qt/examples/declarative/rtl/rtltext.qml | Verify that the indicator at the bottom shows Implicit alignment | +| Press the indicator until Justify alignment shows | Verify that the indicator at the bottom shows Justify alignment | +| Observe two of the three different element types - Text, TextEdit | Verify that for each case where the text box shows right-to-left text, the text is aligned to the right | +| (Skip this on devices with no Home/End key) In the right-to-left TextInput, press Home, then End | Verify the cursor moves fully to the right, and fully to the left respectively | +| In the TextEdit field, copy some of the Arabic text | | +| At the leftmost position of the text, press Enter | Verify the text cursor moves the right on the next line | +| Paste the copied text | The text is pasted into the box, also right aligned |')); + } + +} |