summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kerekes <jan.kerekes@ixonos.com>2012-05-07 10:58:35 +0200
committerChristian Stenger <christian.stenger@nokia.com>2012-05-15 13:18:53 +0200
commitac430542ae24bfe5d19cdff0a0d44e6f8406527e (patch)
tree8944b3c29ab1131a197c32e8223ef7675d323bb9
parent49a3f0129a92ea321d93e139b787f7bedfb983be (diff)
downloadqt-creator-ac430542ae24bfe5d19cdff0a0d44e6f8406527e.tar.gz
Added new test cases (QMLS06, QMLS07, QMLS08) to QMLS suite
initial commit Change-Id: I3be474d8def1161e60421030a799e297e21fc4fe Reviewed-by: Robert Löhning <robert.loehning@nokia.com> Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
-rw-r--r--tests/system/suite_QMLS/suite.conf2
-rw-r--r--tests/system/suite_QMLS/tst_QMLS06/test.py41
-rw-r--r--tests/system/suite_QMLS/tst_QMLS07/test.py25
-rw-r--r--tests/system/suite_QMLS/tst_QMLS08/test.py60
4 files changed, 127 insertions, 1 deletions
diff --git a/tests/system/suite_QMLS/suite.conf b/tests/system/suite_QMLS/suite.conf
index 73de021e6d..321ab6db4b 100644
--- a/tests/system/suite_QMLS/suite.conf
+++ b/tests/system/suite_QMLS/suite.conf
@@ -5,6 +5,6 @@ ENVVARS=envvars
HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
-TEST_CASES=tst_QMLS01 tst_QMLS02 tst_QMLS03 tst_QMLS04 tst_QMLS05
+TEST_CASES=tst_QMLS01 tst_QMLS02 tst_QMLS03 tst_QMLS04 tst_QMLS05 tst_QMLS06 tst_QMLS07 tst_QMLS08
VERSION=2
WRAPPERS=Qt
diff --git a/tests/system/suite_QMLS/tst_QMLS06/test.py b/tests/system/suite_QMLS/tst_QMLS06/test.py
new file mode 100644
index 0000000000..61cc916519
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS06/test.py
@@ -0,0 +1,41 @@
+source("../shared/qmls.py")
+
+def main():
+ editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "}")
+ if not editorArea:
+ return
+ type(editorArea, "<Return>")
+ testingItemText = "Item { x: 10; y: 20; width: 10 }"
+ type(editorArea, testingItemText)
+ for i in range(30):
+ type(editorArea, "<Left>")
+ invokeMenuItem("File", "Save All")
+ # invoke Refactoring - Wrap Component in Loader
+ numLinesExpected = len(str(editorArea.plainText).splitlines()) + 10
+ ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Wrap Component in Loader"))
+ # wait until refactoring ended
+ waitFor("len(str(editorArea.plainText).splitlines()) >= numLinesExpected", 5000)
+ # verify if refactoring was properly applied
+ verifyMessage = "Verifying wrap component in loader functionality at element line."
+ type(editorArea, "<Up>")
+ type(editorArea, "<Up>")
+ verifyCurrentLine(editorArea, "Component {", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "id: component_Item", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, testingItemText, verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "}", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "Loader {", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "id: loader_Item", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "sourceComponent: component_Item", verifyMessage)
+ type(editorArea, "<Down>")
+ verifyCurrentLine(editorArea, "}", verifyMessage)
+ # save and exit
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
diff --git a/tests/system/suite_QMLS/tst_QMLS07/test.py b/tests/system/suite_QMLS/tst_QMLS07/test.py
new file mode 100644
index 0000000000..ff149e4929
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS07/test.py
@@ -0,0 +1,25 @@
+source("../shared/qmls.py")
+
+def main():
+ editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp", "Rectangle {")
+ if not editorArea:
+ return
+ type(editorArea, "<Return>")
+ type(editorArea, "Color")
+ for i in range(3):
+ type(editorArea, "<Left>")
+ invokeMenuItem("File", "Save All")
+ # invoke Refactoring - Add a message suppression comment.
+ numLinesExpected = len(str(editorArea.plainText).splitlines()) + 1
+ ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Refactoring"))
+ activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), "Add a comment to suppress this message"))
+ # wait until refactoring ended
+ waitFor("len(str(editorArea.plainText).splitlines()) >= numLinesExpected", 5000)
+ # verify if refactoring was properly applied
+ type(editorArea, "<Up>")
+ test.compare(str(lineUnderCursor(editorArea)).strip(), "// @disable-check M16",
+ "Verifying 'Add comment to suppress message' refactoring")
+ # save and exit
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
diff --git a/tests/system/suite_QMLS/tst_QMLS08/test.py b/tests/system/suite_QMLS/tst_QMLS08/test.py
new file mode 100644
index 0000000000..a505f0fd0f
--- /dev/null
+++ b/tests/system/suite_QMLS/tst_QMLS08/test.py
@@ -0,0 +1,60 @@
+source("../shared/qmls.py")
+
+def verifyNextLineIndented(editorArea, expectedIndentation):
+ type(editorArea, "<Down>")
+ rawLine = str(lineUnderCursor(editorArea))
+ indentedLine = rawLine.rstrip()
+ # handle special case if line has only whitespaces inside
+ if not indentedLine:
+ indentedLine = rawLine
+ unindentedLine = indentedLine.lstrip()
+ numSpaces = len(indentedLine) - len(unindentedLine)
+ # verify if indentation is valid (multiply of 4) and if has correct depth level
+ test.compare(numSpaces % 4, 0, "Verifying indentation spaces")
+ test.compare(numSpaces / 4, expectedIndentation, "Verifying indentation level")
+
+def verifyIndentation(editorArea):
+ #verify indentation
+ if not placeCursorToLine(editorArea, "id: rect"):
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")
+ return False
+ type(editorArea, "<Up>")
+ expectedIndentations = [1,1,1,2,2,2,2,3,3,3,4,3,3,2,1]
+ for indentation in expectedIndentations:
+ verifyNextLineIndented(editorArea, indentation)
+ return True
+
+def main():
+ editorArea = startQtCreatorWithNewAppAtQMLEditor(tempDir(), "SampleApp")
+ if not editorArea:
+ return
+ # prepare code for test - insert unindented code
+ lines = ['id: rect', 'property bool random: true', 'Text{',
+ 'anchors.bottom:parent.bottom', 'text: rect.random ? getRandom() : "I\'m fixed."',
+ '', 'function getRandom(){', 'var result="I\'m random: ";',
+ 'var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";',
+ 'for(var i=0;i<8;++i)', 'result += chars.charAt(Math.floor(Math.random() * chars.length));',
+ 'return result + ".";']
+ if not placeCursorToLine(editorArea, "Rectangle {"):
+ invokeMenuItem("File", "Exit")
+ return
+ type(editorArea, "<Return>")
+ typeLines(editorArea, lines)
+ # verify default indentation
+ if not verifyIndentation(editorArea):
+ return
+ # cancel indentation
+ type(editorArea, "<Ctrl+A>")
+ for i in range(5):
+ type(editorArea, "<Shift+Backtab>")
+ # select unindented block
+ type(editorArea, "<Ctrl+A>")
+ # do indentation
+ type(editorArea, "<Ctrl+I>")
+ # verify invoked indentation
+ if not verifyIndentation(editorArea):
+ return
+ # save and exit
+ invokeMenuItem("File", "Save All")
+ invokeMenuItem("File", "Exit")