• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
qtest_akonadi.h
1 /* This file is based on qtest_kde.h from kdelibs
2  Copyright (C) 2006 David Faure <faure@kde.org>
3  Copyright (C) 2009 Volker Krause <vkrause@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef QTEST_AKONADI_H
21 #define QTEST_AKONADI_H
22 
23 #include <qtest_kde.h>
24 
25 #include <akonadi/agentinstance.h>
26 #include <akonadi/agentmanager.h>
27 #include <klocale.h>
28 
43 #define QTEST_AKONADIMAIN(TestObject, flags) \
44 int main(int argc, char *argv[]) \
45 { \
46  setenv( "LC_ALL", "C", 1); \
47  unsetenv( "KDE_COLOR_DEBUG" ); \
48  KAboutData aboutData( QByteArray( "qttest" ), QByteArray(), ki18n( "KDE Test Program" ), QByteArray( "version" ) ); \
49  KDEMainFlags mainFlags = flags; \
50  KComponentData cData(&aboutData); \
51  QApplication app( argc, argv, (mainFlags & GUI) != 0 ); \
52  app.setApplicationName( QLatin1String( "qttest" ) ); \
53  qRegisterMetaType<KUrl>(); /*as done by kapplication*/ \
54  qRegisterMetaType<KUrl::List>(); \
55  TestObject tc; \
56  KGlobal::ref(); /* don't quit qeventloop after closing a mainwindow */ \
57  return QTest::qExec( &tc, argc, argv ); \
58 }
59 
60 namespace AkonadiTest {
64 void checkTestIsIsolated() {
65  Q_ASSERT_X(!qgetenv("TESTRUNNER_DB_ENVIRONMENT").isEmpty(),
66  "AkonadiTest::checkTestIsIsolated",
67  "This test must be run using ctest, in order to use the testrunner environment. Aborting, to avoid messing up your real akonadi");
68 }
69 
73 void setAllResourcesOffline() {
74  // switch all resources offline to reduce interference from them
75  foreach (Akonadi::AgentInstance agent, Akonadi::AgentManager::self()->instances()) { //krazy:exclude=foreach
76  agent.setIsOnline(false);
77  }
78 }
79 
80 } // namespace
81 
87 #define AKVERIFYEXEC( job ) \
88  QVERIFY2( job->exec(), job->errorString().toUtf8().constData() )
89 
90 // Taken from Qt 5:
91 #if QT_VERSION < 0x050000
92 
93 // Will try to wait for the expression to become true while allowing event processing
94 #define QTRY_VERIFY(__expr) \
95 do { \
96  const int __step = 50; \
97  const int __timeout = 5000; \
98  if ( !( __expr ) ) { \
99  QTest::qWait( 0 ); \
100  } \
101  for ( int __i = 0; __i < __timeout && !( __expr ); __i += __step ) { \
102  QTest::qWait( __step ); \
103  } \
104  QVERIFY( __expr ); \
105 } while ( 0 )
106 
107 // Will try to wait for the comparison to become successful while allowing event processing
108 #define QTRY_COMPARE(__expr, __expected) \
109 do { \
110  const int __step = 50; \
111  const int __timeout = 5000; \
112  if ( ( __expr ) != ( __expected ) ) { \
113  QTest::qWait( 0 ); \
114  } \
115  for ( int __i = 0; __i < __timeout && ( ( __expr ) != ( __expected ) ); __i += __step ) { \
116  QTest::qWait( __step ); \
117  } \
118  QCOMPARE( __expr, __expected ); \
119 } while ( 0 )
120 
121 #endif
122 
123 #endif
Akonadi::AgentInstance::setIsOnline
void setIsOnline(bool online)
Sets online status of the agent instance.
Definition: agentinstance.cpp:100
Akonadi::AgentManager::self
static AgentManager * self()
Returns the global instance of the agent manager.
Definition: agentmanager.cpp:377
Akonadi::AgentInstance
A representation of an agent instance.
Definition: agentinstance.h:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal