summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@nokia.com>2012-02-10 14:11:49 +0100
committerRobert Löhning <robert.loehning@nokia.com>2012-02-10 16:47:35 +0100
commit43b1ad3661f85869af6dc00a21b129893abbc4c5 (patch)
tree2b8a68e1126fcfd22181ffaa33118920f0042a7a
parent3aa2b0876caa79cf7461d6af0aa7f8330318fb21 (diff)
downloadqt-creator-43b1ad3661f85869af6dc00a21b129893abbc4c5.tar.gz
Squish: Added test for (un-)selecting all content of editors
Change-Id: Id0d768895f74e3686f15817b520552524493e79d Reviewed-by: Christian Stenger <christian.stenger@nokia.com>
-rw-r--r--tests/system/suite_general/suite.conf2
-rw-r--r--tests/system/suite_general/tst_select_all/test.py49
2 files changed, 50 insertions, 1 deletions
diff --git a/tests/system/suite_general/suite.conf b/tests/system/suite_general/suite.conf
index 8ab1ea1dc7..b114c5f47d 100644
--- a/tests/system/suite_general/suite.conf
+++ b/tests/system/suite_general/suite.conf
@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAP=../objects.map
-TEST_CASES=tst_openqt_creator tst_build_speedcrunch tst_cmake_speedcrunch tst_basic_cpp_support
+TEST_CASES=tst_openqt_creator tst_build_speedcrunch tst_cmake_speedcrunch tst_basic_cpp_support tst_select_all
VERSION=2
WRAPPERS=Qt
diff --git a/tests/system/suite_general/tst_select_all/test.py b/tests/system/suite_general/tst_select_all/test.py
new file mode 100644
index 0000000000..fa9d9c2509
--- /dev/null
+++ b/tests/system/suite_general/tst_select_all/test.py
@@ -0,0 +1,49 @@
+source("../../shared/qtcreator.py")
+
+# This tests for QTCREATORBUG-5757
+
+# Results can differ from actual size on disk (different line endings on Windows)
+def charactersInFile(filename):
+ f = open(filename,"r")
+ content = f.read()
+ f.close()
+ return len(content)
+
+def main():
+ filesAndEditors = {srcPath + "/creator/README" : "TextEditor::PlainTextEditorWidget",
+ srcPath + "/creator/qtcreator.pri" : "Qt4ProjectManager::Internal::ProFileEditorWidget",
+ srcPath + "/creator/doc/snippets/qml/list-of-transitions.qml" : "QmlJSEditor::QmlJSTextEditorWidget"}
+ for currentFile in filesAndEditors:
+ if not neededFilePresent(currentFile):
+ return
+
+ startApplication("qtcreator" + SettingsPath)
+ for currentFile in filesAndEditors:
+ test.log("Opening file %s" % currentFile)
+ size = charactersInFile(currentFile)
+ invokeMenuItem("File", "Open File or Project...")
+ selectFromFileDialog(currentFile)
+ editor = waitForObject("{type='%s' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}"
+ % filesAndEditors[currentFile], 20000)
+ # needed on Mac because of QTCREATORBUG-6918
+ nativeMouseClick(editor.mapToGlobal(QPoint(50, 50)).x, editor.mapToGlobal(QPoint(50, 50)).y, Qt.LeftButton)
+ for key in ["<Up>", "<Down>", "<Left>", "<Right>"]:
+ test.log("Selecting everything")
+ invokeMenuItem("Edit", "Select All")
+ waitFor("editor.textCursor().hasSelection()", 1000)
+ test.compare(editor.textCursor().selectionStart(), 0)
+ test.compare(editor.textCursor().selectionEnd(), size)
+ test.compare(editor.textCursor().position(), size)
+ test.log("Pressing key %s" % key)
+ type(editor, key)
+ if key == "<Up>":
+ test.compare(editor.textCursor().selectionStart(), editor.textCursor().selectionEnd())
+ else:
+ pos = size
+ if key == "<Left>":
+ pos -= 1
+ test.compare(editor.textCursor().selectionStart(), pos)
+ test.compare(editor.textCursor().selectionEnd(), pos)
+ test.compare(editor.textCursor().position(), pos)
+ invokeMenuItem("File", "Exit")
+ waitForCleanShutdown()