Commit a8cbaa1e authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor: Tests: Fix blocking the token tests by a pop up

Now the used QuickFixFactory InsertVirtualMethods is configured to not
generate any pop ups.

Change-Id: I36d297678d87e6fb2eb0a73fea6384f0eb7e21f0
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent fb5a5688
......@@ -38,8 +38,11 @@ SOURCES += cppeditorplugin.cpp \
RESOURCES += cppeditor.qrc
equals(TEST, 1) {
HEADERS += cppquickfix_test_utils.h
SOURCES += \
cppquickfix_test.cpp \
cppquickfix_test_utils.cpp \
cppdoxygen_test.cpp \
fileandtokenactions_test.cpp \
followsymbol_switchmethoddecldef_test.cpp
......
......@@ -59,6 +59,8 @@ QtcPlugin {
files: [
"cppdoxygen_test.cpp",
"cppquickfix_test.cpp",
"cppquickfix_test_utils.cpp",
"cppquickfix_test_utils.h",
"fileandtokenactions_test.cpp",
"followsymbol_switchmethoddecldef_test.cpp"
]
......
......@@ -27,6 +27,8 @@
**
****************************************************************************/
#include "cppquickfix_test_utils.h"
#include "cppeditor.h"
#include "cppeditorplugin.h"
#include "cppquickfixassistant.h"
......@@ -3121,33 +3123,6 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_noSignatureMatch()
data.run(&factory);
}
/// Test dialog for insert virtual functions
class InsertVirtualMethodsDialogTest : public InsertVirtualMethodsDialog
{
public:
InsertVirtualMethodsDialogTest(ImplementationMode mode, bool virt, QWidget *parent = 0)
: InsertVirtualMethodsDialog(parent)
{
setImplementationsMode(mode);
setInsertKeywordVirtual(virt);
}
bool gather()
{
return true;
}
ImplementationMode implementationMode() const
{
return m_implementationMode;
}
bool insertKeywordVirtual() const
{
return m_insertKeywordVirtual;
}
};
/// Check: Insert only declarations
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_onlyDecl()
{
......
/****************************************************************************
**
** Copyright (C) 2013 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.
**
****************************************************************************/
#include "cppquickfix_test_utils.h"
#include "cppquickfixes.h"
using namespace CppEditor::Internal;
InsertVirtualMethodsDialogTest::InsertVirtualMethodsDialogTest(ImplementationMode mode,
bool insertVirtualKeyword,
QWidget *parent)
: InsertVirtualMethodsDialog(parent)
{
setImplementationsMode(mode);
setInsertKeywordVirtual(insertVirtualKeyword);
}
InsertVirtualMethodsDialog::ImplementationMode InsertVirtualMethodsDialogTest::implementationMode() const
{
return m_implementationMode;
}
bool InsertVirtualMethodsDialogTest::insertKeywordVirtual() const
{
return m_insertKeywordVirtual;
}
bool InsertVirtualMethodsDialogTest::gather()
{
return true;
}
/****************************************************************************
**
** Copyright (C) 2013 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.
**
****************************************************************************/
#ifndef CPPQUICKFIX_TEST_UTILS_H
#define CPPQUICKFIX_TEST_UTILS_H
#include "cppquickfixes.h"
/// Fake dialog of InsertVirtualMethodsDialog that does not pop up anything.
class InsertVirtualMethodsDialogTest : public CppEditor::Internal::InsertVirtualMethodsDialog
{
public:
InsertVirtualMethodsDialogTest(ImplementationMode mode, bool insertVirtualKeyword,
QWidget *parent = 0);
bool gather();
ImplementationMode implementationMode() const;
bool insertKeywordVirtual() const;
};
#endif // CPPQUICKFIX_TEST_UTILS_H
......@@ -34,9 +34,11 @@
#include <cppeditor/cppeditor.h>
#include <cppeditor/cppeditorplugin.h>
#include <cppeditor/cppquickfixassistant.h>
#include <cppeditor/cppquickfixes.h>
#include <cppeditor/cppquickfix.h>
#include <cpptools/cpptoolsplugin.h>
#include <cppeditor/cppquickfix_test_utils.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolsplugin.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
......@@ -469,7 +471,19 @@ void RunAllQuickFixesTokenAction::run(CPPEditorWidget *editorWidget)
foreach (CppQuickFixFactory *quickFixFactory, quickFixFactories) {
TextEditor::QuickFixOperations operations;
quickFixFactory->match(qfi, operations);
// Some Quick Fixes pop up a dialog and are therefore inappropriate for this test.
// Where possible, use a guiless version of the factory.
if (qobject_cast<InsertVirtualMethods *>(quickFixFactory)) {
QScopedPointer<CppQuickFixFactory> factoryProducingGuiLessOperations;
factoryProducingGuiLessOperations.reset(
new InsertVirtualMethods(
new InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeOutsideClass, true)));
factoryProducingGuiLessOperations->match(qfi, operations);
} else {
quickFixFactory->match(qfi, operations);
}
foreach (QuickFixOperation::Ptr operation, operations) {
qDebug() << " -- Performing Quick Fix" << operation->description();
operation->perform();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment