Autotest: Update textedit test using textFormat
authorCaroline Chao <caroline.chao@digia.com>
Mon, 27 May 2013 06:17:59 +0000 (08:17 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 8 Jun 2013 05:36:03 +0000 (07:36 +0200)
TextEdit does not support the StyledText format, Text does.

Add an autotest to Text to check the line counts using
different text formats.

Task-number: QTBUG-31191

Change-Id: I4670f9155bea295ba85f410988d9636eac12842c
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Reviewed-by: Liang Qi <liang.qi@digia.com>
tests/auto/qmltest/text/tst_text.qml
tests/auto/qmltest/textedit/tst_textedit.qml

index 87e9501..b1d743f 100644 (file)
@@ -78,6 +78,13 @@ Item {
         font.pixelSize: 18
     }
 
+    Text {
+        id: txtlines
+        property string styledtextvalue: "Line 1<br>Line 2<br>Line 3"
+        text: "Line 1\nLine 2\nLine 3"
+        textFormat: Text.PlainText
+    }
+
     TestCase {
         name: "Text"
 
@@ -116,6 +123,16 @@ Item {
             txtlinecount.width = 50;
             compare(txtlinecount.lineCount, 3)
         }
+        function test_linecounts() {
+            compare(txtlines.lineCount, 3)
+            txtlines.text = txtlines.styledtextvalue;
+            compare(txtlines.text, "Line 1<br>Line 2<br>Line 3")
+            tryCompare(txtlines, 'lineCount', 1)
+            txtlines.textFormat = Text.StyledText;
+            tryCompare(txtlines, 'lineCount', 3)
+            txtlines.textFormat = Text.RichText;
+            tryCompare(txtlines, 'lineCount', 3)
+        }
 
     }
 }
index 6e51242..eb53eaa 100644 (file)
@@ -91,7 +91,7 @@ Item {
         id: txtlines
         property string styledtextvalue: "Line 1<br>Line 2<br>Line 3"
         text: "Line 1\nLine 2\nLine 3"
-        textFormat: Text.PlainText
+        textFormat: TextEdit.PlainText
     }
 
     TestCase {
@@ -180,10 +180,7 @@ Item {
             txtlines.text = txtlines.styledtextvalue;
             compare(txtlines.text, "Line 1<br>Line 2<br>Line 3")
             tryCompare(txtlines, 'lineCount', 1)
-            txtlines.textFormat = Text.StyledText;
-            expectFail("", "QTBUG-31191")
-            tryCompare(txtlines, 'lineCount', 3)
-            txtlines.textFormat = Text.RichText;
+            txtlines.textFormat = TextEdit.RichText;
             tryCompare(txtlines, 'lineCount', 3)
         }
     }