Commit d008779b authored by Eike Ziller's avatar Eike Ziller

Merge remote-tracking branch 'origin/3.2'

Conflicts:
	src/plugins/projectexplorer/projectexplorer.cpp

Change-Id: I6dffc1925e6bf35cf6e9fe0676c11d1a5143a208
parents b2487e16 6bf9a192
......@@ -30,6 +30,7 @@
#include "addimportcontainer.h"
#include <QDebug>
#include <QDataStream>
namespace QmlDesigner {
......
......@@ -37,6 +37,7 @@
#include <QStack>
#include <QList>
#include <QVector>
#include <QMetaObject>
QT_BEGIN_NAMESPACE
class QTextDocument;
......
......@@ -34,6 +34,7 @@
#include <QString>
#include <QColor>
#include <QWidget>
namespace Utils {
......
......@@ -320,7 +320,7 @@ bool ModeManager::isModeSelectorVisible()
return d->m_modeSelectorVisible;
}
QObject *ModeManager::instance()
ModeManager *ModeManager::instance()
{
return m_instance;
}
......
......@@ -52,7 +52,7 @@ class CORE_EXPORT ModeManager : public QObject
Q_OBJECT
public:
static QObject *instance();
static ModeManager *instance();
static IMode *currentMode();
static IMode *mode(Id id);
......
......@@ -174,8 +174,8 @@ bool GenericProject::addFiles(const QStringList &filePaths)
QSet<QString> includes = projectIncludePaths().toSet();
QSet<QString> toAdd;
foreach (const QString &filePaths, filePaths) {
QString directory = QFileInfo(filePaths).absolutePath();
foreach (const QString &filePath, filePaths) {
QString directory = QFileInfo(filePath).absolutePath();
if (!includes.contains(directory)
&& !toAdd.contains(directory))
toAdd << directory;
......
......@@ -792,13 +792,37 @@ void PerforcePlugin::filelog(const QString &workingDir, const QString &fileName,
void PerforcePlugin::updateActions(VcsBasePlugin::ActionState as)
{
if (!enableMenuAction(as, m_menuAction)) {
m_commandLocator->setEnabled(false);
const bool menuActionEnabled = enableMenuAction(as, m_menuAction);
const bool enableActions = currentState().hasTopLevel() && menuActionEnabled;
m_commandLocator->setEnabled(enableActions);
m_logRepositoryAction->setEnabled(enableActions);
m_editAction->setEnabled(enableActions);
m_addAction->setEnabled(enableActions);
m_deleteAction->setEnabled(enableActions);
m_openedAction->setEnabled(enableActions);
m_revertFileAction->setEnabled(enableActions);
m_diffFileAction->setEnabled(enableActions);
m_diffProjectAction->setEnabled(enableActions);
m_updateProjectAction->setEnabled(enableActions);
m_revertProjectAction->setEnabled(enableActions);
m_revertUnchangedAction->setEnabled(enableActions);
m_diffAllAction->setEnabled(enableActions);
m_submitProjectAction->setEnabled(enableActions);
m_pendingAction->setEnabled(enableActions);
m_describeAction->setEnabled(enableActions);
m_annotateCurrentAction->setEnabled(enableActions);
m_annotateAction->setEnabled(enableActions);
m_filelogCurrentAction->setEnabled(enableActions);
m_filelogAction->setEnabled(enableActions);
m_logProjectAction->setEnabled(enableActions);
m_logRepositoryAction->setEnabled(enableActions);
m_submitCurrentLogAction->setEnabled(enableActions);
m_updateAllAction->setEnabled(enableActions);
m_diffSelectedFiles->setEnabled(enableActions);
m_undoAction->setEnabled(enableActions);
m_redoAction->setEnabled(enableActions);
if (!menuActionEnabled)
return;
}
const bool hasTopLevel = currentState().hasTopLevel();
m_commandLocator->setEnabled(hasTopLevel);
m_logRepositoryAction->setEnabled(hasTopLevel);
const QString fileName = currentState().currentFileName();
m_editAction->setParameter(fileName);
......@@ -816,14 +840,6 @@ void PerforcePlugin::updateActions(VcsBasePlugin::ActionState as)
m_submitProjectAction->setParameter(projectName);
m_revertProjectAction->setParameter(projectName);
m_revertUnchangedAction->setParameter(projectName);
m_diffAllAction->setEnabled(true);
m_openedAction->setEnabled(true);
m_describeAction->setEnabled(true);
m_annotateAction->setEnabled(true);
m_filelogAction->setEnabled(true);
m_pendingAction->setEnabled(true);
m_updateAllAction->setEnabled(true);
}
bool PerforcePlugin::managesDirectory(const QString &directory, QString *topLevel /* = 0 */)
......
......@@ -1344,6 +1344,8 @@ void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu()
ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
{
disconnect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)),
this, SLOT(currentModeChanged(Core::IMode*,Core::IMode*)));
dd->m_proWindow->aboutToShutdown(); // disconnect from session
SessionManager::closeAllProjects();
dd->m_projectsMode = 0;
......@@ -1730,9 +1732,8 @@ void ProjectExplorerPlugin::restoreSession()
SessionManager::loadSession(dd->m_sessionToRestoreAtStartup);
// update welcome page
connect(ModeManager::instance(),
SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)),
SLOT(currentModeChanged(Core::IMode*,Core::IMode*)));
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)),
this, SLOT(currentModeChanged(Core::IMode*,Core::IMode*)));
connect(dd->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString)));
connect(dd->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(openProjectWelcomePage(QString)));
dd->m_arguments = arguments;
......
......@@ -6254,7 +6254,8 @@ void BaseTextEditorWidget::cut()
void BaseTextEditorWidget::selectAll()
{
d->disableBlockSelection();
if (d->m_inBlockSelectionMode)
d->disableBlockSelection();
QPlainTextEdit::selectAll();
}
......
......@@ -30,6 +30,7 @@
#include "qtlocalpeer.h"
#include <QCoreApplication>
#include <QDataStream>
#include <QTime>
#if defined(Q_OS_WIN)
......
......@@ -261,16 +261,25 @@ static void ChildSignal(int /*arg*/) {
}
- (void)session:(DTiPhoneSimulatorSession *)session didStart:(BOOL)started withError:(NSError *)error {
if (started) {
// bring to front...
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript"
arguments:[NSArray arrayWithObjects:
@"-e", @"tell application \"System Events\"",
@"-e", @" set listOfProcesses to (name of every process where background only is false)",
@"-e", @"end tell",
@"-e", @"repeat with processName in listOfProcesses",
@"-e", @" if processName starts with \"iOS Simulator\" or processName starts with \"iPhone Simulator\" then",
@"-e", @" tell application processName to activate",
@"-e", @" end if",
@"-e", @"end repeat", nil]];
}
if (startOnly && session) {
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript"
arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]];
msgprintf(@"Simulator started (no session)");
[self doExit:EXIT_SUCCESS];
return;
}
if (started) {
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/osascript"
arguments:[NSArray arrayWithObjects:@"-e", @"tell application \"iPhone Simulator\" to activate", nil]];
int pid = [session simulatedApplicationPID];
if (shouldStartDebugger) {
char*args[4] = { NULL, NULL, (char*)[[[NSNumber numberWithInt:pid] description] UTF8String], NULL };
......
......@@ -47,6 +47,8 @@
:Cannot Open Project.Show Details..._QPushButton {text='Show Details...' type='QPushButton' unnamed='1' visible='1' window=':Cannot Open Project_QMessageBox'}
:Cannot Open Project_QMessageBox {text?='Failed to open project in *' type='QMessageBox' unnamed='1' visible='1'}
:Cannot Open Project_QTextEdit {type='QTextEdit' unnamed='1' visible='1' window=':Cannot Open Project_QMessageBox'}
:Close Debugging Session.Yes_QPushButton {text='Yes' type='QPushButton' unnamed='1' visible='1' window=':Close Debugging Session_Utils::CheckableMessageBox'}
:Close Debugging Session_Utils::CheckableMessageBox {type='Utils::CheckableMessageBox' unnamed='1' visible='1' windowTitle='Close Debugging Session'}
:CodePaster__Internal__PasteSelectDialog.Cancel_QPushButton {text='Cancel' type='QPushButton' unnamed='1' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'}
:CodePaster__Internal__PasteSelectDialog.OK_QPushButton {text='OK' type='QPushButton' unnamed='1' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'}
:CodePaster__Internal__PasteSelectDialog.listWidget_QListWidget {name='listWidget' type='QListWidget' visible='1' window=':CodePaster__Internal__PasteSelectDialog_CodePaster::PasteSelectDialog'}
......@@ -188,6 +190,7 @@
:RunSettingsEnvironmentDetails_Utils::DetailsButton {leftWidget=':RunSettingsUseBuildEnvironment_QLabel' text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:RunSettingsUseBuildEnvironment_QLabel {text~='Us(e|ing) <b>Build Environment</b>' type='QLabel' unnamed='1' visible='1'}
:Save Changes.Always save files before build_QCheckBox {name='saveBeforeBuildCheckBox' text='Always save files before build' type='QCheckBox' visible='1' window=':Save Changes_Core::Internal::SaveItemsDialog'}
:Save Changes.Do not Save_QPushButton {text='Do not Save' type='QPushButton' unnamed='1' visible='1' window=':Save Changes_Core::Internal::SaveItemsDialog'}
:Save Changes.Save All_QPushButton {text='Save All' type='QPushButton' unnamed='1' visible='1' window=':Save Changes_Core::Internal::SaveItemsDialog'}
:Save Changes_Core::Internal::SaveItemsDialog {name='Core__Internal__SaveItemsDialog' type='Core::Internal::SaveItemsDialog' visible='1' windowTitle='Save Changes'}
:Select signal.signalList_QTreeWidget {container=':Go to slot.Select signal_QGroupBox' name='signalList' type='QTreeWidget' visible='1'}
......
#############################################################################
##
## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
## Contact: http://www.qt-project.org/legal
##
## 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
## a written agreement between you and Digia. For licensing terms and
## conditions see http://qt.digia.com/licensing. For further information
## use the contact form at http://qt.digia.com/contact-us.
##
## GNU Lesser General Public License Usage
## Alternatively, this file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
##
## In addition, as a special exception, Digia gives you certain additional
## rights. These rights are described in the Digia Qt LGPL Exception
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
##
#############################################################################
def startCreatorTryingClang():
try:
# start Qt Creator with enabled ClangCodeModel plugin (without modifying settings)
startApplication("qtcreator -load ClangCodeModel" + SettingsPath)
errorMsg = "{type='QMessageBox' unnamed='1' visible='1' windowTitle='Qt Creator'}"
errorOK = "{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}" % errorMsg
if waitFor("object.exists(errorOK)", 5000):
clickButton(errorOK) # Error message
clickButton(errorOK) # Help message
raise Exception("ClangCodeModel not found.")
return True
except:
# ClangCodeModel plugin has not been built - start without it
test.warning("ClangCodeModel plugin not available - performing test without.")
startApplication("qtcreator" + SettingsPath)
return False
def __openCodeModelOptions__():
invokeMenuItem("Tools", "Options...")
waitForObjectItem(":Options_QListView", "C++")
clickItem(":Options_QListView", "C++", 14, 15, 0, Qt.LeftButton)
clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Code Model")
def iterateAvailableCodeModels():
__openCodeModelOptions__()
cppChooser = findObject("{type='QComboBox' name='cppChooser' visible='1'}")
models = [str(cppChooser.currentText)] # Make sure default is first in list
if cppChooser.count > 1:
furtherModels = dumpItems(cppChooser.model())
furtherModels.remove(models[0])
models.extend(furtherModels)
clickButton(waitForObject(":Options.OK_QPushButton"))
return models
def selectCodeModel(codeModel):
__openCodeModelOptions__()
expectedObjNames = ['cChooser', 'cppChooser', 'objcChooser', 'objcppChooser', 'hChooser']
for exp in expectedObjNames:
test.verify(checkIfObjectExists("{type='QComboBox' name='%s' visible='1'}" % exp),
"Verifying whether combobox '%s' exists." % exp)
combo = findObject("{type='QComboBox' name='%s' visible='1'}" % exp)
try:
selectFromCombo(combo, codeModel)
except:
test.fatal("Could not find code model '%s'. Canceling dialog." % codeModel)
clickButton(waitForObject(":Options.Cancel_QPushButton"))
return
test.verify(verifyChecked("{name='ignorePCHCheckBox' type='QCheckBox' visible='1'}"),
"Verifying whether 'Ignore pre-compiled headers' is checked by default.")
clickButton(waitForObject(":Options.OK_QPushButton"))
......@@ -54,7 +54,8 @@ source("../../shared/editor_utils.py")
source("../../shared/project_explorer.py")
source("../../shared/hook_utils.py")
source("../../shared/debugger.py")
source("../../shared/workarounds.py")
source("../../shared/clang.py")
source("../../shared/workarounds.py") # include this at last
# ATTENTION: if a test case calls startApplication("qtcreator...") for several times this
# function must be called BEFORE any call except the first (which is done always automatically)
......
......@@ -64,7 +64,7 @@ def constructExpectedCode(original, codeLines, funcSuffix):
return "\n".join(tmp) + "\n"
def main():
startApplication("qtcreator" + SettingsPath)
startCreatorTryingClang()
if not startedWithoutPluginError():
return
projectName = createNewNonQtProject()
......@@ -82,38 +82,45 @@ def main():
"while with braces" : ["", "int dummy = 0;", "while (dummy < 10) {", "++dummy;"],
"do while" : ["", "int dummy = 0;", "do", "++dummy;", "while (dummy < 10);"]
}
editor = getEditorForFileSuffix("main.cpp")
if not editor:
test.fatal("Failed to get an editor - leaving test.")
invokeMenuItem("File", "Exit")
return
models = iterateAvailableCodeModels()
for current in models:
if current != models[0]:
selectCodeModel(current)
test.log("Testing code model: %s" % current)
openDocument("untitled.Sources.main\\.cpp")
editor = getEditorForFileSuffix("main.cpp")
if not editor:
test.fatal("Failed to get an editor - leaving test.")
invokeMenuItem("File", "Exit")
return
originalContent = str(editor.plainText)
for case, codeLines in code.items():
funcSuffix = case.title().replace(" ", "")
test.log("Testing: Extract Function for '%s'" % case)
if not placeCursorToLine(editor, "{"):
continue
typeLines(editor, codeLines)
if not placeCursorToLine(editor, codeLines[2]):
originalContent = str(editor.plainText)
for case, codeLines in code.items():
funcSuffix = case.title().replace(" ", "")
test.log("Testing: Extract Function for '%s'" % case)
if not placeCursorToLine(editor, "{"):
continue
typeLines(editor, codeLines)
if not placeCursorToLine(editor, codeLines[2]):
revertMainCpp()
continue
type(editor, home)
markText(editor, "Right", 2)
snooze(1) # avoid timing issue with the parser
invokeContextMenuItem(editor, 'Refactor', 'Extract Function')
funcEdit = waitForObject("{buddy={text='Enter function name' type='QLabel' unnamed='1' "
"visible='1' window=%s} type='QLineEdit' unnamed='1' visible='1'}"
% inputDialog)
replaceEditorContent(funcEdit, "myFunc%s" % funcSuffix)
clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}"
% inputDialog))
waitFor("'void myFunc%s' in str(editor.plainText)" % funcSuffix, 2500)
# verify the change
modifiedCode = str(editor.plainText)
expectedCode = constructExpectedCode(originalContent, codeLines, funcSuffix)
test.compare(modifiedCode, expectedCode, "Verifying whether code matches expected.")
# reverting to initial state of main.cpp
revertMainCpp()
continue
type(editor, home)
markText(editor, "Right", 2)
snooze(1) # avoid timing issue with the parser
invokeContextMenuItem(editor, 'Refactor', 'Extract Function')
funcEdit = waitForObject("{buddy={text='Enter function name' type='QLabel' unnamed='1' "
"visible='1' window=%s} type='QLineEdit' unnamed='1' visible='1'}"
% inputDialog)
replaceEditorContent(funcEdit, "myFunc%s" % funcSuffix)
clickButton(waitForObject("{text='OK' type='QPushButton' unnamed='1' visible='1' window=%s}"
% inputDialog))
waitFor("'void myFunc%s' in str(editor.plainText)" % funcSuffix, 2500)
# verify the change
modifiedCode = str(editor.plainText)
expectedCode = constructExpectedCode(originalContent, codeLines, funcSuffix)
test.compare(modifiedCode, expectedCode, "Verifying whether code matches expected.")
# reverting to initial state of main.cpp
revertMainCpp()
invokeMenuItem('File', 'Close All')
invokeMenuItem('File', 'Exit')
......@@ -39,44 +39,48 @@ def main():
# copy example project to temp directory
templateDir = prepareTemplate(sourceExample)
examplePath = os.path.join(templateDir, proFile)
startApplication("qtcreator" + SettingsPath)
startCreatorTryingClang()
if not startedWithoutPluginError():
return
# open example project
openQmakeProject(examplePath)
# wait for parsing to complete
progressBarWait(30000)
# open .cpp file in editor
if not openDocument("propertyanimation.Sources.main\\.cpp"):
test.fatal("Could not open main.cpp")
invokeMenuItem("File", "Exit")
return
test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
"Verifying if: .cpp file is opened in Edit mode.")
# place cursor on line "QmlApplicationViewer viewer;"
editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
# invoke find usages from context menu on word "viewer"
if not invokeFindUsage(editorWidget, "QmlApplicationViewer viewer;", "<Left>", 10):
invokeMenuItem("File", "Exit")
return
# wait until search finished and verify search results
waitForSearchResults()
validateSearchResult(14)
result = re.search("QmlApplicationViewer", str(editorWidget.plainText))
test.verify(result, "Verifying if: The list of all usages of the selected text is displayed in Search Results. "
"File with used text is opened.")
# move cursor to the other word and test Find Usages function by pressing Ctrl+Shift+U.
openDocument("propertyanimation.Sources.main\\.cpp")
if not placeCursorToLine(editorWidget, "viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);"):
return
for i in range(4):
type(editorWidget, "<Left>")
type(editorWidget, "<Ctrl+Shift+u>")
# wait until search finished and verify search results
waitForSearchResults()
validateSearchResult(3)
# exit qt creator
invokeMenuItem("File", "Save All")
models = iterateAvailableCodeModels()
for current in models:
if current != models[0]:
selectCodeModel(current)
test.log("Testing code model: %s" % current)
# open .cpp file in editor
if not openDocument("propertyanimation.Sources.main\\.cpp"):
test.fatal("Could not open main.cpp")
invokeMenuItem("File", "Exit")
return
test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
"Verifying if: .cpp file is opened in Edit mode.")
# place cursor on line "QmlApplicationViewer viewer;"
editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
# invoke find usages from context menu on word "viewer"
if not invokeFindUsage(editorWidget, "QmlApplicationViewer viewer;", "<Left>", 10):
invokeMenuItem("File", "Exit")
return
# wait until search finished and verify search results
waitForSearchResults()
validateSearchResult(14)
result = re.search("QmlApplicationViewer", str(editorWidget.plainText))
test.verify(result, "Verifying if: The list of all usages of the selected text is displayed in Search Results. "
"File with used text is opened.")
# move cursor to the other word and test Find Usages function by pressing Ctrl+Shift+U.
openDocument("propertyanimation.Sources.main\\.cpp")
if not placeCursorToLine(editorWidget, "viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);"):
return
for i in range(4):
type(editorWidget, "<Left>")
type(editorWidget, "<Ctrl+Shift+u>")
# wait until search finished and verify search results
waitForSearchResults()
validateSearchResult(3)
invokeMenuItem("File", "Close All")
invokeMenuItem("File", "Exit")
def waitForSearchResults():
......
......@@ -39,59 +39,64 @@ def main():
# copy example project to temp directory
templateDir = prepareTemplate(sourceExample)
examplePath = os.path.join(templateDir, proFile)
startApplication("qtcreator" + SettingsPath)
startCreatorTryingClang()
if not startedWithoutPluginError():
return
# open example project
openQmakeProject(examplePath)
# wait for parsing to complete
progressBarWait(30000)
# open .cpp file in editor
if not openDocument("propertyanimation.Sources.main\\.cpp"):
test.fatal("Could not open main.cpp")
invokeMenuItem("File", "Exit")
return
test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
"Verifying if: .cpp file is opened in Edit mode.")
# select some word for example "viewer" and press Ctrl+F.
editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
if not placeCursorToLine(editorWidget, "QmlApplicationViewer viewer;"):
invokeMenuItem("File", "Exit")
return
type(editorWidget, "<Left>")
markText(editorWidget, "Left", 6)
type(editorWidget, "<Ctrl+f>")
# verify if find toolbar exists and if search text contains selected word
test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"),
"Verifying if: Find/Replace pane is displayed at the bottom of the view.")
test.compare(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit").displayText, "viewer",
"Verifying if: Find line edit contains 'viewer' text.")
# insert some word to "Replace with:" field and select "Replace All".
replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "find")
oldCodeText = str(editorWidget.plainText)
clickButton(waitForObject(":Qt Creator.Replace All_QToolButton"))
mouseClick(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), 5, 5, 0, Qt.LeftButton)
newCodeText = str(editorWidget.plainText)
test.compare(newCodeText, oldCodeText.replace("viewer", "find").replace("Viewer", "find"),
"Verifying if: Found text is replaced with new word properly.")
# select some other word in .cpp file and select "Edit" -> "Find/Replace".
clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton"))
placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);")
for i in range(25):
models = iterateAvailableCodeModels()
for current in models:
if current != models[0]:
selectCodeModel(current)
test.log("Testing code model: %s" % current)
# open .cpp file in editor
if not openDocument("propertyanimation.Sources.main\\.cpp"):
test.fatal("Could not open main.cpp")
invokeMenuItem("File", "Exit")
return
test.verify(checkIfObjectExists(":Qt Creator_CppEditor::Internal::CPPEditorWidget"),
"Verifying if: .cpp file is opened in Edit mode.")
# select some word for example "viewer" and press Ctrl+F.
editorWidget = findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
if not placeCursorToLine(editorWidget, "QmlApplicationViewer viewer;"):
invokeMenuItem("File", "Exit")
return
type(editorWidget, "<Left>")
markText(editorWidget, "Left", 18)
invokeMenuItem("Edit", "Find/Replace", "Find/Replace")
replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer")
oldCodeText = str(editorWidget.plainText)
clickButton(waitForObject(":Qt Creator.Replace_QToolButton"))
newCodeText = str(editorWidget.plainText)
# "::" is used to replace only one occurrence by python
test.compare(newCodeText, oldCodeText.replace("QmlApplicationfind::", "QmlApplicationViewer::"),
"Verifying if: Only selected word is replaced, the rest of found words are not replaced.")
# close Find/Replace tab.
clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton"))
test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar", False),
"Verifying if: Find/Replace tab is closed.")
# exit qt creator
invokeMenuItem("File", "Save All")
markText(editorWidget, "Left", 6)
type(editorWidget, "<Ctrl+f>")
# verify if find toolbar exists and if search text contains selected word
test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar"),
"Verifying if: Find/Replace pane is displayed at the bottom of the view.")
test.compare(waitForObject(":*Qt Creator.findEdit_Utils::FilterLineEdit").displayText, "viewer",
"Verifying if: Find line edit contains 'viewer' text.")
# insert some word to "Replace with:" field and select "Replace All".
replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "find")
oldCodeText = str(editorWidget.plainText)
clickButton(waitForObject(":Qt Creator.Replace All_QToolButton"))
mouseClick(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), 5, 5, 0, Qt.LeftButton)
newCodeText = str(editorWidget.plainText)
test.compare(newCodeText, oldCodeText.replace("viewer", "find").replace("Viewer", "find"),
"Verifying if: Found text is replaced with new word properly.")
# select some other word in .cpp file and select "Edit" -> "Find/Replace".
clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton"))
placeCursorToLine(editorWidget, "find.setOrientation(QmlApplicationfind::ScreenOrientationAuto);")
for i in range(25):
type(editorWidget, "<Left>")
markText(editorWidget, "Left", 18)
invokeMenuItem("Edit", "Find/Replace", "Find/Replace")
replaceEditorContent(waitForObject(":Qt Creator.replaceEdit_Utils::FilterLineEdit"), "QmlApplicationViewer")
oldCodeText = str(editorWidget.plainText)
clickButton(waitForObject(":Qt Creator.Replace_QToolButton"))
newCodeText = str(editorWidget.plainText)
# "::" is used to replace only one occurrence by python
test.compare(newCodeText, oldCodeText.replace("QmlApplicationfind::", "QmlApplicationViewer::"),
"Verifying if: Only selected word is replaced, the rest of found words are not replaced.")
# close Find/Replace tab.
clickButton(waitForObject(":Qt Creator.CloseFind_QToolButton"))
test.verify(checkIfObjectExists(":*Qt Creator.Find_Find::Internal::FindToolBar", False),
"Verifying if: Find/Replace tab is closed.")
invokeMenuItem("File", "Close All")
clickButton(waitForObject(":Save Changes.Do not Save_QPushButton"))
invokeMenuItem("File", "Exit")
......@@ -29,28 +29,6 @@
source("../../shared/qtcreator.py")
def makeClangDefaultCodeModel(pluginAvailable):
invokeMenuItem("Tools", "Options...")
waitForObjectItem(":Options_QListView", "C++")