Merge remote-tracking branch 'origin/3.1'

This commit is contained in:
Eike Ziller
2014-02-27 17:13:27 +01:00
53 changed files with 765 additions and 412 deletions

View File

@@ -127,6 +127,7 @@ private Q_SLOTS:
void functionDefaultArgument();
void attributeInAccessSpecifier();
void braceReturn();
void staticVarDeclWithTypeDecl();
};
struct Line {
@@ -2111,6 +2112,43 @@ void tst_CodeFormatter::braceReturn()
checkIndent(data);
}
void tst_CodeFormatter::staticVarDeclWithTypeDecl()
{
QList<Line> data;
data << Line("static class: public Foo {")
<< Line("public:")
<< Line(" int bar();")
<< Line("} mooze;")
<< Line("")
<< Line("static enum Col {")
<< Line(" red,")
<< Line(" yellow,")
<< Line(" green")
<< Line("} Loc;")
<< Line("")
<< Line("static enum {")
<< Line(" red,")
<< Line(" yellow,")
<< Line(" green")
<< Line("} Loc;")
<< Line("")
<< Line("enum class Col {")
<< Line(" red,")
<< Line(" yellow,")
<< Line(" green")
<< Line("};")
<< Line("")
<< Line("static enum class Col")
<< Line("{")
<< Line(" red,")
<< Line(" yellow,")
<< Line(" green")
<< Line("} Loc;")
<< Line("")
;
checkIndent(data);
}
QTEST_MAIN(tst_CodeFormatter)
#include "tst_codeformatter.moc"

View File

@@ -32,6 +32,7 @@
#include <QtTest>
#include <QFile>
#include <QHash>
#include <QSet>
//TESTED_COMPONENT=src/libs/cplusplus
using namespace CPlusPlus;
@@ -116,9 +117,17 @@ public:
}
virtual void passedMacroDefinitionCheck(unsigned /*offset*/,
unsigned /*line*/,
const Macro &/*macro*/) {}
virtual void failedMacroDefinitionCheck(unsigned /*offset*/, const ByteArrayRef &/*name*/) {}
unsigned line,
const Macro &macro)
{
m_definitionsResolvedFromLines[macro.name()].append(line);
}
virtual void failedMacroDefinitionCheck(unsigned /*offset*/,
const ByteArrayRef &name)
{
m_unresolvedDefines.insert(name.toByteArray());
}
virtual void notifyMacroReference(unsigned offset, unsigned line, const Macro &macro)
{
@@ -249,6 +258,12 @@ public:
QHash<QByteArray, QList<unsigned> > macroUsesLine() const
{ return m_macroUsesLine; }
QHash<QByteArray, QList<unsigned> > definitionsResolvedFromLines() const
{ return m_definitionsResolvedFromLines; }
QSet<QByteArray> unresolvedDefines() const
{ return m_unresolvedDefines; }
const QList<int> macroArgsCount() const
{ return m_macroArgsCount; }
@@ -266,6 +281,8 @@ private:
QList<QByteArray> m_definedMacros;
QList<unsigned> m_definedMacrosLine;
QHash<QByteArray, QList<unsigned> > m_macroUsesLine;
QHash<QByteArray, QList<unsigned> > m_definitionsResolvedFromLines;
QSet<QByteArray> m_unresolvedDefines;
QList<int> m_macroArgsCount;
};
@@ -326,6 +343,7 @@ private slots:
void extra_va_args();
void defined();
void defined_data();
void defined_usage();
void empty_macro_args();
void macro_args_count();
void invalid_param_count();
@@ -356,6 +374,7 @@ private slots:
void include_guard_data();
void empty_trailing_lines();
void empty_trailing_lines_data();
void undef();
};
// Remove all #... lines, and 'simplify' string, to allow easily comparing the result
@@ -1058,6 +1077,36 @@ void tst_Preprocessor::defined_data()
"#endif\n";
}
void tst_Preprocessor::defined_usage()
{
QByteArray output;
Environment env;
MockClient client(&env, &output);
Preprocessor pp(&client, &env);
QByteArray source =
"#define X\n"
"#define Y\n"
"#ifdef X\n"
"#endif\n"
"#ifdef Y\n"
"#endif\n"
"#ifndef X\n"
"#endif\n"
"#ifndef Y\n"
"#endif\n"
"#ifdef ABSENT\n"
"#endif\n"
"#ifndef ABSENT2\n"
"#endif\n"
;
pp.run(QLatin1String("<stdin>"), source);
QHash<QByteArray, QList<unsigned> > definitionsResolvedFromLines =
client.definitionsResolvedFromLines();
QCOMPARE(definitionsResolvedFromLines["X"], QList<unsigned>() << 3 << 7);
QCOMPARE(definitionsResolvedFromLines["Y"], QList<unsigned>() << 5 << 9);
QCOMPARE(client.unresolvedDefines(), QSet<QByteArray>() << "ABSENT" << "ABSENT2");
}
void tst_Preprocessor::dont_eagerly_expand_data()
{
QTest::addColumn<QByteArray>("input");
@@ -1691,6 +1740,46 @@ void tst_Preprocessor::empty_trailing_lines_data()
);
}
void tst_Preprocessor::undef()
{
Environment env;
QByteArray output;
MockClient client(&env, &output);
Preprocessor preprocess(&client, &env);
QByteArray input =
"#define FOO\n"
"#define FOO2\n"
"#undef FOO\n"
"#undef BAR\n";
preprocess.run(QLatin1String("<stdin>"), input);
QCOMPARE(env.macroCount(), 4U);
Macro *macro = env.macroAt(0);
QCOMPARE(macro->name(), QByteArray("FOO"));
QCOMPARE(macro->offset(), 8U);
QCOMPARE(macro->line(), 1U);
QVERIFY(!macro->isHidden());
macro = env.macroAt(1);
QCOMPARE(macro->name(), QByteArray("FOO2"));
QCOMPARE(macro->offset(), 20U);
QCOMPARE(macro->line(), 2U);
QVERIFY(!macro->isHidden());
macro = env.macroAt(2);
QCOMPARE(macro->name(), QByteArray("FOO"));
QCOMPARE(macro->offset(), 32U);
QCOMPARE(macro->line(), 3U);
QVERIFY(macro->isHidden());
macro = env.macroAt(3);
QCOMPARE(macro->name(), QByteArray("BAR"));
QCOMPARE(macro->offset(), 43U);
QCOMPARE(macro->line(), 4U);
QVERIFY(macro->isHidden());
QList<QByteArray> macros = client.definedMacros();
QVERIFY(macros.contains("FOO"));
QVERIFY(macros.contains("FOO2"));
QCOMPARE(client.macroUsesLine()["FOO"], (QList<unsigned>() << 3U));
QVERIFY(client.macroUsesLine()["BAR"].isEmpty());
}
void tst_Preprocessor::compare_input_output(bool keepComments)
{
QFETCH(QByteArray, input);

View File

@@ -131,6 +131,7 @@
:Qt Creator.Help_Search for:_QLineEdit {leftWidget=':Qt Creator.Search for:_QLabel' type='QLineEdit' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Issues_QListView {type='QListView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Issues'}
:Qt Creator.Project.Menu.File_QMenu {name='Project.Menu.File' type='QMenu'}
:Qt Creator.Project.Menu.Folder_QMenu {name='Project.Menu.Folder' type='QMenu' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.ReRun_QToolButton {toolTip='Re-run this run-configuration' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator.Replace All_QToolButton {name='replaceAllButton' text='Replace All' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}

View File

@@ -82,7 +82,10 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
openItemContextMenu(treeview, itemText, 5, 5, 0)
except:
openItemContextMenu(treeview, addBranchWildcardToRoot(itemText), 5, 5, 0)
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.File_QMenu", "Rename..."))
if oldname.endswith(".qrc"):
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.Folder_QMenu", "Rename File"))
else:
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.File_QMenu", "Rename..."))
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), newname)
type(waitForObject(":Qt Creator_Utils::NavigationTreeView::QExpandingLineEdit"), "<Return>")
test.verify(waitFor("os.path.exists(newFilePath)", 1000),

View File

@@ -44,7 +44,7 @@ def main():
for project in projects:
openQmakeProject(project)
progressBarWait(20000)
checkNavigator(49, "Verifying whether all projects have been opened.")
checkNavigator(68, "Verifying whether all projects have been opened.")
openDocument("propertyanimation.QML.qml.color-animation\\.qml")
openDocument("declarative-music-browser.Headers.utility\\.h")
checkOpenDocuments(2, "Verifying whether 2 files are open.")
@@ -57,7 +57,7 @@ def main():
switchSession(sessionName)
test.verify(waitFor("sessionName in str(mainWindow.windowTitle)", 2000),
"Verifying window title contains created session name.")
checkNavigator(49, "Verifying whether all projects have been re-opened.")
checkNavigator(68, "Verifying whether all projects have been re-opened.")
checkOpenDocuments(2, "Verifying whether 2 files have been re-opened.")
if test.verify("utility.h" in str(mainWindow.windowTitle),
"Verifying whether utility.h has been opened."):