test.py 2.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
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():
13
14
    files = map(lambda record: os.path.join(srcPath, testData.field(record, "filename")),
                testData.dataset("files.tsv"))
15
    for currentFile in files:
16
17
18
19
        if not neededFilePresent(currentFile):
            return

    startApplication("qtcreator" + SettingsPath)
20
    for currentFile in files:
21
22
23
24
        test.log("Opening file %s" % currentFile)
        size = charactersInFile(currentFile)
        invokeMenuItem("File", "Open File or Project...")
        selectFromFileDialog(currentFile)
25
26
27
28
29
        editor = getEditorForFileSuffix(currentFile)
        if editor == None:
            test.fatal("Could not get the editor for '%s'" % currentFile,
                       "Skipping this file for now.")
            continue
30
        JIRA.performWorkaroundIfStillOpen(6918, JIRA.Bug.CREATOR, editor)
31
32
33
34
35
36
37
        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)
Robert Loehning's avatar
Robert Loehning committed
38
            test.log("Pressing key: %s" % key.replace("<", "").replace(">", ""))
39
40
41
42
43
44
45
            type(editor, key)
            if key == "<Up>":
                test.compare(editor.textCursor().selectionStart(), editor.textCursor().selectionEnd())
            else:
                pos = size
                if key == "<Left>":
                    pos -= 1
Robert Loehning's avatar
Robert Loehning committed
46
                    if JIRA.isBugStillOpen(7215, JIRA.Bug.CREATOR):
47
48
                        test.warning("Using workaround for %s-%d" % (JIRA.Bug.CREATOR, 7215))
                        pos = 0
49
50
51
52
53
                test.compare(editor.textCursor().selectionStart(), pos)
                test.compare(editor.textCursor().selectionEnd(), pos)
                test.compare(editor.textCursor().position(), pos)
    invokeMenuItem("File", "Exit")
    waitForCleanShutdown()