test.py 8.03 KB
Newer Older
1 2
#############################################################################
##
Eike Ziller's avatar
Eike Ziller committed
3 4
## Copyright (C) 2015 The Qt Company Ltd.
## Contact: http://www.qt.io/licensing
5 6 7 8 9 10 11
##
## This file is part of Qt Creator.
##
## Commercial License Usage
## Licensees holding valid commercial Qt licenses may use this file in
## accordance with the commercial license agreement provided with the
## Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12 13
## a written agreement between you and The Qt Company.  For licensing terms and
## conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
## use the contact form at http://www.qt.io/contact-us.
15 16 17
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18 19 20 21 22 23
## General Public License version 2.1 or version 3 as published by the Free
## Software Foundation and appearing in the file LICENSE.LGPLv21 and
## LICENSE.LGPLv3 included in the packaging of this file.  Please review the
## following information to ensure the GNU Lesser General Public License
## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
##
Eike Ziller's avatar
Eike Ziller committed
25 26
## In addition, as a special exception, The Qt Company gives you certain additional
## rights.  These rights are described in The Qt Company LGPL Exception
27 28 29 30
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
#############################################################################

31 32 33 34
source("../../shared/qtcreator.py")

# test bookmark functionality
def renameBookmarkFolder(view, item, newName):
35
    invokeContextMenuItemOnBookmarkFolder(view, item, "Rename Folder")
36 37
    replaceEditorContent(waitForObject(":Add Bookmark.treeView_QExpandingLineEdit"), newName)
    type(waitForObject(":Add Bookmark.treeView_QExpandingLineEdit"), "<Return>")
38 39
    return

40 41 42 43 44 45 46
def invokeContextMenuItemOnBookmarkFolder(view, item, menuItem):
    aboveWidget = "{name='line' type='QFrame' visible='1' window=':Add Bookmark_BookmarkDialog'}"
    mouseClick(waitForObjectItem(view, item), 5, 5, 0, Qt.LeftButton)
    openItemContextMenu(view, item, 5, 5, 0)
    activateItem(waitForObject("{aboveWidget=%s type='QMenu' unnamed='1' visible='1' "
                               "window=':Add Bookmark_BookmarkDialog'}" % aboveWidget), menuItem)

Robert Loehning's avatar
Robert Loehning committed
47
def textForQtVersion(text):
48 49 50 51 52 53 54
    if isQt53Build:
        return text + " | QtCreator"
    else:
        suffix = "Qt Creator Manual"
        if text != suffix:
            text += " | " + suffix
        return text
Robert Loehning's avatar
Robert Loehning committed
55

56 57
def main():
    startApplication("qtcreator" + SettingsPath)
58 59
    if not startedWithoutPluginError():
        return
60 61
    # goto help mode and click on topic
    switchViewTo(ViewConstants.HELP)
62 63 64 65
    manualQModelIndex = getQModelIndexStr("text?='Qt Creator Manual *'",
                                          ":Qt Creator_QHelpContentWidget")
    doubleClick(manualQModelIndex, 5, 5, 0, Qt.LeftButton)
    mouseClick(waitForObject(getQModelIndexStr("text='Building and Running an Example'",
Christian Stenger's avatar
Christian Stenger committed
66
                                               manualQModelIndex)), 5, 5, 0, Qt.LeftButton)
67 68
    # open bookmarks window
    clickButton(waitForObject(":Qt Creator.Add Bookmark_QToolButton"))
69
    clickButton(waitForObject(":Add Bookmark.ExpandBookmarksList_QToolButton"))
70 71 72 73 74 75 76 77 78 79 80
    # create root bookmark directory
    clickButton(waitForObject(":Add Bookmark.New Folder_QPushButton"))
    # rename root bookmark directory
    bookmarkView = waitForObject(":Add Bookmark.treeView_QTreeView")
    renameBookmarkFolder(bookmarkView, "New Folder*", "Sample")
    # create two more subfolders
    clickButton(waitForObject(":Add Bookmark.New Folder_QPushButton"))
    renameBookmarkFolder(bookmarkView, "Sample.New Folder*", "Folder 1")
    clickButton(waitForObject(":Add Bookmark.New Folder_QPushButton"))
    renameBookmarkFolder(bookmarkView, "Sample.Folder 1.New Folder*", "Folder 2")
    clickButton(waitForObject(":Add Bookmark.OK_QPushButton"))
81
    mouseClick(manualQModelIndex, 5, 5, 0, Qt.LeftButton)
82 83
    type(waitForObject(":Qt Creator_QHelpContentWidget"), "<Down>")
    clickButton(waitForObject(":Qt Creator.Add Bookmark_QToolButton"))
84
    clickButton(waitForObject(":Add Bookmark.ExpandBookmarksList_QToolButton"))
85
    # click on "Sample" and create new directory under it
86
    mouseClick(waitForObject(getQModelIndexStr("text='Sample'", ":Add Bookmark.treeView_QTreeView")))
87 88 89 90 91
    clickButton(waitForObject(":Add Bookmark.New Folder_QPushButton"))
    clickButton(waitForObject(":Add Bookmark.OK_QPushButton"))
    # choose bookmarks
    mouseClick(waitForObjectItem(":Qt Creator_Core::Internal::CommandComboBox", "Bookmarks"))
    # verify if all folders are created and bookmarks present
92 93 94
    sampleQModelIndex = getQModelIndexStr("text='Sample'", ":Qt Creator_Bookmarks_TreeView")
    folder1QModelIndex = getQModelIndexStr("text='Folder 1'", sampleQModelIndex)
    folder2QModelIndex = getQModelIndexStr("text='Folder 2'", folder1QModelIndex)
Robert Loehning's avatar
Robert Loehning committed
95
    bldRunQModelIndex = getQModelIndexStr("text?='%s'" % textForQtVersion("Building and Running an Example*"),
96 97
                                          folder2QModelIndex)
    newFolderQModelIndex = getQModelIndexStr("text='New Folder'", sampleQModelIndex)
Robert Loehning's avatar
Robert Loehning committed
98
    manualQModelIndex = getQModelIndexStr("text='%s'" % textForQtVersion("Qt Creator Manual"),
99 100 101 102 103 104
                                             newFolderQModelIndex)
    test.verify(checkIfObjectExists(sampleQModelIndex, verboseOnFail = True) and
                checkIfObjectExists(folder1QModelIndex, verboseOnFail = True) and
                checkIfObjectExists(folder2QModelIndex, verboseOnFail = True) and
                checkIfObjectExists(bldRunQModelIndex, verboseOnFail = True) and
                checkIfObjectExists(manualQModelIndex, verboseOnFail = True),
105
                "Verifying if all folders and bookmarks are present")
106
    mouseClick(waitForObject(":Qt Creator_Bookmarks_TreeView"), 5, 5, 0, Qt.LeftButton)
107
    for i in range(6):
108 109
        type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Right>")
    type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Return>")
110
    test.verify(textForQtVersion("Building and Running an Example") in getHelpTitle(),
111
                "Verifying if first bookmark is opened")
112 113 114 115 116
    mouseClick(waitForObject(bldRunQModelIndex))
    type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Down>")
    type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Right>")
    type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Down>")
    type(waitForObject(":Qt Creator_Bookmarks_TreeView"), "<Return>")
117
    test.verify(textForQtVersion("Qt Creator Manual") in getHelpTitle(),
118 119 120
                "Verifying if second bookmark is opened")
    # delete previously created directory
    clickButton(waitForObject(":Qt Creator.Add Bookmark_QToolButton"))
121
    clickButton(waitForObject(":Add Bookmark.ExpandBookmarksList_QToolButton"))
122 123
    invokeContextMenuItemOnBookmarkFolder(":Add Bookmark.treeView_QTreeView", "Sample.Folder 1",
                                          "Delete Folder")
124
    clickButton(waitForObject("{container=':Add Bookmark.treeView_QTreeView' text='Yes' "
125
                              "type='QPushButton' unnamed='1' visible='1'}"))
126 127
    # close bookmarks
    clickButton(waitForObject(":Add Bookmark.OK_QPushButton"))
128
    # choose bookmarks from command combobox
129 130 131
    mouseClick(waitForObject(":Qt Creator_Core::Internal::CommandComboBox"))
    mouseClick(waitForObjectItem(":Qt Creator_Core::Internal::CommandComboBox", "Bookmarks"))
    # verify if folders and bookmark deleted
132 133 134 135 136
    test.verify(checkIfObjectExists(sampleQModelIndex, verboseOnFail = True) and
                checkIfObjectExists(folder1QModelIndex, shouldExist = False, verboseOnFail = True) and
                checkIfObjectExists(folder2QModelIndex, shouldExist = False, verboseOnFail = True) and
                checkIfObjectExists(bldRunQModelIndex, shouldExist = False, verboseOnFail = True) and
                checkIfObjectExists(manualQModelIndex, verboseOnFail = True),
137 138 139
                "Verifying if folder 1 and folder 2 deleted including their bookmark")
    # exit
    invokeMenuItem("File", "Exit")