mmappfw_plat/mpx_common_api/tsrc/ui_commontestclass/src/testmpxmessagemonitor.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: MPXMessageMonitor testing implementation (mpxmessagemonitor.h)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include <mpxcollectionframeworkdefs.h>
       
    21 
       
    22 #include "commontestclass.h"
       
    23 
       
    24 _LIT(KMPXCollectionServerName,"MPXCollectionServer");
       
    25 _LIT(KMPXCollectionServerImg,"mpxcollectionserver");        // DLL/EXE name
       
    26 // UID
       
    27 const TUid KMPXCollectionServerUid3={0x101FFC31};  
       
    28 // Serverversion number
       
    29 const TUint KMPXCollectionServerMajorVersionNumber=0;
       
    30 const TUint KMPXCollectionServerMinorVersionNumber=1;
       
    31 const TUint KMPXCollectionServerBuildVersionNumber=1;
       
    32 
       
    33 // Begin CMPXMessageMonitor testing implementation (mpxmessagemonitor.h)=======================================
       
    34 // -----------------------------------------------------------------------------
       
    35 // CCommonTestClass::CreateCMPXMessageMonitorL()
       
    36 // Returns: Symbian OS errors.
       
    37 // -----------------------------------------------------------------------------
       
    38 TInt CCommonTestClass::CreateCMPXMessageMonitorL()
       
    39     {
       
    40 	FTRACE(FPrint(_L("CCommonTestClass::CreateCMPXMessageMonitorL testing CMPXMessageMonitor::NewL() begin")));
       
    41     iLog->Log(_L("CCommonTestClass::CreateCMPXMessageMonitorL testing CMPXMessageMonitor::NewL() begin"));
       
    42     TInt err = KErrNone;
       
    43     if ( iMsgMonitor != NULL)
       
    44         {
       
    45         delete iMsgMonitor;
       
    46         }
       
    47     iMsgMonitor = NULL;
       
    48 
       
    49     User::LeaveIfError(
       
    50         iMessageSession.Connect(KMPXCollectionServerName,
       
    51                      KMPXCollectionServerImg,
       
    52                      TVersion(KMPXCollectionServerMajorVersionNumber,
       
    53                      KMPXCollectionServerMinorVersionNumber,
       
    54                      KMPXCollectionServerBuildVersionNumber)));
       
    55     iMessageSession.SendReceiveL(EMcsSetMode,TIpcArgs(KMcModeDefault.iUid));                      
       
    56 
       
    57     iMsgMonitor = CMPXMessageMonitor::NewL(iMessageSession, *this );
       
    58     
       
    59     if ( iMsgMonitor == NULL)
       
    60         {
       
    61         err = KErrNotFound;
       
    62         }
       
    63 	FTRACE(FPrint(_L("CCommonTestClass::CreateCMPXMessageMonitorL testing CMPXMessageMonitor::NewL() end err=%d"), err));
       
    64     iLog->Log(_L("CCommonTestClass::CreateCMPXMessageMonitorL testing CMPXMessageMonitor::NewL() end err=%d"), err);
       
    65 	return err;
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CCommonTestClass::DeleteCMPXMessageMonitorL()
       
    71 // Returns: Symbian OS errors.
       
    72 // -----------------------------------------------------------------------------
       
    73 TInt CCommonTestClass::DeleteCMPXMessageMonitorL()
       
    74     {
       
    75 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCMPXMessageMonitorL testing CMPXMessageMonitorL::~ begin")));
       
    76     iLog->Log(_L("CCommonTestClass::DeleteCMPXMessageMonitorL testing CMPXMessageMonitorL::~ begin"));
       
    77     TInt err = KErrNone;
       
    78     
       
    79     iMsgMonitor->Cancel();
       
    80     delete iMsgMonitor;
       
    81     iMessageSession.Close();
       
    82     iMsgMonitor = NULL;
       
    83     
       
    84 	FTRACE(FPrint(_L("CCommonTestClass::DeleteCMPXMessageMonitorL testing CMPXMessageMonitorL::~ end=%d"), err));
       
    85     iLog->Log(_L("CCommonTestClass::DeleteCMPXMessageMonitorL testing CMPXMessageMonitorL::~ end=%d"), err);
       
    86 	return err;
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CCommonTestClass::RunLCMPXMessageMonitorL()
       
    92 // Returns: Symbian OS errors.
       
    93 // -----------------------------------------------------------------------------
       
    94 TInt CCommonTestClass::RunLCMPXMessageMonitorL()
       
    95     {
       
    96 	FTRACE(FPrint(_L("CCommonTestClass::RunLCMPXMessageMonitorL testing CMPXMessageMonitor::RunL begin")));
       
    97     iLog->Log(_L("CCommonTestClass::RunLCMPXMessageMonitorL testing CMPXMessageMonitor::RunL begin"));
       
    98     TInt err = KErrNone;
       
    99 
       
   100     if ( iMsgMonitor != NULL )
       
   101         {
       
   102         iMessageSession.SendReceiveL(EMcsNotifyEvent);                              
       
   103         iMessageSession.SendReceiveL(EMcsGetSupportedTypes);
       
   104     	FTRACE(FPrint(_L("CCommonTestClass::RunLCMPXMessageMonitorL")));
       
   105         iLog->Log(_L("CCommonTestClass::RunLCMPXMessageMonitorL"));
       
   106         }
       
   107     else
       
   108         {
       
   109         err = KErrBadTestParameter;
       
   110     	FTRACE(FPrint(_L("CCommonTestClass::RunLCMPXMessageMonitorL Stif test script is wrong.")));
       
   111         iLog->Log(_L("CCommonTestClass::RunLCMPXMessageMonitorL Stif test script is wrong."));
       
   112         }
       
   113 
       
   114 	FTRACE(FPrint(_L("CCommonTestClass::GetNextMessage testing CMPXMessageMonitor::RunL end err=%d"), err));
       
   115     iLog->Log(_L("CCommonTestClass::GetNextMessage testing CMPXMessageMonitor::RunL end err=%d"), err);
       
   116 	return err;
       
   117     }
       
   118     
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CCommonTestClass::MessageReceived()
       
   122 // Returns: none
       
   123 // -----------------------------------------------------------------------------
       
   124 void CCommonTestClass::MessageReceived(TInt /*aMsgData*/, TInt /*aError*/)
       
   125     {
       
   126     }
       
   127 
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CCommonTestClass::GetNextMessageCMPXMessageMonitorL()
       
   131 // Returns: Symbian OS errors.
       
   132 // -----------------------------------------------------------------------------
       
   133 TInt CCommonTestClass::GetNextMessageCMPXMessageMonitorL()
       
   134     {
       
   135 	FTRACE(FPrint(_L("CCommonTestClass::GetNextMessageCMPXMessageMonitorL testing GetNextMessage begin")));
       
   136     iLog->Log(_L("CCommonTestClass::GetNextMessageCMPXMessageMonitorL testing GetNextMessage begin"));
       
   137     TInt err = KErrNone;
       
   138     iMsgMonitor->GetNextMessage();
       
   139     delete iMsgMonitor;
       
   140     iMessageSession.Close();
       
   141     iMsgMonitor = NULL;
       
   142 	FTRACE(FPrint(_L("CCommonTestClass::GetNextMessageCMPXMessageMonitorL testing GetNextMessage end=%d"), err));
       
   143     iLog->Log(_L("CCommonTestClass::GetNextMessageCMPXMessageMonitorL testing GetNextMessage end=%d"), err);
       
   144 	return err;
       
   145     }
       
   146 // -----------------------------------------------------------------------------
       
   147 // CCommonTestClass::DoCancelCMPXMessageMonitorL()
       
   148 // Returns: Symbian OS errors.
       
   149 // -----------------------------------------------------------------------------
       
   150 TInt CCommonTestClass::DoCancelCMPXMessageMonitorL()
       
   151     {
       
   152     FTRACE(FPrint(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL testing CMPXMessageMonitor::DoCancel begin")));
       
   153     iLog->Log(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL testing CMPXMessageMonitor::DoCancel begin"));
       
   154     TInt err = KErrNone;
       
   155 
       
   156     if ( iMsgMonitor != NULL )
       
   157         {
       
   158         iMessageSession.SendReceiveL(EMcsNotifyEvent);                              
       
   159         iMessageSession.SendReceiveL(EMcsGetSupportedTypes);
       
   160         iMessageSession.SendReceiveL(EMcsCancelGetMessage);
       
   161     	FTRACE(FPrint(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL")));
       
   162         iLog->Log(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL"));
       
   163         }
       
   164     else
       
   165         {
       
   166         err = KErrBadTestParameter;
       
   167     	FTRACE(FPrint(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL Stif test script is wrong.")));
       
   168         iLog->Log(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL Stif test script is wrong."));
       
   169         }
       
   170 
       
   171 	FTRACE(FPrint(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL testing CMPXMessageMonitor::DoCancel end err=%d"), err));
       
   172     iLog->Log(_L("CCommonTestClass::DoCancelCMPXMessageMonitorL testing CMPXMessageMonitor::DoCancel end err=%d"), err);
       
   173 	return err;
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CCommonTestClass::RunErrorCMPXMessageMonitorL()
       
   178 // Returns: Symbian OS errors.
       
   179 // -----------------------------------------------------------------------------
       
   180 TInt CCommonTestClass::RunErrorCMPXMessageMonitorL(   )
       
   181     {
       
   182     FTRACE(FPrint(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL testing CMPXMessageMonitor::RunError begin")));
       
   183     iLog->Log(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL testing CMPXMessageMonitor::RunError begin"));
       
   184     TInt err = KErrNone;
       
   185 
       
   186     if ( iMsgMonitor != NULL )
       
   187         {
       
   188         iMessageSession.SendReceiveL(EMcsNotifyEvent);                              
       
   189         iMessageSession.SendReceiveL(EMcsGetSupportedTypes);
       
   190         iMessageSession.SendReceiveL(EMcsCancelRequest);
       
   191     	FTRACE(FPrint(_L("CCommonTestClass::CMPXMessageMonitorL")));
       
   192         iLog->Log(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL"));
       
   193         }
       
   194     else
       
   195         {
       
   196         err = KErrBadTestParameter;
       
   197     	FTRACE(FPrint(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL Stif test script is wrong.")));
       
   198         iLog->Log(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL Stif test script is wrong."));
       
   199         }
       
   200 
       
   201 	FTRACE(FPrint(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL testing CMPXMessageMonitor::RunError end err=%d"), err));
       
   202     iLog->Log(_L("CCommonTestClass::RunErrorCMPXMessageMonitorL testing CMPXMessageMonitor::RunError end err=%d"), err);
       
   203 	return err;
       
   204     }