summaryrefslogtreecommitdiffstats
path: root/kpilot/tests
diff options
context:
space:
mode:
Diffstat (limited to 'kpilot/tests')
-rw-r--r--kpilot/tests/CMakeLists.txt55
-rw-r--r--kpilot/tests/conduits/vcalconduit/exampletest.cc26
-rw-r--r--kpilot/tests/conduits/vcalconduit/exampletest.h28
-rw-r--r--kpilot/tests/data/AddressDB.pdbbin1545 -> 0 bytes
-rw-r--r--kpilot/tests/data/MailDB.pdbbin1342 -> 0 bytes
-rw-r--r--kpilot/tests/data/MemoDB.pdbbin5262 -> 0 bytes
-rw-r--r--kpilot/tests/data/ToDoDB.pdbbin881 -> 0 bytes
-rw-r--r--kpilot/tests/data/bogus.pdb367
-rw-r--r--kpilot/tests/exportdatebook.cc136
-rw-r--r--kpilot/tests/importaddresses.cc128
-rw-r--r--kpilot/tests/importdatebook.cc131
-rw-r--r--kpilot/tests/main.cc17
-rw-r--r--kpilot/tests/mergecalendars.cc228
-rw-r--r--kpilot/tests/testactions.cc92
-rw-r--r--kpilot/tests/testaddress.cc106
-rw-r--r--kpilot/tests/testcategories.cc215
-rw-r--r--kpilot/tests/testconstants.cc68
-rw-r--r--kpilot/tests/testdatabase.cc316
-rw-r--r--kpilot/tests/testdatebook.cc95
-rw-r--r--kpilot/tests/testidmapper.cc314
20 files changed, 0 insertions, 2322 deletions
diff --git a/kpilot/tests/CMakeLists.txt b/kpilot/tests/CMakeLists.txt
deleted file mode 100644
index b38883c92..000000000
--- a/kpilot/tests/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-link_directories(${CMAKE_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR})
-include_directories(${CMAKE_SOURCE_DIR}/lib ${CMAKE_BINARY_DIR}/lib)
-
-# Tests don't need to go into toplevel/bin, they are fine in the current dir.
-set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-
-# This can be used for finding data files in the source dir
-add_definitions( -DKDESRCDIR=\\"${CMAKE_CURRENT_SOURCE_DIR}\\" )
-
-
-set(testconstants_SRCS testconstants.cc)
-kde3_add_executable(testconstants ${testconstants_SRCS})
-target_link_libraries(testconstants kpilot ${QT_LIBRARIES})
-add_test(testconstants ${EXECUTABLE_OUTPUT_PATH}/testconstants)
-
-set(testcategories_SRCS testcategories.cc)
-kde3_add_executable(testcategories ${testcategories_SRCS})
-target_link_libraries(testcategories kpilot ${QT_LIBRARIES})
-add_test(testcategories ${EXECUTABLE_OUTPUT_PATH}/testcategories)
-
-set(testaddresses_SRCS testaddress.cc)
-kde3_add_executable(testaddresses ${testaddresses_SRCS})
-target_link_libraries(testaddresses kpilot ${QT_LIBRARIES})
-add_test(testaddresses ${EXECUTABLE_OUTPUT_PATH}/testaddresses)
-
-set(testdatebook_SRCS testdatebook.cc)
-kde3_add_executable(testdatebook ${testdatebook_SRCS})
-target_link_libraries(testdatebook kpilot ${QT_LIBRARIES})
-add_test(testdatebook ${EXECUTABLE_OUTPUT_PATH}/testdatebook)
-
-set(testidmapper_SRCS testidmapper.cc)
-kde3_add_executable(testidmapper ${testidmapper_SRCS})
-target_link_libraries(testidmapper kpilot ${QT_LIBRARIES})
-add_test(testidmapper ${EXECUTABLE_OUTPUT_PATH}/testidmapper)
-
-if (HAVE_CALENDARLOCAL_H)
- set(importdatebook_SRCS importdatebook.cc)
- set(exportdatebook_SRCS exportdatebook.cc)
- set(mergecalendars_SRCS mergecalendars.cc)
- kde3_add_executable(importdatebook ${importdatebook_SRCS})
- kde3_add_executable(exportdatebook ${exportdatebook_SRCS})
- kde3_add_executable(mergecalendars ${mergecalendars_SRCS})
- target_link_libraries(importdatebook kpilot ${QT_LIBRARIES} kcal)
- target_link_libraries(exportdatebook kpilot ${QT_LIBRARIES} kcal)
- target_link_libraries(mergecalendars ${QT_LIBRARIES} kcal)
- add_test(importdatebook ${EXECUTABLE_OUTPUT_PATH}/importdatebook)
- add_test(exportdatebook ${EXECUTABLE_OUTPUT_PATH}/exportdatebook)
- add_test(mergecalendars ${EXECUTABLE_OUTPUT_PATH}/mergecalendars)
-endif (HAVE_CALENDARLOCAL_H)
-
-set(importaddresses_SRCS importaddresses.cc)
-kde3_add_executable(importaddresses ${importaddresses_SRCS})
-target_link_libraries(importaddresses kpilot ${QT_LIBRARIES} kabc kabc_file)
-add_test(importaddresses ${EXECUTABLE_OUTPUT_PATH}/importaddresses)
-
diff --git a/kpilot/tests/conduits/vcalconduit/exampletest.cc b/kpilot/tests/conduits/vcalconduit/exampletest.cc
deleted file mode 100644
index b16a6c3e5..000000000
--- a/kpilot/tests/conduits/vcalconduit/exampletest.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "options.h"
-#include "config.h"
-
-#include "exampletest.h"
-
-CPPUNIT_TEST_SUITE_REGISTRATION( VCalConduitTest );
-
-
-void VCalConduitTest::setUp()
-{
- device = TQString("testdevice");
- link = new KPilotLocalLink(0, "localLink");
- syncMode = SyncAction::SyncMode::eHotSync;
-}
-
-
-void VCalConduitTest::tearDown()
-{
- delete link;
-}
-
-
-void VCalConduitTest::testConstructor()
-{
- CPPUNIT_ASSERT( true == true );
-}
diff --git a/kpilot/tests/conduits/vcalconduit/exampletest.h b/kpilot/tests/conduits/vcalconduit/exampletest.h
deleted file mode 100644
index f98c14c58..000000000
--- a/kpilot/tests/conduits/vcalconduit/exampletest.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef EXAMPLETEST_H
-#define EXAMPLETEST_H
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <tqstring.h>
-
-#include "kpilotlocallink.h"
-#include "syncAction.h"
-
-class VCalConduitTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE( VCalConduitTest );
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST_SUITE_END();
-
-private:
- TQString device;
- KPilotLocalLink *link;
- SyncAction::SyncMode::Mode syncMode;
-
-public:
- void setUp();
- void tearDown();
-
- void testConstructor();
-};
-
-#endif
diff --git a/kpilot/tests/data/AddressDB.pdb b/kpilot/tests/data/AddressDB.pdb
deleted file mode 100644
index cad6363b7..000000000
--- a/kpilot/tests/data/AddressDB.pdb
+++ /dev/null
Binary files differ
diff --git a/kpilot/tests/data/MailDB.pdb b/kpilot/tests/data/MailDB.pdb
deleted file mode 100644
index 33ca47372..000000000
--- a/kpilot/tests/data/MailDB.pdb
+++ /dev/null
Binary files differ
diff --git a/kpilot/tests/data/MemoDB.pdb b/kpilot/tests/data/MemoDB.pdb
deleted file mode 100644
index 94097b109..000000000
--- a/kpilot/tests/data/MemoDB.pdb
+++ /dev/null
Binary files differ
diff --git a/kpilot/tests/data/ToDoDB.pdb b/kpilot/tests/data/ToDoDB.pdb
deleted file mode 100644
index fd4027f84..000000000
--- a/kpilot/tests/data/ToDoDB.pdb
+++ /dev/null
Binary files differ
diff --git a/kpilot/tests/data/bogus.pdb b/kpilot/tests/data/bogus.pdb
deleted file mode 100644
index f90aef1d8..000000000
--- a/kpilot/tests/data/bogus.pdb
+++ /dev/null
@@ -1,367 +0,0 @@
-/* This file is part of the KDE libraries
- Copyright (c) 2000 The KDE Project
-
- unsetenv() taken from the GNU C Library.
- Copyright (C) 1992,1995-1999,2000-2002 Free Software Foundation, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- 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 <config.h>
-
-#define KDE_open open
-#define KDE_mkdir mkdir
-
-#ifndef HAVE_SETENV
-
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- int setenv(const char *name, const char *value, int overwrite) {
- int i;
- char * a;
-
- if (!overwrite && getenv(name)) return 0;
-
- i = strlen(name) + strlen(value) + 2;
- a = (char*)malloc(i);
- if (!a) return 1;
-
- strcpy(a, name);
- strcat(a, "=");
- strcat(a, value);
-
- return putenv(a);
-}
-#endif /* !HAVE_SETENV */
-
-#ifndef HAVE_UNSETENV
-
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-
-#ifndef environ
-extern char ** environ;
-#endif
-
- void unsetenv (name)
- const char *name;
-{
- size_t len;
- char **ep;
-
- if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
- {
- errno = EINVAL;
- return;
- }
-
- len = strlen (name);
-
- ep = environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
-
-}
-
-#endif /* !HAVE_UNSETENV */
-
-#ifndef HAVE_USLEEP
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#ifdef __cplusplus /* this is supposed to be a C source file but still.. */
-extern "C" {
-#endif
-
-void usleep(unsigned int usec) {
- struct timeval _usleep_tv;
- _usleep_tv.tv_sec = usec/1000000;
- _usleep_tv.tv_usec = usec%1000000;
- select(0,0,0,0,&_usleep_tv);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !HAVE_USLEEP */
-
-#ifndef HAVE_RANDOM
-long int random()
-{
- return lrand48();
-}
-
-void srandom(unsigned int seed)
-{
- srand48(seed);
-}
-#endif
-
-#ifndef HAVE_SETEUID
-int seteuid(uid_t euid)
-{
- setreuid(-1, euid); /* Well, if you have neither you are in trouble :) */
-}
-#endif
-
-#ifndef HAVE_MKSTEMPS
-#include <sys/types.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#include <fcntl.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-
-/* this is based on code taken from the GNU libc, distributed under the LGPL license */
-
-/* Generate a unique temporary file name from TEMPLATE.
-
- TEMPLATE has the form:
-
- <path>/ccXXXXXX<suffix>
-
- SUFFIX_LEN tells us how long <suffix> is (it can be zero length).
-
- The last six characters of TEMPLATE before <suffix> must be "XXXXXX";
- they are replaced with a string that makes the filename unique.
-
- Returns a file descriptor open on the file for reading and writing. */
-
- int mkstemps (char* _template, int suffix_len)
-{
- static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- char *XXXXXX;
- int len;
- int count;
- int value;
-
- len = strlen (_template);
-
- if ((int) len < 6 + suffix_len || strncmp (&_template[len - 6 - suffix_len], "XXXXXX", 6))
- return -1;
-
- XXXXXX = &_template[len - 6 - suffix_len];
-
- value = rand();
- for (count = 0; count < 256; ++count)
- {
- int v = value;
- int fd;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
-
- fd = KDE_open (_template, O_RDWR|O_CREAT|O_EXCL, 0600);
- if (fd >= 0)
- /* The file does not exist. */
- return fd;
-
- /* This is a random value. It is only necessary that the next
- TMP_MAX values generated by adding 7777 to VALUE are different
- with (module 2^32). */
- value += 7777;
- }
- /* We return the null string if we can't find a unique file name. */
- _template[0] = '\0';
- return -1;
-}
-
-#endif /* !HAVE_MKSTEMPS */
-
-#ifndef HAVE_MKSTEMP
- int mkstemp (char* _template)
-{
- return mkstemps( _template, 0 );
-}
-#endif
-
-#ifndef HAVE_MKDTEMP
-
-#ifndef HAVE_MKSTEMPS
-#include <sys/types.h>
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#endif
-
-/* Generate a unique temporary directory name from TEMPLATE.
-
- TEMPLATE has the form:
-
- <path>/ccXXXXXX
-
-
- The last six characters of TEMPLATE must be "XXXXXX";
- they are replaced with a string that makes the filename unique.
-
- Returns a file descriptor open on the file for reading and writing. */
-
- char* mkdtemp (char* _template)
-{
- static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- char *XXXXXX;
- int len;
- int count;
- int value;
-
- len = strlen (_template);
-
- if ((int) len < 6 || strncmp (&_template[len - 6], "XXXXXX", 6))
- return 0;
-
- XXXXXX = &_template[len - 6];
-
- value = rand();
- for (count = 0; count < 256; ++count)
- {
- int v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
-
- /* This is a random value. It is only necessary that the next
- TMP_MAX values generated by adding 7777 to VALUE are different
- with (module 2^32). */
- value += 7777;
-
- if (!KDE_mkdir(_template,0700))
- return _template;
- }
- return 0;
-}
-#endif /* !HAVE_MKDTEMP */
-
-#ifndef HAVE_REVOKE
-#include <errno.h>
-#ifndef ENOTSUP
-#define ENOTSUP 134 /* Not supported */
-#endif
- int revoke(const char *tty)
-{
- errno = ENOTSUP;
- return -1;
-}
-#endif
-
-#ifndef HAVE_STRLCPY
- unsigned long strlcpy(char* d, const char* s, unsigned long bufsize)
-{
- unsigned long len, ret = strlen(s);
-
- if (ret >= bufsize) {
- if (bufsize) {
- len = bufsize - 1;
- memcpy(d, s, len);
- d[len] = '\0';
- }
- } else
- memcpy(d, s, ret + 1);
-
- return ret;
-}
-#endif
-
-#ifndef HAVE_STRLCAT
- unsigned long strlcat(char* d, const char* s, unsigned long bufsize)
-{
- char *cp;
- unsigned long ret, len1, len2 = strlen(s);
-
- cp = (char *)memchr (d, '\0', bufsize);
- if (!cp)
- return bufsize + len2;
- len1 = cp - d;
- ret = len1 + len2;
- if (ret >= bufsize) {
- len2 = bufsize - len1 - 1;
- memcpy(cp, s, len2);
- cp[len2] = '\0';
- } else
- memcpy(cp, s, len2 + 1);
-
- return ret;
-}
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
diff --git a/kpilot/tests/exportdatebook.cc b/kpilot/tests/exportdatebook.cc
deleted file mode 100644
index d4cf8c53e..000000000
--- a/kpilot/tests/exportdatebook.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-/* testaddresses KPilot
-**
-** Copyright (C) 2007 by Jason 'vanRijn' Kasper <vR@movingparts.net)
-**
-** Test the functions related to address database handling.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-#include <kconfigskeleton.h>
-
-#include <libkcal/calendar.h>
-#include <libkcal/calendarlocal.h>
-
-#include "pilot.h"
-#include "pilotDateEntry.h"
-#include "pilotLocalDatabase.h"
-#include "../conduits/vcalconduit/kcalRecord.cc"
-#include "../conduits/vcalconduit/vcalRecord.cc"
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- {"vcal-file <path>","Set vcal file", 0},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
- FUNCTIONSETUP;
-
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("exportdatebook","Emport Date Book","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-
- TQString datadir = args->getOption("data-dir");
- TQString vcalfile = args->getOption("vcal-file");
-
- if (datadir.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a data-directory." << endl;
- }
- if (vcalfile.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a vcal-file to write to." << endl;
- }
- if (datadir.isEmpty() || vcalfile.isEmpty())
- {
- return 1;
- }
-
- /*
- KConfig korgcfg( locate( "config", CSL1("korganizerrc") ) );
-
- // this part taken from adcalendarbase.cpp:
- korgcfg.setGroup( "Time & Date" );
- TQString tz(korgcfg.readEntry( "TimeZoneId" ) );
-
- DEBUGKPILOT << fname << ": KOrganizer's time zone = " << tz << endl;
-
- KCal::CalendarLocal *calendar = new KCal::CalendarLocal( tz );
- */
- KCal::CalendarLocal *calendar = new KCal::CalendarLocal( TQString() );
-
- if (!calendar)
- {
- WARNINGKPILOT << "! Can't create calendar object." << endl;
- return 1;
- }
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- PilotLocalDatabase db( datadir, "DatebookDB" );
-
- PilotDateInfo *fAppointmentAppInfo = new PilotDateInfo( &db );
-
- int currentRecord = 0;
- PilotRecord *pilotRec = 0;
- PilotDateEntry *d = 0;
-
- while ((pilotRec = db.readRecordByIndex(currentRecord++)) != NULL)
- {
- d = new PilotDateEntry(pilotRec);
-
- KCal::Event*event = new KCal::Event;
-
- KCalSync::setEvent(event, d,*fAppointmentAppInfo->categoryInfo());
-
- event->setSyncStatus( KCal::Incidence::SYNCNONE );
-
- calendar->addEvent(event);
-
- }
-
- calendar->save(vcalfile);
-
- return 0;
-}
-
diff --git a/kpilot/tests/importaddresses.cc b/kpilot/tests/importaddresses.cc
deleted file mode 100644
index 61cc513a3..000000000
--- a/kpilot/tests/importaddresses.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-/* importaddresses KPilot
-**
-** Copyright (C) 2006 by Adriaan de Groot <groot@kde.org)
-**
-** Create an address database (for the handheld) from PC data.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include <kabc/addressbook.h>
-#include <kabc/resourcefile.h>
-
-#include "pilot.h"
-#include "pilotLocalDatabase.h"
-#include "pilotAddress.h"
-#include "../conduits/abbrowserconduit/kabcRecord.h"
-#include "../conduits/abbrowserconduit/kabcRecord.cc"
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- {"address-file <path>","Set addressbook file", 0},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
- KAboutData aboutData("importaddresses","Import Address Book","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- // KApplication app( false, false );
- KApplication app;
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
-#ifdef DEBUG
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-#endif
- TQString datadir = args->getOption("data-dir");
- TQString addressfile = args->getOption("address-file");
-
- if (datadir.isEmpty())
- {
- kdWarning() << "! Must provide a data-directory." << endl;
- }
- if (addressfile.isEmpty())
- {
- kdWarning() << "! Must provide an address-file to read." << endl;
- }
- if (datadir.isEmpty() || addressfile.isEmpty())
- {
- return 1;
- }
-
- KABC::ResourceFile *file = new KABC::ResourceFile( addressfile );
- KABC::AddressBook book;
- book.addResource( file );
- if (!book.load())
- {
- kdWarning() << "! Failed to load the address-file <" << addressfile << ">" << endl;
- return 1;
- }
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- PilotLocalDatabase db( datadir, "AddressDB" );
- db.createDatabase( 0xdead, 0xbeef );
- PilotAddressInfo info(0L);
- info.resetToDefault();
- info.writeTo(&db);
-
- KABCSync::Settings settings;
-
- kdDebug() << "# Printing address book." << endl;
- unsigned int count = 1;
- KABC::AddressBook::ConstIterator it = book.begin();
- while (it != book.end())
- {
- const KABC::Addressee &a = *it;
- kdDebug() << "# Entry #" << count << endl;
- kdDebug() << "# " << a.name() << endl;
- kdDebug() << "# " << a.formattedName() << endl;
- PilotAddress *p = new PilotAddress();
- KABCSync::copy(*p,a,info,settings);
- PilotRecord *r = p->pack();
- if (r)
- {
- db.writeRecord(r);
- delete r;
- }
- delete p;
- ++it;
- ++count;
- }
-
- return 0;
-}
diff --git a/kpilot/tests/importdatebook.cc b/kpilot/tests/importdatebook.cc
deleted file mode 100644
index ebbb70122..000000000
--- a/kpilot/tests/importdatebook.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-/* testaddresses KPilot
-**
-** Copyright (C) 2006 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to address database handling.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include <libkcal/calendar.h>
-#include <libkcal/calendarlocal.h>
-
-#include "pilot.h"
-#include "pilotDateEntry.h"
-#include "pilotLocalDatabase.h"
-#include "../conduits/vcalconduit/kcalRecord.cc"
-#include "../conduits/vcalconduit/vcalRecord.cc"
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- {"vcal-file <path>","Set vcal file", 0},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("importdatebook","Import Date Book","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-
- TQString datadir = args->getOption("data-dir");
- TQString vcalfile = args->getOption("vcal-file");
-
- if (datadir.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a data-directory." << endl;
- }
- if (vcalfile.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a vcal-file to read." << endl;
- }
- if (datadir.isEmpty() || vcalfile.isEmpty())
- {
- return 1;
- }
-
- DEBUGKPILOT << "Using vcal-file: [" << vcalfile
- << "], creating DatebookDB in: [" << datadir
- << "]" << endl;
-
- KCal::CalendarLocal *calendar = new KCal::CalendarLocal( TQString::fromLatin1("UTC") );
- if (!calendar || !calendar->load( vcalfile ))
- {
- return 1;
- }
-
- DEBUGKPILOT << "Opened calendar with: ["
- << calendar->incidences().count() << "] incidences." << endl;
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- PilotLocalDatabase db( datadir, "DatebookDB" );
- db.createDatabase( 0xdead, 0xbeef );
- PilotDateInfo appInfo(0L);
- appInfo.resetToDefault();
- appInfo.writeTo(&db);
-
- KCal::Event::List events = calendar->events();
-
- for (KCal::Event::List::ConstIterator i = events.begin();
- i != events.end(); ++i)
- {
- PilotDateEntry * d = new PilotDateEntry();
-
- const KCal::Event *e = *i;
- DEBUGKPILOT << "event: [" << e->summary() << "]" << endl;
-
- if (KCalSync::setDateEntry(d,e,*appInfo.categoryInfo()))
- {
-DEBUGKPILOT << "got here." << endl;
- PilotRecord *r = d->pack();
- if (r)
- {
- db.writeRecord(r);
- delete r;
- }
- }
- }
-
- return 0;
-}
-
diff --git a/kpilot/tests/main.cc b/kpilot/tests/main.cc
deleted file mode 100644
index c6ddd23c9..000000000
--- a/kpilot/tests/main.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-
-int main( int argc, char **argv)
-{
- CppUnit::TestFactoryRegistry &registry =
- CppUnit::TestFactoryRegistry::getRegistry();
-
- CppUnit::TextUi::TestRunner runner;
- runner.addTest( registry.makeTest() );
-
- // Run the tests.
- bool wasSucessful = runner.run();
-
- // Return error code 1 if the one of test failed.
- return wasSucessful ? 0 : 1;
-}
diff --git a/kpilot/tests/mergecalendars.cc b/kpilot/tests/mergecalendars.cc
deleted file mode 100644
index 898eb8c06..000000000
--- a/kpilot/tests/mergecalendars.cc
+++ /dev/null
@@ -1,228 +0,0 @@
-/* mergecalendars KPilot
-**
-** Copyright (C) 2007 by Jason 'vanRijn' Kasper <vR@movingparts.net)
-**
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-#include <kconfigskeleton.h>
-
-#include <libkcal/calendar.h>
-#include <libkcal/calendarlocal.h>
-
-#include "options.h"
-
-static const KCmdLineOptions options[] =
-{
- {"korgfile <path>","KOrganizer master file", 0},
- {"newfile <path>","Calendar file to merge into korganizer", 0},
- {"category <string>","Category to remove from 'korgfile' and to add to events in 'newfile' for synch purposes", 0},
- {"verbose", "Verbose debugging", 0},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
-
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("mergecalendars","Merge libkcal Calendars","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
- int debug_level= (args->isSet("verbose")) ? 4 : 0;
-
- TQString korgfile = args->getOption("korgfile");
- TQString newfile = args->getOption("newfile");
- TQString category = args->getOption("category");
-
- if (korgfile.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a korganizer file." << endl;
- }
- if (newfile.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a newfile file." << endl;
- }
- if (category.isEmpty())
- {
- WARNINGKPILOT << "! Must provide a category to use." << endl;
- }
- if (korgfile.isEmpty() || newfile.isEmpty() || category.isEmpty())
- {
- return 1;
- }
-
- TQString korgsave = TQString("%1.updated").arg(korgfile);
- TQString newfilesave = TQString("%1.updated").arg(newfile);
-
- DEBUGKPILOT << "Using korgfile: [" << korgfile
- << "]" << endl;
- DEBUGKPILOT << "Using newfile: [" << newfile
- << "]" << endl;
- DEBUGKPILOT << "Will save korgfile to: [" << korgsave
- << "]" << endl;
- DEBUGKPILOT << "Will save newfile to: [" << newfilesave
- << "]" << endl << endl;
-
- KCal::CalendarLocal *calkorg = new KCal::CalendarLocal( TQString::fromLatin1("UTC") );
- KCal::CalendarLocal *calnew = new KCal::CalendarLocal( TQString::fromLatin1("UTC") );
- if (!calkorg || !calnew)
- {
- WARNINGKPILOT << "Unable to create base calendar objects." << endl;
- return 1;
- }
-
- if (!calkorg->load(korgfile) || !calnew->load(newfile))
- {
- WARNINGKPILOT << "Unable to load calendar files." << endl;
- return 1;
- }
-
- int numkorgstart = calkorg->incidences().count();
- int numnewstart = calnew->incidences().count();
-
- DEBUGKPILOT << " - Opened korganizer calendar with: ["
- << numkorgstart << "] incidences." << endl;
- DEBUGKPILOT << " - Opened newfile calendar with: ["
- << numnewstart << "] incidences." << endl;
-
- KCal::Event::List korgEvents;
- KCal::Event::List::ConstIterator korgIt;
- korgEvents = calkorg->events();
- korgEvents.setAutoDelete(false);
-
- KCal::Event::List newEvents;
- KCal::Event::List::ConstIterator newIt;
- newEvents = calnew->events();
- newEvents.setAutoDelete(false);
-
- DEBUGKPILOT << "Looking for previous pilot ids for exchange events..." << endl;
-
- // iterate through all events and try to find a korganizer event
- // that matches up with this external event's UID
- unsigned int numkorgpilotids = 0;
- KCal::Event *ev = 0;
- for (newIt = newEvents.begin(); newIt != newEvents.end(); ++newIt )
- {
- ev = *newIt;
- TQString uid = ev->uid();
- if (debug_level)
- DEBUGKPILOT << " - Looking at event: ["
- << ev->summary() << "], uid: ["
- << uid << "]" << endl;
-
- KCal::Event * evkorg = calkorg->event(uid);
- if ( evkorg && (evkorg->pilotId() > 0) )
- {
- unsigned long pilotId = evkorg->pilotId();
-
- if (debug_level)
- DEBUGKPILOT << "Found korg event for uid: ["
- << uid << "], pilotId: ["
- << pilotId << "]" << endl;
-
- ev->setPilotId(pilotId);
- ev->setSyncStatus(KCal::Incidence::SYNCMOD);
-
- ++numkorgpilotids;
- }
- }
-
- DEBUGKPILOT << "Matched: [" << numkorgpilotids << "] events."<< endl;
-
- DEBUGKPILOT << "Now searching for previous events of category: [" << category << "] in korganizer's calendar." << endl;
-
- // iterate through all events and try to find a korganizer event
- // that matches up with this external event's UID
- unsigned int numkorgremoved = 0;
-
- TQString categoryToken = category;
-
- // careful iterating and removing...
- KCal::Event *next = 0;
-
- korgIt = korgEvents.begin();
- for ( ev = *korgIt; ev != 0; ev = next )
- {
- if (++korgIt == korgEvents.end())
- {
- next = 0;
- }
- else
- {
- next = *korgIt;
- }
-
- if (ev->categoriesStr().contains(categoryToken))
- {
- if (debug_level)
- DEBUGKPILOT << " - Found matching event: ["
- << ev->summary() << "], uid: ["
- << ev->uid() << "]. Removing." << endl;
-
- korgEvents.remove(ev);
- calkorg->deleteEvent(ev);
-
- ++numkorgremoved;
- }
- }
-
- DEBUGKPILOT << " - Found: [" << numkorgremoved
- << "] prior: [" << categoryToken
- << "] category events." << endl;
-
- DEBUGKPILOT << "Merging new events into korganizer calendar..."
- << endl;
-
- for (newIt = newEvents.begin(); newIt != newEvents.end(); ++newIt )
- {
- ev = *newIt;
- ev->setCategories(category);
- korgEvents.append(ev);
- calkorg->addEvent(ev);
- }
-
- DEBUGKPILOT << "Ended up with: [" << korgEvents.count()
- << "] events in korganizer calendar." << endl;
-
- DEBUGKPILOT << "Saving updated korganizer file..." << endl;
- calkorg->save(korgsave);
-
- DEBUGKPILOT << "Saving updated newfile file..." << endl;
- calnew->save(newfilesave);
-
- return 0;
-}
-
diff --git a/kpilot/tests/testactions.cc b/kpilot/tests/testactions.cc
deleted file mode 100644
index 51cb23685..000000000
--- a/kpilot/tests/testactions.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/* testactions KPilot
-**
-** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to sync actions.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-#include "syncAction.h"
-
-bool run_modes(bool test, bool local)
-{
- bool ok = true;
-
- kdDebug() << "***\n*** Sync Modes ("
- << ( test ? "" : "no")
- << "test, "
- << ( local ? "" : "no")
- << "local)\n***\n";
-
-
- for (int m = (int)SyncAction::SyncMode::eHotSync;
- m <= (int) SyncAction::SyncMode::eRestore ;
- m++)
- {
- SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
- kdDebug() << "* " << mode.name() << endl;
- SyncAction::SyncMode mode2(mode.list());
- if (!(mode==mode2)) {
- kdDebug() << "E " << "Modes mismatch [" << mode.name() << "] ["
- << mode2.name() << "]" << endl;
- ok = false;
- }
- }
-
- return ok;
-}
-
-bool single_mode(int m, bool test, bool local)
-{
- SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
-
- kdDebug() << "* " << m << " " << test << " " << local << endl;
-
- if ((mode.mode() == m) && (mode.isTest() == test) && (mode.isLocal() == local))
- {
- return true;
- }
- else
- {
- kdDebug() << "E " << "Modes mismatch " << m << " " << test << " " << local
- << "[" << mode.name() << "]" << endl;
- return false;
- }
-}
-
-int main(int argc, char **argv)
-{
- if (!run_modes(false,false)) return 1;
- if (!run_modes(false,true)) return 1;
- if (!run_modes(true,false)) return 1;
- if (!run_modes(true,true)) return 1;
-
- kdDebug() << "***\n*** Sync Modes - misc\n***\n";
- if (!single_mode(3,false,false)) return 1;
- if (!single_mode(1,true,true)) return 1;
-
- return 0;
-}
-
-
diff --git a/kpilot/tests/testaddress.cc b/kpilot/tests/testaddress.cc
deleted file mode 100644
index 5da0c4474..000000000
--- a/kpilot/tests/testaddress.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/* testaddresses KPilot
-**
-** Copyright (C) 2006 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to address database handling.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include "pilot.h"
-#include "pilotAddress.h"
-#include "pilotLocalDatabase.h"
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("testaddress","Test Addresses","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
-#ifdef DEBUG
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-#endif
- TQString datadir = args->getOption("data-dir");
-
- DEBUGKPILOT << "### testaddresses\n#\n#" << endl;
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- PilotLocalDatabase db( datadir, "AddressDB" );
- PilotAddressInfo appinfo( &db );
-
- appinfo.dump();
-
- for (unsigned int i=0; i<db.recordCount(); ++i)
- {
- PilotRecord *r = db.readRecordByIndex( i );
-
- if (r)
- {
- DEBUGKPILOT << "# Record @" << (void *)r << " ID=" << r->id() << endl;
- PilotAddress a( r );
- DEBUGKPILOT << "# Text Representation:" << endl << a.getTextRepresentation(&appinfo,Qt::PlainText) << endl;
- DEBUGKPILOT << "# Category#" << a.category() << endl;
- DEBUGKPILOT << "# Category Label " << appinfo.categoryName(a.category()) << endl;
- DEBUGKPILOT << "# ID " << a.id() << endl;
-
- // With the given address database, where all the
- // categories are already filled, this should fail
- // (and give a useful error message).
- //
- a.setCategory( appinfo.findCategory(CSL1("Fake Cat")) );
- DEBUGKPILOT << "# Category#" << a.category() << endl;
- DEBUGKPILOT << "# Category Label " << appinfo.categoryName(a.category()) << endl;
- // This category exists, so it should succeed
- //
- a.setCategory( appinfo.findCategory(CSL1("Business")) );
- DEBUGKPILOT << "# Category#" << a.category() << endl;
- DEBUGKPILOT << "# Category Label " << appinfo.categoryName(a.category()) << endl;
- }
- }
-
- return 0;
-}
-
diff --git a/kpilot/tests/testcategories.cc b/kpilot/tests/testcategories.cc
deleted file mode 100644
index aefb8b944..000000000
--- a/kpilot/tests/testcategories.cc
+++ /dev/null
@@ -1,215 +0,0 @@
-/* testcategories KPilot
-**
-** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to category handling.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include "pilotLocalDatabase.h"
-#include "pilotRecord.h"
-#include "pilotAppInfo.h"
-
-// Name of a bogus broken DB
-#define BOGUS_NAME "bogus"
-
-// Name of an actual DB
-#define MEMO_NAME "MemoDB"
-
-TQStringList categories( const PilotAppInfoBase *appinfo )
-{
- TQStringList cats;
-
- for (unsigned int i=0; i<Pilot::CATEGORY_COUNT; i++)
- {
- TQString cat = appinfo->categoryName(i);
- if (!cat.isEmpty())
- {
- TQString s = CSL1("(%1:%2)").arg(i).arg(cat);
- cats.append(s);
- }
- }
-
- return cats;
-}
-
-TQStringList listCategories( const TQString &dir, const char *dbname )
-{
- TQStringList cats;
- PilotLocalDatabase *database = new PilotLocalDatabase( dir, dbname );
- if (!database->isOpen()) return cats;
-
- PilotAppInfoBase *appinfo = new PilotAppInfoBase( database );
- appinfo->dump();
-
- cats = categories( appinfo );
-
- delete appinfo;
- delete database;
- return cats;
-}
-
-void badAppInfoCreation()
-{
- FUNCTIONSETUP;
- PilotAppInfoBase *appinfo = new PilotAppInfoBase( 0L );
- appinfo->dump();
- KPILOT_DELETE( appinfo ) ;
-
- PilotLocalDatabase *database = new PilotLocalDatabase( BOGUS_NAME );
- appinfo = new PilotAppInfoBase( database );
- appinfo->dump();
- KPILOT_DELETE( appinfo );
-}
-
-void categoryNames( const TQString &dir )
-{
- PilotLocalDatabase *database = new PilotLocalDatabase( dir, MEMO_NAME );
- if (!database->isOpen())
- {
- WARNINGKPILOT << "Can not open database '" << MEMO_NAME << "'" << endl;
- return;
- }
-
- PilotAppInfoBase *appinfo = new PilotAppInfoBase( database );
- appinfo->dump();
-
- DEBUGKPILOT << "# Done dumping" << endl;
-
- if (!appinfo->categoryInfo())
- {
- WARNINGKPILOT << "Could not read required database" << endl;
- return;
- }
-
- const char *funnyname = "OneTwoThreeFourFiveSixSevenEight";
- const int funnyname_length = strlen(funnyname);
-
- if (funnyname_length < 20)
- {
- WARNINGKPILOT << "String of example category names is too short." << endl;
- return;
- }
-
- DEBUGKPILOT << "# Updating category names with various lengths." << endl;
- DEBUGKPILOT << "# Expect three truncation errors and two bad category numbers." << endl;
- for (unsigned int i=0; i<Pilot::CATEGORY_COUNT+2; i++)
- {
- TQString name = TQString::fromLatin1(funnyname+funnyname_length-i-3);
- if (!appinfo->setCategoryName(i,name))
- {
- WARNINGKPILOT << "Failed to set category " << i << " name to <" << name << ">" << endl;
- }
- else
- {
- TQString categoryname = appinfo->categoryName(i);
- if (categoryname != name)
- {
- WARNINGKPILOT << "Category name " << i
- << " set to <" << name
- << "> and returns <"
- << categoryname << ">" << endl;
- }
- }
- }
-
- DEBUGKPILOT << "# Final categories\n# " << categories( appinfo ).join("\n# ") << endl;
-}
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- KCmdLineLastOption
-};
-
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("testcategories","Test Categories","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
-#ifdef DEBUG
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-#endif
-
- Q_UNUSED(argc);
- Q_UNUSED(argv);
-
- static const char *files[] = {
- MEMO_NAME,
- "AddressDB",
- "MailDB",
- "ToDoDB",
- 0L
- };
-
- TQString datadir = args->getOption("data-dir");
-
- DEBUGKPILOT << "### testcategories\n#\n#" << endl;
- DEBUGKPILOT << "# Listing categories from database files.\n#" << endl;
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- // Include arbitrary break-off point, in case
- for (unsigned int i = 0; i<sizeof(files)/sizeof(const char *) ; i++)
- {
- if (!files[i])
- {
- break;
- }
- DEBUGKPILOT << "# Categories (" << files[i] << "): " << endl;
- DEBUGKPILOT << "# " << listCategories( datadir, files[i] ).join("\n# ") << "\n#\n";
- }
- // Should bail, not crash
- DEBUGKPILOT << "# Categories (nonexistent): " << endl;
- (void) listCategories( datadir, "nonexistent" );
-
- DEBUGKPILOT << "# Categories (bogus): " << endl;
- (void) listCategories( datadir, BOGUS_NAME );
-
- DEBUGKPILOT << "#\n# Trying to pass broken pointers to category functions.\n# Four errors are expected.\n#" << endl;
- badAppInfoCreation();
-
- DEBUGKPILOT << "#\n# Checking category names." << endl;
- categoryNames( datadir );
-
- DEBUGKPILOT << "# OK.\n" << endl;
- return 0;
-}
-
diff --git a/kpilot/tests/testconstants.cc b/kpilot/tests/testconstants.cc
deleted file mode 100644
index 06e9fafa8..000000000
--- a/kpilot/tests/testconstants.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/* testconstants KPilot
-**
-** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
-**
-** Checks that various data structures are sized properly.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include "pilot.h"
-#include "pilotAppInfo.h"
-
-#include <pi-appinfo.h>
-
-int main(int, char **)
-{
-#ifdef DEBUG
- debug_level = 1;
-#endif
- PilotAppInfoBase info;
-
-
- DEBUGKPILOT << "### testconstants\n#" << endl;
- DEBUGKPILOT << "# Sizes of structures\n#" << endl;
- DEBUGKPILOT << "# AppInfoBase: " << sizeof(PilotAppInfoBase) << endl;
- DEBUGKPILOT << "# CategoryInfo: " << sizeof(info.categoryInfo()) << endl;
- DEBUGKPILOT << "# CategoryInfo: " << sizeof(*info.categoryInfo()) << endl;
- DEBUGKPILOT << "# Category names: " << sizeof(info.categoryInfo()->name) << endl;
- DEBUGKPILOT << "# Single category: " << sizeof(info.categoryInfo()->name[0]) << endl;
-
- DEBUGKPILOT << "#\n# Sanity checking structure sizes\n#" << endl;
- if ( sizeof(info.categoryInfo()->name[0]) != Pilot::CATEGORY_SIZE )
- {
- WARNINGKPILOT << "! Category names are not 16 bytes." << endl;
- return 1;
- }
- if ( sizeof(info.categoryInfo()->name) / sizeof(info.categoryInfo()->name[0]) != Pilot::CATEGORY_COUNT )
- {
- WARNINGKPILOT << "! There are not " << Pilot::CATEGORY_COUNT << " categories available." << endl;
- return 1;
- }
-
- DEBUGKPILOT << "# OK.\n" << endl;
- return 0;
-}
-
-
diff --git a/kpilot/tests/testdatabase.cc b/kpilot/tests/testdatabase.cc
deleted file mode 100644
index 02b43c6be..000000000
--- a/kpilot/tests/testdatabase.cc
+++ /dev/null
@@ -1,316 +0,0 @@
-/* testdatabase KPilot
-**
-** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to local databases.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include "pilotLocalDatabase.h"
-#include "pilotRecord.h"
-#include "pilotMemo.h"
-
-
-/* Return values for the various check* functions. They
- return OK if all is OK; ERR is for generic errors.
- ERR_NO_EXIST is returned if something (usually a database
- or other file) doesn't exist that should. The latter
- error might be ignored.
-*/
-#define OK (0)
-#define ERR (1)
-#define ERR_NO_EXIST (2)
-
-
-/* Data about the records in a database. The id field is
- interpreted specially for the first and last entries.
-*/
-typedef struct { int id,size; } recordInfo;
-
-/* Use END in the last recordInfo struct describing a database
- to indicate you expect the database to end there. Use NO_EXIST
- as the ID in the first struct to indicate that the database
- is expected _not_ to exist.
-*/
-#define NO_EXIST (-2)
-#define END (-1)
-
-/* These tables of data are taken from various databases I have
- (but which I cannot commit to SVN due to license issues).
- The aesop listing is from an eBook of Aesop's fables.
- The way to create these tables is to use a third-party
- tool such as par to read the database:
-
- ./par l /tmp/Aesop.pdb | awk '{print "{",$3,",",$4,"},";}'
-
-*/
-recordInfo nonexistent[] = {
- { NO_EXIST, 0 }
-} ;
-
-recordInfo aesop[] = {
-{ 7307264 , 214 },
-{ 7307265 , 1564 },
-{ 7307266 , 1575 },
-{ 7307267 , 2214 },
-{ 7307268 , 2276 },
-{ 7307269 , 2148 },
-{ 7307270 , 2194 },
-{ 7307271 , 2178 },
-{ 7307272 , 2220 },
-{ 7307273 , 2216 },
-{ 7307274 , 2181 },
-{ 7307275 , 2183 },
-{ 7307276 , 2197 },
-{ 7307277 , 2010 },
-{ 7307278 , 2198 },
-{ 7307279 , 2196 },
-{ 7307280 , 2243 },
-{ 7307281 , 2211 },
-{ 7307282 , 2274 },
-{ 7307283 , 364 },
-{ 7307284 , 49124 },
- { END, 0 }
-} ;
-
-int checkDatabase(const char *path, recordInfo *info)
-{
- FUNCTIONSETUP;
-
- PilotLocalDatabase db(TQString::fromLatin1(path));
- if (!db.isOpen())
- {
- kdDebug() << "No database " << path << endl;
- if ( info[0].id == NO_EXIST )
- {
- kdDebug() << "This was expected" << endl;
- return OK;
- }
- else
- {
- return ERR_NO_EXIST;
- }
- }
-
- if ( info[0].id == NO_EXIST )
- {
- kdDebug() << "Database not expected" << endl;
- return ERR;
- }
-
- int fail = 0;
- int index = 0;
- PilotRecord *r;
- while( (r = db.readRecordByIndex(index) ) )
- {
- kdDebug() << "[" << index << "] id=" << r->id() << " size=" << r->size() << endl;
- if ( ((recordid_t)info[index].id) != r->id() )
- {
- kdDebug() << "* Bad ID (expected" << r->id() << ")" << endl;
- fail++;
- }
- else if ( info[index].size != r->size() )
- {
- kdDebug() << "* Bad size (expected " << info[index].size << ")" << endl;
- fail++;
- }
- index++;
- }
- if ( info[index].id != END )
- {
- kdDebug() << "* End wasn't expected yet." << endl;
- r++;
- }
-
- if (fail)
- {
- kdDebug() << "* " << fail << " failures." << endl;
- return ERR;
- }
- return OK;
-}
-
-const char *categoryNames[4] =
-{
- "aardvarks",
- "toolongToBeaCategoryName",
- "personal",
- "impersonal"
-} ;
-
-TQStringList listCategories()
-{
- TQStringList cats;
- PilotLocalDatabase *l = new PilotLocalDatabase("./data/MemoDB");
- PilotMemoInfo *m = new PilotMemoInfo(l);
-
- if (!l->isOpen()) return cats;
-
- cats.append(CSL1("Unfiled"));
- m->dump();
-
- for (int i=0; i<20; i++)
- {
- PilotRecord *r = l->readRecordByIndex(i);
- kdDebug() << "Read record " << (void *)r << " with id=" << r->id() << endl;
- if (!r) break;
- }
-
- for (int i=0; i<4; i++)
- {
- TQString s = m->category(i);
- kdDebug() << "Category " << i << ": " << (s.isEmpty() ? CSL1("<empty>") : s) << endl;
- cats.append(s);
-/*
- if (i<((sizeof(categoryNames) / sizeof(categoryNames[0]))))
- m->setCategoryName(i,TQString::fromLatin1(categoryNames[i]));
-*/
- }
-
- m->write(l);
-
- delete m;
- delete l;
-
- return cats;
-}
-
-int checkCategories()
-{
- TQStringList l = listCategories();
- TQStringList m = listCategories();
-
- if (l.isEmpty() || m.isEmpty()) return ERR;
- if (l!=m) return ERR;
- return OK;
-}
-
-int checkMemo()
-{
- PilotLocalDatabase *l = new PilotLocalDatabase("./data/MemoDB");
- if (!l->isOpen()) return ERR_NO_EXIST;
-
- PilotMemoInfo *m = new PilotMemoInfo(l);
- m->dump();
-
- TQString c = m->category(1);
- if (c != CSL1("Business"))
- {
- kdDebug() << "* Category 1 is not 'Business' but " << c << endl;
- return ERR;
- }
-
- m->setCategoryName(2,CSL1("Aardvark"));
- m->dump();
-
- c = m->category(2);
- if (c != CSL1("Aardvark"))
- {
- kdDebug() << "* Category 2 is not 'Aardvark' but " << c << endl;
- return ERR;
- }
-
-
- delete m;
- delete l;
- return OK;
-}
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- KCmdLineLastOption
-};
-
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("testdatabase","Test Databases","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
- Q_UNUSED(args)
-
- int r = 0;
- int i = 0;
-#ifdef DEBUG
- debug_level=4;
-#endif
-
- Q_UNUSED(argc);
- Q_UNUSED(argv);
-
-#define ALLOW_NO_EXIST (1)
- static struct { const char *path; recordInfo *info; int flags; }
- tests[] =
- {
- { "/tmp/nonexistant/nonexistent", nonexistent,0 },
- { "/tmp/Aesop", aesop, ALLOW_NO_EXIST },
- { 0L, 0L, 0 }
- } ;
-
- while ( tests[i].path )
- {
- kdDebug() << "*** Test " << i << endl;
- int ret = checkDatabase( tests[i].path, tests[i].info );
- if ( ret )
- {
- if ( (ret==ERR_NO_EXIST) &&
- (tests[i].flags & ALLOW_NO_EXIST) )
- {
- kdDebug() << "* Test database doesn't exist, ignored." << endl;
- }
- else
- {
- r++;
- }
- }
- i++;
- }
-
- kdDebug() << "*** Test " << i << endl;
- if (checkMemo()) r++;
- i++;
-
- if (r)
- {
- kdDebug() << "***\n*** Failed " << r << " tests." << endl;
- return 1;
- }
- return 0;
-}
-
diff --git a/kpilot/tests/testdatebook.cc b/kpilot/tests/testdatebook.cc
deleted file mode 100644
index 8e6cc5569..000000000
--- a/kpilot/tests/testdatebook.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-/* testaddresses KPilot
-**
-** Copyright (C) 2006 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to address database handling.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kdebug.h>
-#include <klocale.h>
-#include <kcmdlineargs.h>
-
-#include "pilot.h"
-#include "pilotDateEntry.h"
-#include "pilotLocalDatabase.h"
-
-static const KCmdLineOptions options[] =
-{
- {"verbose", "Verbose output", 0},
- {"data-dir <path>","Set data directory", "."},
- KCmdLineLastOption
-};
-
-
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
-
- KAboutData aboutData("testdatebook","Test Date Book","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
- KCmdLineArgs::addCmdLineOptions( options );
-
- KApplication app( false, false );
-
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
-#ifdef DEBUG
- debug_level= (args->isSet("verbose")) ? 4 : 0;
-#endif
- TQString datadir = args->getOption("data-dir");
-
- DEBUGKPILOT << "### testdatebook\n#\n#" << endl;
-
- Pilot::setupPilotCodec( CSL1("Latin1") );
-
- PilotLocalDatabase db( datadir, "DatebookDB" );
- PilotDateInfo appinfo( &db );
-
- for (unsigned int i=0; i<db.recordCount(); ++i)
- {
- PilotRecord *r = db.readRecordByIndex( i );
-
- if (r)
- {
- DEBUGKPILOT << "# Record @" << (void *)r << " ID=" << r->id() << endl;
- PilotDateEntry a( r );
- DEBUGKPILOT << "# Text Representation:" << endl << a.getTextRepresentation(Qt::PlainText) << endl;
- DEBUGKPILOT << "# Category#" << a.category() << endl;
- DEBUGKPILOT << "# Category Label " << appinfo.categoryName(a.category()) << endl;
- DEBUGKPILOT << "# ID " << a.id() << endl;
- int cat = appinfo.findCategory( CSL1("Fake Cat") );
- a.setCategory( cat );
- DEBUGKPILOT << "# Category#" << a.category() << endl;
- DEBUGKPILOT << "# Category Label " << appinfo.categoryName(a.category()) << endl;
- }
- }
-
- return 0;
-}
-
diff --git a/kpilot/tests/testidmapper.cc b/kpilot/tests/testidmapper.cc
deleted file mode 100644
index 8d60afc5b..000000000
--- a/kpilot/tests/testidmapper.cc
+++ /dev/null
@@ -1,314 +0,0 @@
-/* testactions KPilot
-**
-** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
-**
-** Test the functions related to sync actions.
-*/
-
-/*
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program in a file called COPYING; if not, write to
-** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-** MA 02110-1301, USA.
-*/
-
-/*
-** Bug reports and questions can be sent to kde-pim@kde.org
-*/
-
-#include "idmapper.h"
-#include "options.h"
-
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kcmdlineargs.h>
-
-#include <tqdir.h>
-#include <tqfile.h>
-
-#define TESTFILE "Testing/mapping.xml"
-#define CONDUIT CSL1("knotes")
-
-/**
- * If the file does not exist it should be created by the idmapper.
- */
-bool test1()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
-
- delete mapper;
- mapper = 0l;
-
- TQFile f( TESTFILE );
- bool result = f.exists();
-
- if( result )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- return result;
-}
-
-/**
- * Test if a uid gets added when it's registered.
- */
-bool test2()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
- mapper->registerPCObjectId( CONDUIT, CSL1("testuid-1") );
-
- delete mapper;
- mapper = 0l;
-
- // Creating a new mapper ensures that the file is readed. So we know if this
- // test passess that the data is saved and readed from the xml file correctly.
- mapper = new IDMapper( TESTFILE );
-
- bool result1 = ( mapper->getPCObjectIds( CONDUIT ).size() == 1 );
- bool result2 = false;
-
- if( result1 )
- result2 = ( mapper->getPCObjectIds( CONDUIT ).first() == "testuid-1" );
-
-
- if( result1 && result2 )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": " << result1 << " " << result2 << endl;
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- delete mapper;
- mapper = 0l;
-
- return (result1 && result2);
-}
-
-/**
- * Set the pid for uid "testuid-1". getHHObjectIds should return 1 item now and
- * that should be the same as the one which is set.
- */
-bool test3()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
- mapper->setHHObjectId( CONDUIT, "testuid-1", 100 );
-
- delete mapper;
- mapper = 0l;
-
- // Creating a new mapper ensures that the file is readed. So we know if this
- // test passess that the data is saved and readed from the xml file correctly.
- mapper = new IDMapper( TESTFILE );
-
- bool result1 = ( mapper->getHHObjectIds( CONDUIT ).size() == 1 );
- bool result2 = false;
-
- if( result1 )
- result2 = ( mapper->getHHObjectIds( CONDUIT ).first() == 100 );
-
-
- if( result1 && result2 )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": " << result1 << " " << result2 << endl;
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- delete mapper;
- mapper = 0l;
-
- return (result1 && result2);
-}
-
-/**
- * Test if a pid is stored correctly when it's registered.
- */
-bool test4()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
- mapper->registerHHObjectId( CONDUIT, 150 );
-
- delete mapper;
- mapper = 0l;
-
- // Creating a new mapper ensures that the file is readed. So we know if this
- // test passess that the data is saved and readed from the xml file correctly.
- mapper = new IDMapper( TESTFILE );
-
- // We have two pids registered at this moment
- bool result1 = ( mapper->getHHObjectIds( CONDUIT ).size() == 2 );
- bool result2 = false;
-
- // This prevents the test from chrashing when getHHObjectIds.size is 0.
- if( result1 )
- result2 = ( mapper->getHHObjectIds( CONDUIT ).contains( 150 ) );
-
- if( result1 && result2 )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": " << result1 << " " << result2 << endl;
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- delete mapper;
- mapper = 0l;
-
- return (result1 && result2);
-}
-
-/**
- * Set the uid for pid 150. getPcObjectIds should return 2 items now and
- * it should contain the one which is just set.
- */
-bool test5()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
- mapper->setPCObjectId( CONDUIT, 150, "testuid-2" );
-
- delete mapper;
- mapper = 0l;
-
- // Creating a new mapper ensures that the file is readed. So we know if this
- // test passess that the data is saved and readed from the xml file correctly.
- mapper = new IDMapper( TESTFILE );
-
- bool result1 = ( mapper->getPCObjectIds( CONDUIT ).size() == 2 );
- bool result2 = false;
-
- if( result1 )
- result2 = ( mapper->getPCObjectIds( CONDUIT ).contains( "testuid-2" ) );
-
-
- if( result1 && result2 )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": " << result1 << " " << result2 << endl;
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- delete mapper;
- mapper = 0l;
-
- return (result1 && result2);
-}
-
-
-/**
- * Test for the hasPCId function.
- */
-bool test6()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
-
- // Should be true (PCId is set to "testuid-2").
- bool result = mapper->hasPCId( CONDUIT, 150 );
-
- delete mapper;
- mapper = 0l;
-
- if( result )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- return result;
-}
-
-/**
- * Test for the hasHHId function.
- */
-bool test7()
-{
- FUNCTIONSETUP;
-
- IDMapper *mapper = new IDMapper( TESTFILE );
-
- // Should be true (HHId is set to "150").
- bool result = mapper->hasHHId( CONDUIT, "testuid-2" );
-
- delete mapper;
- mapper = 0l;
-
- if( result )
- {
- DEBUGKPILOT << fname << ": passed" << endl;
- }
- else
- {
- DEBUGKPILOT << fname << ": failed" << endl;
- }
-
- return result;
-}
-
-int main(int argc, char **argv)
-{
- KApplication::disableAutoDcopRegistration();
- KAboutData aboutData("testidmapper","Test IDMapper","0.1");
- KCmdLineArgs::init(argc,argv,&aboutData);
-
- KApplication app( false, false );
-
- // Remove file from previous test run
- TQDir test( "Testing" );
- if( !test.exists() ) {
- TQDir current;
- current.mkdir( "Testing" );
- }
-
- TQFile f( TESTFILE );
- if( f.exists() )
- TQFile::remove( TESTFILE );
-
- if( test1() && test2() && test3() &&
- test4() && test5() && test6() &&
- test7() )
- return 0;
- else
- return 1;
-}
-
-