~ubuntu-branches/ubuntu/utopic/nepomuk-core/utopic

« back to all changes in this revision

Viewing changes to libnepomukcore/test/simpleresourceclassestest.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-26 22:43:09 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120726224309-pf2v1e78ee7uljjp
Tags: 4:4.9.0a-0ubuntu1
* Use direct build-depends versions rather than kde-sc-dev-latest
* New upstream release
* New symbols, rename libnepomukcore4 to libnepomukcore4abi and enable Debian ABI manager

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   This file is part of the Nepomuk KDE project.
 
3
   Copyright (C) 2011 Serebriyskiy Artem <v.for.vandal@gmail.com>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) version 3, or any
 
9
   later version accepted by the membership of KDE e.V. (or its
 
10
   successor approved by the membership of KDE e.V.), which shall
 
11
   act as a proxy defined in Section 6 of version 3 of the license.
 
12
 
 
13
   This library is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
   Lesser General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU Lesser General Public
 
19
   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
#include "simpleresourceclassestest.h"
 
23
 
 
24
 
 
25
#include <QtDebug>
 
26
#include <QByteArray>
 
27
#include <QDataStream>
 
28
#include <QtTest/QTest>
 
29
 
 
30
using namespace Nepomuk2;
 
31
 
 
32
void SimpleResourceSubsystemTest::initTestCase()
 
33
{
 
34
    resource1.setUri(QUrl("resource1"));
 
35
    resource1.addProperty(QUrl("blablabla"),QString("blablabla"));
 
36
    resource1.addProperty(QUrl("resprg"),SimpleResource(QUrl("another")));
 
37
 
 
38
    resource2.setUri(QUrl("resource2"));
 
39
    resource2.addProperty(QUrl("prop2"),QString("text"));
 
40
    resource2.addProperty(QUrl("prop3"),QVariant(1));
 
41
}
 
42
 
 
43
 
 
44
void SimpleResourceSubsystemTest::testSimpleResourceStream()
 
45
{
 
46
 
 
47
    QByteArray array;
 
48
    QDataStream write_stream(&array,QIODevice::WriteOnly);
 
49
 
 
50
    write_stream << resource1;
 
51
 
 
52
    // Now read
 
53
    QDataStream read_stream(array);
 
54
    SimpleResource answer;
 
55
    read_stream >> answer;
 
56
 
 
57
    QCOMPARE(resource1,answer);
 
58
 
 
59
}
 
60
 
 
61
void SimpleResourceSubsystemTest::testSimpleResourceGraphStream()
 
62
{
 
63
    SimpleResourceGraph refGraph;
 
64
    refGraph.insert(resource1);
 
65
    refGraph.insert(resource2);
 
66
 
 
67
    QByteArray array;
 
68
    QDataStream write_stream(&array,QIODevice::WriteOnly);
 
69
 
 
70
    write_stream << refGraph;
 
71
 
 
72
    // Now read
 
73
    QDataStream read_stream(array);
 
74
    SimpleResourceGraph answer;
 
75
    read_stream >> answer;
 
76
 
 
77
    QCOMPARE(refGraph,answer);
 
78
 
 
79
}
 
80
 
 
81
void SimpleResourceSubsystemTest::testSimpleResourceGraphAdd()
 
82
{
 
83
    SimpleResourceGraph refGraph;
 
84
    refGraph.insert(resource1);
 
85
    refGraph.insert(resource2);
 
86
    SimpleResourceGraph graph1;
 
87
 
 
88
    graph1 += refGraph;
 
89
    QCOMPARE(graph1,refGraph);
 
90
 
 
91
    SimpleResourceGraph graph2;
 
92
    graph2 = refGraph;
 
93
    graph2 += refGraph;
 
94
    qDebug() << refGraph;
 
95
    qDebug() << graph2;
 
96
 
 
97
    QCOMPARE(graph2,refGraph);
 
98
}
 
99
QTEST_MAIN(SimpleResourceSubsystemTest)