phoneclientserver/phoneclient/tsrc/public/basic/ut_ussd/ut_cphcltussdnotecontroller.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2010 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: Unit test for satappmainhandler
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QTimer> // timeout callback
       
    19 #include <QEventLoop>
       
    20 
       
    21 #include "ut_cphcltussdnotecontroller.h"
       
    22 #include "cphcltussdcommonconstant.h"
       
    23 //test class
       
    24 #include "cphcltussdnotecontroller.h"
       
    25 //const
       
    26 const int KExtendTimeoutMseconds = 50000;
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // Ut_CphCltUssdNoteController::Ut_CphCltUssdNoteController
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 Ut_CphCltUssdNoteController::Ut_CphCltUssdNoteController(QObject *parent):
       
    33         QObject(parent)
       
    34 {
       
    35     qDebug("Ut_CphCltUssdNoteController::Ut_CphCltUssdNoteController >");
       
    36     qDebug("Ut_CphCltUssdNoteController::Ut_CphCltUssdNoteController <");
       
    37 }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // Ut_CphCltUssdNoteController::~Ut_CphCltUssdNoteController
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 Ut_CphCltUssdNoteController::~Ut_CphCltUssdNoteController()
       
    44 {
       
    45     qDebug("Ut_CphCltUssdNoteController::~Ut_CphCltUssdNoteController >");
       
    46     qDebug("Ut_CphCltUssdNoteController::~Ut_CphCltUssdNoteController <");
       
    47 }
       
    48 
       
    49 
       
    50 void Ut_CphCltUssdNoteController::GlobalWaitNoteHidden()
       
    51 {
       
    52     qDebug("Ut_CphCltUssdNoteController::GlobalWaitNoteHidden >");
       
    53     qDebug("Ut_CphCltUssdNoteController::GlobalWaitNoteHidden <");
       
    54 }
       
    55 // -----------------------------------------------------------------------------
       
    56 // Ut_CphCltUssdNoteController::initTestCase
       
    57 // QTestLib cleanup method, called after the last testfunction .
       
    58 // -----------------------------------------------------------------------------
       
    59 void Ut_CphCltUssdNoteController::initTestCase()
       
    60 {
       
    61     qDebug("Ut_CphCltUssdNoteController::initTestCase >");
       
    62     qDebug("Ut_CphCltUssdNoteController::initTestCase <");
       
    63 }
       
    64 
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // Ut_CphCltUssdNoteController::cleanupTestCase
       
    68 // 
       
    69 // Connects to test object signal and verifies received data.
       
    70 // -----------------------------------------------------------------------------
       
    71 void Ut_CphCltUssdNoteController::cleanupTestCase()
       
    72 {
       
    73     qDebug("Ut_CphCltUssdNoteController::cleanupTestCase >");
       
    74     if (mNoteController) {
       
    75         qDebug("Ut_CphCltUssdNoteController::cleanupTestCase delete \
       
    76             mNoteController");
       
    77         delete mNoteController;
       
    78         mNoteController = 0;
       
    79     }
       
    80     qDebug("Ut_CphCltUssdNoteController::cleanupTestCase <");
       
    81 }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // Ut_CphCltUssdNoteController::testCreateMainHandler
       
    85 // 
       
    86 // Connects to test object signal and verifies received data.
       
    87 // -----------------------------------------------------------------------------
       
    88 void Ut_CphCltUssdNoteController::testCreateMainHandler()
       
    89 {
       
    90     qDebug("Ut_CphCltUssdNoteController::testProfileState >");
       
    91     mNoteController = CPhCltUssdNoteController::NewL(*this);
       
    92     QVERIFY(mNoteController);
       
    93     qDebug("Ut_CphCltUssdNoteController::testProfileState <");
       
    94 }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // Ut_CphCltUssdNoteController::testShowGlobalInformationNote_data
       
    99 // 
       
   100 // Connects to test object signal and verifies received data.
       
   101 // -----------------------------------------------------------------------------
       
   102 void Ut_CphCltUssdNoteController::testShowGlobalInformationNote_data()
       
   103 {
       
   104     qDebug("Ut_CphCltUssdNoteController::testShowGlobalInformationNote_data >");
       
   105     QTest::addColumn<int>("noteType");
       
   106     QTest::newRow("Unconfirme") << 1;
       
   107     QTest::newRow("Notallowed") << 2;
       
   108     QTest::newRow("Noservice") << 3;
       
   109     QTest::newRow("Offline") << 4;
       
   110     QTest::newRow("Done") << 5;
       
   111     QTest::newRow("NotDone") << 6;
       
   112     qDebug("Ut_CphCltUssdNoteController::testShowGlobalInformationNote_data <");
       
   113 }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // Ut_CphCltUssdNoteController::testShowGlobalInformationNote
       
   117 // 
       
   118 // Connects to test object signal and verifies received data.
       
   119 // -----------------------------------------------------------------------------
       
   120 void Ut_CphCltUssdNoteController::testShowGlobalInformationNote()
       
   121 {
       
   122     qDebug("Ut_CphCltUssdNoteController::testShowGlobalInformationNote >");
       
   123     QFETCH(int, noteType);
       
   124     TPhCltUssdInformationType infoType = 
       
   125         static_cast<TPhCltUssdInformationType>(noteType);
       
   126     TRAPD(err,mNoteController->ShowGlobalInformationNoteL(infoType) );
       
   127     QCOMPARE(KErrNone, err);
       
   128     qDebug("Ut_CphCltUssdNoteController::testShowGlobalInformationNote <");
       
   129 }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // Ut_CphCltUssdNoteController::testProfileState
       
   133 // 
       
   134 // Connects to test object signal and verifies received data.
       
   135 // -----------------------------------------------------------------------------
       
   136 void Ut_CphCltUssdNoteController::testShowGlobalWaitNote()
       
   137 {
       
   138     qDebug("Ut_CphCltUssdNoteController::testShowGlobalWaitNote >");
       
   139     QVERIFY(mNoteController);
       
   140     TRAPD(err, mNoteController->ShowGlobalWaitNoteL() );
       
   141     QCOMPARE(KErrNone, err);
       
   142     qDebug("Ut_CphCltUssdNoteController::testShowGlobalWaitNote <");
       
   143 }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // Ut_CphCltUssdNoteController::testDestroyGlobalWaitNote
       
   147 // 
       
   148 // Connects to test object signal and verifies received data.
       
   149 // -----------------------------------------------------------------------------
       
   150 void Ut_CphCltUssdNoteController::testDestroyGlobalWaitNote()
       
   151 {
       
   152     qDebug("Ut_CphCltUssdNoteController::testDestroyGlobalWaitNote >");
       
   153     QVERIFY(mNoteController);
       
   154     mNoteController->DestroyGlobalWaitNote();
       
   155     qDebug("Ut_CphCltUssdNoteController::testDestroyGlobalWaitNote <");
       
   156 }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // Ut_CphCltUssdNoteController::testCancelGlobalWaitNote
       
   160 // 
       
   161 // Connects to test object signal and verifies received data.
       
   162 // -----------------------------------------------------------------------------
       
   163 void Ut_CphCltUssdNoteController::testCancelGlobalWaitNote()
       
   164 {
       
   165     qDebug("Ut_CphCltUssdNoteController::testCancelGlobalWaitNote >");
       
   166     QVERIFY(mNoteController);
       
   167     TRAPD(err, mNoteController->ShowGlobalWaitNoteL() );
       
   168     QTimer *timer = new QTimer(this);
       
   169     timer->start(KExtendTimeoutMseconds);
       
   170     bool ret = connect(timer, SIGNAL(timeout()), timer, SLOT(stop()));
       
   171 
       
   172 
       
   173     QEventLoop *loop = new QEventLoop(this);
       
   174     ret = connect(timer, SIGNAL(timeout()), loop, SLOT(quit()));
       
   175     loop->exec(QEventLoop::AllEvents);
       
   176     mNoteController->DestroyGlobalWaitNote();
       
   177     qDebug("Ut_CphCltUssdNoteController::testCancelGlobalWaitNote <");
       
   178 }
       
   179 
       
   180 // End of file