forked from qt-creator/qt-creator
QmlProfiler: Add tests for QmlNote
Change-Id: Ida4a3ad0adf59d9c21d6405ea6dcbfea5d41ba71 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -38,4 +38,15 @@ QDataStream &operator<<(QDataStream &stream, const QmlNote ¬e)
|
||||
return stream << note.m_typeIndex << note.m_startTime << note.m_duration << note.m_text;
|
||||
}
|
||||
|
||||
bool operator==(const QmlNote ¬e1, const QmlNote ¬e2)
|
||||
{
|
||||
return note1.typeIndex() == note2.typeIndex() && note1.startTime() == note2.startTime()
|
||||
&& note1.duration() == note2.duration() && note1.text() == note2.text();
|
||||
}
|
||||
|
||||
bool operator!=(const QmlNote ¬e1, const QmlNote ¬e2)
|
||||
{
|
||||
return !(note1 == note2);
|
||||
}
|
||||
|
||||
} // namespace QmlProfiler
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace QmlProfiler {
|
||||
class QmlNote {
|
||||
|
||||
public:
|
||||
QmlNote(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1,
|
||||
QmlNote(int typeIndex = -1, qint64 startTime = -1, qint64 duration = 0,
|
||||
const QString &text = QString()) :
|
||||
m_typeIndex(typeIndex), m_startTime(startTime), m_duration(duration), m_text(text)
|
||||
{}
|
||||
@@ -54,6 +54,9 @@ private:
|
||||
QString m_text;
|
||||
};
|
||||
|
||||
bool operator==(const QmlNote ¬e1, const QmlNote ¬e2);
|
||||
bool operator!=(const QmlNote ¬e1, const QmlNote ¬e2);
|
||||
|
||||
QDataStream &operator>>(QDataStream &stream, QmlNote ¬e);
|
||||
QDataStream &operator<<(QDataStream &stream, const QmlNote ¬e);
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ QtcPlugin {
|
||||
"qmlevent_test.cpp", "qmlevent_test.h",
|
||||
"qmleventlocation_test.cpp", "qmleventlocation_test.h",
|
||||
"qmleventtype_test.cpp", "qmleventtype_test.h",
|
||||
"qmlnote_test.cpp", "qmlnote_test.h",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "tests/qmlevent_test.h"
|
||||
#include "tests/qmleventlocation_test.h"
|
||||
#include "tests/qmleventtype_test.h"
|
||||
#include "tests/qmlnote_test.h"
|
||||
#endif
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -99,6 +100,7 @@ QList<QObject *> QmlProfiler::Internal::QmlProfilerPlugin::createTestObjects() c
|
||||
tests << new QmlEventTest;
|
||||
tests << new QmlEventLocationTest;
|
||||
tests << new QmlEventTypeTest;
|
||||
tests << new QmlNoteTest;
|
||||
#endif
|
||||
return tests;
|
||||
}
|
||||
|
||||
77
src/plugins/qmlprofiler/tests/qmlnote_test.cpp
Normal file
77
src/plugins/qmlprofiler/tests/qmlnote_test.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlnote_test.h"
|
||||
#include <qmlprofiler/qmlnote.h>
|
||||
#include <QtTest>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
QmlNoteTest::QmlNoteTest(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void QmlNoteTest::testAccessors()
|
||||
{
|
||||
QmlNote note;
|
||||
QCOMPARE(note.typeIndex(), -1);
|
||||
QCOMPARE(note.startTime(), -1);
|
||||
QCOMPARE(note.duration(), 0);
|
||||
QVERIFY(note.text().isEmpty());
|
||||
|
||||
note.setText("blah");
|
||||
QCOMPARE(note.text(), QString("blah"));
|
||||
|
||||
QmlNote note2(8, 9, 10, "semmeln");
|
||||
QCOMPARE(note2.typeIndex(), 8);
|
||||
QCOMPARE(note2.startTime(), 9);
|
||||
QCOMPARE(note2.duration(), 10);
|
||||
QCOMPARE(note2.text(), QString("semmeln"));
|
||||
}
|
||||
|
||||
void QmlNoteTest::testStreamOps()
|
||||
{
|
||||
QmlNote note(4, 5, 6, "eheheh");
|
||||
|
||||
QBuffer wbuffer;
|
||||
wbuffer.open(QIODevice::WriteOnly);
|
||||
QDataStream wstream(&wbuffer);
|
||||
wstream << note;
|
||||
|
||||
QBuffer rbuffer;
|
||||
rbuffer.setData(wbuffer.data());
|
||||
rbuffer.open(QIODevice::ReadOnly);
|
||||
QDataStream rstream(&rbuffer);
|
||||
|
||||
QmlNote note2;
|
||||
QVERIFY(note != note2);
|
||||
rstream >> note2;
|
||||
|
||||
QCOMPARE(note2, note);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
46
src/plugins/qmlprofiler/tests/qmlnote_test.h
Normal file
46
src/plugins/qmlprofiler/tests/qmlnote_test.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
class QmlNoteTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlNoteTest(QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void testAccessors();
|
||||
void testStreamOps();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
@@ -9,7 +9,8 @@ SOURCES += \
|
||||
$$PWD/pixmapcachemodel_test.cpp \
|
||||
$$PWD/qmlevent_test.cpp \
|
||||
$$PWD/qmleventlocation_test.cpp \
|
||||
$$PWD/qmleventtype_test.cpp
|
||||
$$PWD/qmleventtype_test.cpp \
|
||||
$$PWD/qmlnote_test.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/debugmessagesmodel_test.h \
|
||||
@@ -22,4 +23,5 @@ HEADERS += \
|
||||
$$PWD/pixmapcachemodel_test.h \
|
||||
$$PWD/qmlevent_test.h \
|
||||
$$PWD/qmleventlocation_test.h \
|
||||
$$PWD/qmleventtype_test.h
|
||||
$$PWD/qmleventtype_test.h \
|
||||
$$PWD/qmlnote_test.h
|
||||
|
||||
Reference in New Issue
Block a user