phoneplugins/infowidgetplugin/infowidgetprovider/tsrc/ut_infowidgetsathandlerprivate/src/ut_infowidgetsathandlerprivate.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 40 bab96b7ed1a4
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ut_infowidgetsathandlerprivate.h"
       
    19 #define private public
       
    20 #include "infowidgetsathandlerprivate.h"
       
    21 #include "infowidgetsathandler.h"
       
    22 #include "infowidgetlogging.h"
       
    23 #include "qtestmains60.h"
       
    24 
       
    25 void SimulateLeaveL()
       
    26 {
       
    27     User::Leave(KErrGeneral);
       
    28 }
       
    29 
       
    30 void FillData( HBufC * aText,
       
    31         RSatService::TSatIconQualifier & aIconQualifier,
       
    32         TUint8 & aRecordNumber)
       
    33 {
       
    34     _LIT(KText,"Idle Text");
       
    35     TPtr p(aText->Des());
       
    36     p.Copy(KText);
       
    37     aIconQualifier=RSatService::ESatIconNotSelfExplanatory;
       
    38     aRecordNumber=1;
       
    39 }
       
    40 
       
    41 void FillDataNoIcon( HBufC * aText,
       
    42         RSatService::TSatIconQualifier & aIconQualifier,
       
    43         TUint8 & aRecordNumber)
       
    44 {
       
    45     Q_UNUSED(aIconQualifier);
       
    46     Q_UNUSED(aRecordNumber);
       
    47     _LIT(KText,"Idle Text");
       
    48     TPtr p(aText->Des());
       
    49     p.Copy(KText);
       
    50 }
       
    51 
       
    52 void FillDataSelfExplIcon( HBufC * aText,
       
    53         RSatService::TSatIconQualifier & aIconQualifier,
       
    54         TUint8 & aRecordNumber)
       
    55 {
       
    56     Q_UNUSED(aText);
       
    57     aIconQualifier=RSatService::ESatIconSelfExplanatory;
       
    58     aRecordNumber=1;
       
    59 }
       
    60 
       
    61 /*!
       
    62   UT_InfoWidgetSatHandlerPrivate ::UT_InfoWidgetSatHandlerPrivate 
       
    63  */
       
    64 UT_InfoWidgetSatHandlerPrivate::UT_InfoWidgetSatHandlerPrivate () //:
       
    65 {
       
    66     DPRINT << "IN";
       
    67     
       
    68     m_satHandler = 0;
       
    69     m_iwSatHandler = 0;
       
    70     
       
    71     DPRINT << "OUT";
       
    72 }
       
    73 
       
    74 /*!
       
    75   UT_InfoWidgetSatHandlerPrivate ::~UT_InfoWidgetSatHandlerPrivate 
       
    76  */
       
    77 UT_InfoWidgetSatHandlerPrivate::~UT_InfoWidgetSatHandlerPrivate ()
       
    78 {
       
    79     DPRINT << "IN";
       
    80     
       
    81     delete m_satHandler;
       
    82     delete m_iwSatHandler;
       
    83     
       
    84     DPRINT << "OUT";
       
    85 }
       
    86 
       
    87 /*!
       
    88   UT_InfoWidgetSatHandlerPrivate ::init
       
    89  */
       
    90 void UT_InfoWidgetSatHandlerPrivate::init()
       
    91 {
       
    92     DPRINT << "IN";
       
    93     
       
    94     initialize();
       
    95     m_iwSatHandler = new InfoWidgetSatHandler;
       
    96     m_satHandler =  new InfoWidgetSatHandlerPrivate( m_iwSatHandler, m_satService);
       
    97     
       
    98     QVERIFY(verify());
       
    99 
       
   100     DPRINT << "OUT";
       
   101 }
       
   102 
       
   103 /*!
       
   104   UT_InfoWidgetSatHandlerPrivate ::cleanup
       
   105  */
       
   106 void UT_InfoWidgetSatHandlerPrivate::cleanup()
       
   107 {
       
   108     DPRINT << "IN";
       
   109     
       
   110     reset();
       
   111     delete m_satHandler;
       
   112     delete m_iwSatHandler;
       
   113 
       
   114     DPRINT << "OUT";
       
   115 }
       
   116 
       
   117 /*!
       
   118   UT_InfoWidgetSatHandlerPrivate::t_connect
       
   119  */
       
   120 void UT_InfoWidgetSatHandlerPrivate::t_connect()
       
   121 {
       
   122     DPRINT << "IN";
       
   123     
       
   124     expect("RSatSession::ConnectL");
       
   125     expect("RSatService::OpenL");
       
   126     m_satHandler->connect();
       
   127      
       
   128     expect("RSatSession::ConnectL")
       
   129         .willOnce(invokeWithoutArguments(SimulateLeaveL));
       
   130     m_satHandler->connect();
       
   131     
       
   132     expect("RSatService::OpenL")
       
   133         .willOnce(invokeWithoutArguments(SimulateLeaveL));
       
   134     m_satHandler->connect();
       
   135 
       
   136     QVERIFY(verify());
       
   137 
       
   138     DPRINT << "OUT";
       
   139 }
       
   140 
       
   141 /*!
       
   142   UT_InfoWidgetSatHandlerPrivate::t_disconnect
       
   143  */
       
   144 void UT_InfoWidgetSatHandlerPrivate::t_disconnect()
       
   145 {
       
   146     DPRINT << "IN";
       
   147     
       
   148     m_satHandler->disconnect();
       
   149     QVERIFY(verify());
       
   150 
       
   151     DPRINT << "OUT";
       
   152 }
       
   153 
       
   154 /*!
       
   155   UT_InfoWidgetSatHandlerPrivate::t_startObserving
       
   156  */
       
   157 void UT_InfoWidgetSatHandlerPrivate::t_startObserving()
       
   158 {
       
   159     DPRINT << "IN";
       
   160     
       
   161     int i = KErrGeneral;
       
   162     expect("RSatService::NotifySetupIdleModeTextChange").returns(i);
       
   163     expect("RSatService::GetSetupIdleModeTextL")
       
   164         .willOnce(invoke(FillData));
       
   165     m_satHandler->startObserving();
       
   166     
       
   167     expect("RSatService::NotifySetupIdleModeTextChange").returns(i);
       
   168     expect("RSatService::GetSetupIdleModeTextL")
       
   169         .willOnce(invoke(FillDataNoIcon));
       
   170     m_satHandler->startObserving();
       
   171     
       
   172     expect("RSatService::NotifySetupIdleModeTextChange").returns(i);
       
   173     expect("RSatService::GetSetupIdleModeTextL")
       
   174         .willOnce(invoke(FillDataSelfExplIcon));
       
   175     m_satHandler->startObserving();
       
   176     
       
   177     expect("RSatService::GetSetupIdleModeTextL")
       
   178         .willOnce(invokeWithoutArguments(SimulateLeaveL));
       
   179     m_satHandler->startObserving();
       
   180     
       
   181     QVERIFY(verify());
       
   182 
       
   183     DPRINT << "OUT";
       
   184 }
       
   185 
       
   186 /*!
       
   187   UT_InfoWidgetSatHandlerPrivate::t_runL
       
   188  */
       
   189 void UT_InfoWidgetSatHandlerPrivate::t_runL()
       
   190 {
       
   191     DPRINT << "IN";
       
   192     
       
   193     int i = 1;
       
   194     expect("RSatService::GetSetupIdleModeTextL")
       
   195           .willOnce(invoke(FillData));
       
   196     expect("RSatService::NotifySetupIdleModeTextChange").returns(i);
       
   197     m_satHandler->RunL();
       
   198     
       
   199     m_satHandler->iStatus = KErrGeneral;
       
   200     expect("RSatService::NotifySetupIdleModeTextChange").returns(i);
       
   201     m_satHandler->RunL();
       
   202         
       
   203     QVERIFY(verify());
       
   204 
       
   205     DPRINT << "OUT";
       
   206 }
       
   207 
       
   208 /*!
       
   209   UT_InfoWidgetSatHandlerPrivate::t_doCancel
       
   210  */
       
   211 void UT_InfoWidgetSatHandlerPrivate::t_doCancel()
       
   212 {    
       
   213     DPRINT << "IN";
       
   214 
       
   215     m_satHandler->DoCancel();
       
   216     QVERIFY(verify());
       
   217 
       
   218     DPRINT << "OUT";
       
   219 }
       
   220 
       
   221 QTEST_MAIN_S60(UT_InfoWidgetSatHandlerPrivate )