aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/tests/qmleventlocation_test.cpp
blob: 3a6c9881666bd3e0a4ceccb589e670a2fa00a1b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "qmleventlocation_test.h"

#include <qmlprofiler/qmleventlocation.h>
#include <QtTest>

namespace QmlProfiler {
namespace Internal {

QmlEventLocationTest::QmlEventLocationTest(QObject *parent) : QObject(parent)
{
}

void QmlEventLocationTest::testCtor()
{
    QmlEventLocation location;
    QVERIFY(!location.isValid());

    QmlEventLocation location2("blah.qml", 2, 3);
    QVERIFY(location2.isValid());
    QCOMPARE(location2.filename(), QString("blah.qml"));
    QCOMPARE(location2.line(), 2);
    QCOMPARE(location2.column(), 3);
}

void QmlEventLocationTest::testStreamOps()
{
    QmlEventLocation location("socken.js", 12, 13);

    QBuffer wbuffer;
    wbuffer.open(QIODevice::WriteOnly);
    QDataStream wstream(&wbuffer);
    wstream << location;

    QBuffer rbuffer;
    rbuffer.setData(wbuffer.data());
    rbuffer.open(QIODevice::ReadOnly);
    QDataStream rstream(&rbuffer);

    QmlEventLocation location2;
    QVERIFY(location != location2);
    rstream >> location2;

    QCOMPARE(location2, location);
}

} // namespace Internal
} // namespace QmlProfiler