[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepimlibs] akonadi/calendar: Add hack to not display dialog when running unit-tests.
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2013-11-01 0:10:32
Message-ID: E1Vc2Js-0001QS-4D () scm ! kde ! org
[Download RAW message or body]

Git commit 700db1e8ce4117beaa461ef7b037ccf25e0b277a by Sergio Martins.
Committed on 31/10/2013 at 23:53.
Pushed by smartins into branch 'master'.

Add hack to not display dialog when running unit-tests.

The dialog in question is the "You're not the organizer, do you
really want to modify event?".

We already have InvitationPolicy which lets us suppress 99% of dialogs,
which are related to sending.

In KDE5 we can remove dialogs or add abstract delegates...

M  +18   -0    akonadi/calendar/incidencechanger.cpp
M  +1    -0    akonadi/calendar/tests/itiphandlertest.cpp

http://commits.kde.org/kdepimlibs/700db1e8ce4117beaa461ef7b037ccf25e0b277a

diff --git a/akonadi/calendar/incidencechanger.cpp \
b/akonadi/calendar/incidencechanger.cpp index f7a28de..7ca07a6 100644
--- a/akonadi/calendar/incidencechanger.cpp
+++ b/akonadi/calendar/incidencechanger.cpp
@@ -38,6 +38,12 @@
 using namespace Akonadi;
 using namespace KCalCore;
 
+#ifdef PLEASE_TEST_INVITATIONS
+# define RUNNING_UNIT_TESTS true
+#else
+# define RUNNING_UNIT_TESTS false
+#endif
+
 ITIPHandlerHelper::Action actionFromStatus( ITIPHandlerHelper::SendResult result )
 {
   //enum SendResult {
@@ -469,6 +475,18 @@ bool IncidenceChanger::Private::handleInvitationsBeforeChange( \
const Change::Ptr  break;
         }
 
+        const bool weAreOrganizer = Akonadi::CalendarUtils::thatIsMe( \
newIncidence->organizer()->email() ); +        if (RUNNING_UNIT_TESTS && \
!weAreOrganizer ) { +          // This is a bit of a workaround when running tests. I \
don't want to show the +          // "You're not organizer, do you want to modify \
event?" dialog in unit-tests, but want +          // to emulate a "yes" and a "no" \
press. +          if ( m_invitationPolicy == InvitationPolicySend ) {
+            return true;
+          } else if (m_invitationPolicy == InvitationPolicyDontSend) {
+            return false;
+          }
+        }
+
         const bool modify = handler.handleIncidenceAboutToBeModified( newIncidence \
);  if ( modify ) {
           break;
diff --git a/akonadi/calendar/tests/itiphandlertest.cpp \
b/akonadi/calendar/tests/itiphandlertest.cpp index 7bc484d..9c8cfff 100644
--- a/akonadi/calendar/tests/itiphandlertest.cpp
+++ b/akonadi/calendar/tests/itiphandlertest.cpp
@@ -643,6 +643,7 @@ void ITIPHandlerTest::onModifyFinished(int changeId, const Item \
&item,  if (m_pendingIncidenceChangerSignal == 0) {
         stopWaiting();
     }
+    kDebug() << "Got result " << resultCode << m_cancelExpected;
     QCOMPARE(resultCode, m_cancelExpected ? IncidenceChanger::ResultCodeUserCanceled
                                           : IncidenceChanger::ResultCodeSuccess);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic