Commit 12a0e932 authored by Milian Wolff's avatar Milian Wolff
Browse files

add unit test to benchmark makeoutputmodel

CCBUG: 295361
parent fec7aa1a
project(makebuilder)
add_definitions( -DKDE_DEFAULT_DEBUG_AREA=9037 )
add_subdirectory(tests)
########### next target ###############
set(kdevmakebuilder_LIB_SRCS
......@@ -46,4 +48,3 @@ install( FILES imakebuilder.h DESTINATION ${INCLUDE_INSTALL_DIR}/kdevelop/make C
install( FILES kcm_kdev_makebuilder.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES kdevmakebuilder.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
# install( FILES kdevmakebuilder.rc DESTINATION ${DATA_INSTALL_DIR}/kdevmakebuilder )
......@@ -34,20 +34,16 @@
#include "outputfilters.h"
class FilteredItem
FilteredItem::FilteredItem(const QString& line)
: originalLine( line )
, type( QVariant::fromValue( MakeOutputModel::StandardItem ) )
, shortenedText( line )
, isActivatable(false)
, lineNo(-1)
, columnNo(-1)
{
public:
FilteredItem( const QString& line )
: originalLine( line ),
type( QVariant::fromValue( MakeOutputModel::StandardItem ) ),
shortenedText( line ), isActivatable(false), lineNo(-1), columnNo(-1) { kDebug() << "created item with type:" << type << type.value<MakeOutputModel::OutputItemType>(); }
QString originalLine;
QVariant type;
QString shortenedText;
bool isActivatable;
KUrl url;
int lineNo, columnNo;
};
kDebug() << "created item with type:" << type << type.value<MakeOutputModel::OutputItemType>();
}
const int MakeOutputModel::MakeItemTypeRole = Qt::UserRole + 1;
......
......@@ -30,7 +30,17 @@
#include <QMap>
#include <QVector>
class FilteredItem;
class FilteredItem
{
public:
FilteredItem( const QString& line );
QString originalLine;
QVariant type;
QString shortenedText;
bool isActivatable;
KUrl url;
int lineNo, columnNo;
};
class MakeOutputModel : public QAbstractListModel, public KDevelop::IOutputViewModel
{
......
set(testmakeoutputmodel_SRC test_makeoutputmodel.cpp ../makeoutputmodel.cpp ../outputfilters.cpp)
kde4_add_unit_test(testmakeoutputmodel ${testmakeoutputmodel_SRC})
target_link_libraries(testmakeoutputmodel ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${KDEVPLATFORM_TESTS_LIBRARIES})
/*
* This file is part of KDevelop
*
* Copyright 2012 Milian Wolff <mail@milianw.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "test_makeoutputmodel.h"
#include "../makeoutputmodel.h"
#include <QStringList>
#include <QTest>
QTEST_MAIN(TestMakeOutputModel)
TestMakeOutputModel::TestMakeOutputModel(QObject* parent): QObject(parent)
{
}
void TestMakeOutputModel::benchAddLines()
{
MakeOutputModel model(KUrl("/tmp/build-foo"));
QStringList lines;
const int numLines = 1000;
const int charsPerLine = 100;
for(int i = 0; i < numLines; ++i) {
lines << (QString::number(i) + QString().fill('a', charsPerLine));
}
QBENCHMARK {
model.addLines(lines);
}
}
#include "test_makeoutputmodel.moc"
/*
* This file is part of KDevelop
*
* Copyright 2012 Milian Wolff <mail@milianw.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TEST_MAKEOUTPUTMODEL_H
#define TEST_MAKEOUTPUTMODEL_H
#include <QObject>
class TestMakeOutputModel : public QObject
{
Q_OBJECT
public:
explicit TestMakeOutputModel(QObject* parent = 0);
private slots:
void benchAddLines();
};
#endif // TEST_MAKEOUTPUTMODEL_H
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