Commit b43f8ecb authored by Tobias Koenig's avatar Tobias Koenig

Add first unit-test for akonadi-contact library

svn path=/trunk/KDE/kdepimlibs/; revision=1022308
parent d4975a59
......@@ -5,6 +5,8 @@ include_directories(
${CMAKE_SOURCE_DIR}/kabc
)
add_subdirectory(tests)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII ${KDE4_ENABLE_EXCEPTIONS}")
########### next target ###############
......
/* This file is part of the KDE project
Copyright (C) 2007 David Faure <faure@kde.org>
This library 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 library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef AKONADI_CONTACT_PRIVATE_EXPORT_H
#define AKONADI_CONTACT_PRIVATE_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <kdemacros.h>
#ifndef AKONADI_CONTACT_TESTS_EXPORT
# if defined(MAKE_AKONADI_CONTACT_LIB)
/* We are building this library */
# define AKONADI_CONTACT_TESTS_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define AKONADI_CONTACT_TESTS_EXPORT KDE_IMPORT
# endif
#endif
#endif
......@@ -22,6 +22,8 @@
#ifndef AKONADI_CONTACTMETADATAATTRIBUTE_P_H
#define AKONADI_CONTACTMETADATAATTRIBUTE_P_H
#include "akonadi-contactprivate_export.h"
#include <akonadi/attribute.h>
#include <QtCore/QVariant>
......@@ -33,7 +35,7 @@ namespace Akonadi {
*
* @author Tobias Koenig <tokoe@kde.org>
*/
class ContactMetaDataAttribute : public Akonadi::Attribute
class AKONADI_CONTACT_TESTS_EXPORT ContactMetaDataAttribute : public Akonadi::Attribute
{
public:
/**
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( ${CMAKE_SOURCE_DIR}/akonadi/contact )
########### next target ###############
set(contactmetadataattributetest_SRCS contactmetadataattributetest.cpp)
kde4_add_unit_test(contactmetadataattributetest TESTNAME contactmetadataattributetest ${contactmetadataattributetest_SRCS})
target_link_libraries(contactmetadataattributetest ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${KDE4_KDECORE_LIBS} akonadi-contact)
/*
This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library 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 library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "contactmetadataattributetest.h"
#include "contactmetadataattribute_p.h"
#include <qtest_kde.h>
QTEST_KDEMAIN( ContactMetaDataAttributeTest, NoGUI )
static QVariantMap testData()
{
QVariantMap data;
data.insert( QLatin1String( "key1" ), QLatin1String( "value1" ) );
data.insert( QLatin1String( "key2" ), QLatin1String( "value2" ) );
return data;
}
void ContactMetaDataAttributeTest::type()
{
Akonadi::ContactMetaDataAttribute attribute;
QVERIFY( attribute.type() == "contactmetadata" );
}
void ContactMetaDataAttributeTest::clone()
{
const QVariantMap content1 = testData();
Akonadi::ContactMetaDataAttribute attribute1;
attribute1.setMetaData( content1 );
Akonadi::ContactMetaDataAttribute *attribute2 = static_cast<Akonadi::ContactMetaDataAttribute*>( attribute1.clone() );
const QVariantMap content2 = attribute2->metaData();
QVERIFY( content1 == content2 );
}
void ContactMetaDataAttributeTest::serialization()
{
const QVariantMap content1 = testData();
Akonadi::ContactMetaDataAttribute attribute1;
attribute1.setMetaData( content1 );
const QByteArray data = attribute1.serialized();
Akonadi::ContactMetaDataAttribute attribute2;
attribute2.deserialize( data );
const QVariantMap content2 = attribute2.metaData();
QVERIFY( content1 == content2 );
}
#include "contactmetadataattributetest.moc"
/*
This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
This library 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 library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef CONTACTMETADATAATTRIBUTETEST_H
#define CONTACTMETADATAATTRIBUTETEST_H
#include <QtCore/QObject>
class ContactMetaDataAttributeTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void type();
void clone();
void serialization();
};
#endif
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