satui/satapp/tsrc/ut_satapp/src/ut_csatuiobserver.cpp
changeset 15 d7fc66ccd6fb
equal deleted inserted replaced
13:e32024264ebb 15:d7fc66ccd6fb
       
     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 CSatUiObserver
       
    15 *
       
    16 */
       
    17 
       
    18 //symbian
       
    19 #include <e32base.h>
       
    20 //#include <e32cmn.h>
       
    21 #include <badesca.h>
       
    22 #include <msatuiobserver.h>
       
    23 //qt
       
    24 #include <QStringList>
       
    25 //test class
       
    26 #include "csatuiobserver.h"
       
    27 #include "ut_csatuiobserver.h"
       
    28 #include "dummyeventprovider.h"
       
    29 
       
    30 
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // Ut_CSatUiObserver::Ut_CSatUiObserver
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 Ut_CSatUiObserver::Ut_CSatUiObserver(QObject *parent):QObject(parent) 
       
    37 {
       
    38     qDebug("Ut_CSatUiObserver::Ut_CSatUiObserver >");
       
    39     TRAPD(err, mSatObserver = CSatUiObserver::NewL());
       
    40     qDebug("Ut_CSatUiObserver: Ut_CSatUiObserver, err=%d", err);
       
    41     mImplementer = new DummyEventProvider();
       
    42     QVERIFY(mImplementer);
       
    43     qDebug("Ut_CSatUiObserver::Ut_CSatUiObserver <");
       
    44 }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // Ut_CSatUiObserver::~Ut_CSatUiObserver
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 Ut_CSatUiObserver::~Ut_CSatUiObserver()
       
    51 {
       
    52     qDebug("Ut_CSatUiObserver::~Ut_CSatUiObserver >");
       
    53     if (mSatObserver) {
       
    54         qDebug("Ut_CSatUiObserver::~Ut_CSatUiObserver delete mSatObserver...");
       
    55         delete mSatObserver;
       
    56         mSatObserver = 0;
       
    57     }
       
    58     if (mImplementer) {
       
    59         qDebug("Ut_CSatUiObserver::~Ut_CSatUiObserver delete mImplementer...");
       
    60         delete mImplementer;
       
    61         mImplementer = 0;
       
    62     }
       
    63     qDebug("Ut_CSatUiObserver::~Ut_CSatUiObserver <");
       
    64 }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // Ut_CSatUiObserver::initTestCase
       
    68 // QTestLib cleanup method, called after the last testfunction .
       
    69 // -----------------------------------------------------------------------------
       
    70 void Ut_CSatUiObserver::initTestCase()
       
    71 {
       
    72     qDebug("Ut_CSatUiObserver::initTestCase >");
       
    73     qDebug("Ut_CSatUiObserver::initTestCase <");
       
    74 }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // Ut_CSatUiObserver::cleanupTestCase
       
    79 // 
       
    80 // Connects to test object signal and verifies received data.
       
    81 // -----------------------------------------------------------------------------
       
    82 void Ut_CSatUiObserver::cleanupTestCase()
       
    83 {
       
    84     qDebug("Ut_CSatUiObserver::cleanupTestCase >");
       
    85     qDebug("Ut_CSatUiObserver::cleanupTestCase <");
       
    86 }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // Ut_CSatUiObserver::testConnectRSatSession
       
    90 // 
       
    91 // Connects to test object signal and verifies received data.
       
    92 // -----------------------------------------------------------------------------
       
    93 void Ut_CSatUiObserver::testConnectRSatSession()
       
    94 {
       
    95     qDebug("Ut_CSatUiObserver::testConnectRSatSession >");
       
    96     QVERIFY(mSatObserver);
       
    97     TRAP_IGNORE(mSatObserver->ConnectRSatSessionL());
       
    98     qDebug("Ut_CSatUiObserver::testConnectRSatSession <");
       
    99 }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // Ut_CSatUiObserver::testAdapter
       
   103 // 
       
   104 // Connects to test object signal and verifies received data.
       
   105 // -----------------------------------------------------------------------------
       
   106 void Ut_CSatUiObserver::testAdapter()
       
   107 {
       
   108     qDebug("Ut_CSatUiObserver::testAdapter >");
       
   109     QVERIFY(mSatObserver);
       
   110     mSatObserver->Adapter();
       
   111     qDebug("Ut_CSatUiObserver::testAdapter <");
       
   112 }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // Ut_CSatUiObserver::testDisconnectRSatSession
       
   116 // 
       
   117 // Connects to test object signal and verifies received data.
       
   118 // -----------------------------------------------------------------------------
       
   119 void Ut_CSatUiObserver::testDisconnectRSatSession()
       
   120 {
       
   121     qDebug("Ut_CSatUiObserver::testDisconnectRSatSession >");
       
   122     QVERIFY(mSatObserver);
       
   123     mSatObserver->DisconnectRSatSession();
       
   124     qDebug("Ut_CSatUiObserver::testDisconnectRSatSession <");
       
   125 } 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // Ut_CSatUiObserver::testProfileState
       
   129 // 
       
   130 // Connects to test object signal and verifies received data.
       
   131 // -----------------------------------------------------------------------------
       
   132 void Ut_CSatUiObserver::testProfileState()
       
   133 {
       
   134     qDebug("Ut_CSatUiObserver::testProfileState >");
       
   135     QVERIFY(mSatObserver);
       
   136     mSatObserver->ProfileState();
       
   137     qDebug("Ut_CSatUiObserver::testProfileState <");
       
   138 }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // Ut_CSatUiObserver::testSetImplementer
       
   142 // 
       
   143 // Connects to test object signal and verifies received data.
       
   144 // -----------------------------------------------------------------------------
       
   145 void Ut_CSatUiObserver::testSetImplementer()
       
   146 {
       
   147     qDebug("Ut_CSatUiObserver::testSetImplementer >");
       
   148     QVERIFY(mSatObserver);
       
   149     QVERIFY(mImplementer);
       
   150     mSatObserver->SetImplementer(mImplementer);
       
   151     qDebug("Ut_CSatUiObserver::testSetImplementer <");
       
   152 }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // Ut_CSatUiObserver::testDisplayText_data
       
   156 // 
       
   157 // Connects to test object signal and verifies received data.
       
   158 // -----------------------------------------------------------------------------
       
   159 void Ut_CSatUiObserver::testDisplayText_data()
       
   160 {
       
   161     qDebug("Ut_CSatUiObserver::testDisplayText_data >");
       
   162     QTest::addColumn<QString>("text");
       
   163     QTest::addColumn<QString>("appName");
       
   164     QTest::addColumn<int>("iconIdIdentifier");
       
   165     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   166     QTest::addColumn<bool>("isIconDisplayed");
       
   167     QTest::addColumn<bool>("sustainedText");
       
   168     QTest::addColumn<int>("duration");
       
   169     QTest::addColumn<bool>("isWaitUsertoClear");
       
   170     QTest::addColumn<int>("expectValue");
       
   171 
       
   172     QTest::newRow("first") << "Show Display text!" << "Unit test SIM Service" << 
       
   173         84 << 1 << false << false << 2500 << true << 0;
       
   174 
       
   175     QTest::newRow("second") << "Show Display text!" << "SIM Service" << 
       
   176         84 << 1 << true << false << 2500 << false << 0;
       
   177     // test null text
       
   178     QTest::newRow("third") << "" << "SIM Service" << 
       
   179         84 << 1 << true << false << 2500 << false << -1;
       
   180 
       
   181     // test icon is available for command
       
   182     QTest::newRow("fouth") << "Show Display text!" << "SIM Service" << 
       
   183         84 << 2 << true << false << 2500 << false << 0;
       
   184 
       
   185     // test leave occurs
       
   186     //QTest::newRow("forth") << "Show Display text!" << "" << 
       
   187     //    84 << 2 << true << false << 2500 << false << 1;
       
   188 
       
   189     qDebug("Ut_CSatUiObserver::testDisplayText_data <");
       
   190 }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // Ut_SatApp::testDisplayText
       
   194 // 
       
   195 // Connects to test object signal and verifies received data.
       
   196 // -----------------------------------------------------------------------------
       
   197 void Ut_CSatUiObserver::testDisplayText()
       
   198 {
       
   199     qDebug("Ut_CSatUiObserver::testDisplayText >");
       
   200     QVERIFY(mSatObserver);
       
   201     QFETCH(QString, text);
       
   202     QFETCH(QString, appName);
       
   203     QFETCH(int, iconIdIdentifier);
       
   204     QFETCH(int, iconIdQualifier);
       
   205     QFETCH(bool, isIconDisplayed);
       
   206     QFETCH(bool, sustainedText);
       
   207     QFETCH(int, duration);
       
   208     QFETCH(bool, isWaitUsertoClear);
       
   209     QFETCH(int, expectValue);
       
   210 
       
   211     // text
       
   212     HBufC* hText = HBufC::New(text.length());
       
   213     TPtr aText( hText->Des() );
       
   214     aText.Copy( text.utf16() );
       
   215     // sim name
       
   216     HBufC* hSimAppName = HBufC::New(appName.length());
       
   217     TPtr aSimApplicationName( hSimAppName->Des() );
       
   218     aSimApplicationName.Copy( appName.utf16() );
       
   219 
       
   220     TSatIconId aIconId;
       
   221     aIconId.iIdentifier = iconIdIdentifier;
       
   222     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   223     TBool aIsIconDisplayed(isIconDisplayed);
       
   224 
       
   225     TSatUiResponse result(ESatSuccess);
       
   226     // It seems that TRAPD&QT_TRAP_THROWING does nothing if leave occurs, need 
       
   227     // to investigate.
       
   228     QT_TRAP_THROWING( result = mSatObserver->DisplayTextL(
       
   229                               aText, 
       
   230                               aSimApplicationName,
       
   231                               aIconId,
       
   232                               aIsIconDisplayed,
       
   233                               sustainedText,
       
   234                               duration,
       
   235                               isWaitUsertoClear
       
   236                               ));
       
   237     delete hText;
       
   238     hText = 0;
       
   239     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectValue);
       
   240     QCOMPARE(exValue, result);
       
   241     qDebug("Ut_CSatUiObserver::testDisplayText <");
       
   242 }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // Ut_CSatUiObserver::testSetUpMenu_data
       
   246 // 
       
   247 // Connects to test object signal and verifies received data.
       
   248 // -----------------------------------------------------------------------------
       
   249 void Ut_CSatUiObserver::testSetUpMenu_data()
       
   250 {
       
   251     qDebug("Ut_CSatUiObserver::testSetUpMenu_data >");
       
   252     QTest::addColumn<QString>("text");
       
   253     QTest::addColumn<QStringList>("setupMenuItem");
       
   254     QTest::addColumn<bool>("isHelpIsAvailable");
       
   255     QTest::addColumn<int>("iconIdIdentifier");
       
   256     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   257     QTest::addColumn<int>("iconListQualifier");
       
   258     QTest::addColumn<int>("expectReturnValue");
       
   259 
       
   260     QStringList testSetUpMenu_1_items;
       
   261     testSetUpMenu_1_items 
       
   262     << "SendData" 
       
   263     << "ReceiveData" 
       
   264     << "CloseChannel"
       
   265     << "OpenChannel"
       
   266     << "GetChannelStatus"
       
   267     << "DisplayText with different symbols and durations"
       
   268     << "GetInkey"
       
   269     << "GetInput"
       
   270     << "SelectItem"
       
   271     << "PlayTone"
       
   272     << "RefreshRequired"
       
   273     << "DoRefresh"
       
   274     << "SendSm"
       
   275     << "SendSs"
       
   276     << "SendUssd"
       
   277     << "SetUpCall"
       
   278     << "SetUpIdleModeText"
       
   279     << "CallControl"
       
   280     << "MoSmControl"
       
   281     << "LaunchBrowser"
       
   282     << "SendDTMF"
       
   283     << "SetUpEventList"
       
   284     << "ProvideLocalInfo"
       
   285     << "EventDownload for IdleScreen available event"
       
   286     << "SetUpMenu";
       
   287 
       
   288     QTest::newRow("first") << "SAT" << testSetUpMenu_1_items << 
       
   289         false << 80 << 1 << 2 << 0;
       
   290 
       
   291     qDebug("Ut_CSatUiObserver::testSetUpMenu_data <");
       
   292 }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // Ut_CSatUiObserver::testSetUpMenu
       
   296 // 
       
   297 // Connects to test object signal and verifies received data.
       
   298 // -----------------------------------------------------------------------------
       
   299 void Ut_CSatUiObserver::testSetUpMenu()
       
   300 {
       
   301     qDebug("Ut_CSatUiObserver::testSetUpMenu >");
       
   302     QVERIFY(mSatObserver);
       
   303     QFETCH(QString, text);
       
   304     QFETCH(QStringList, setupMenuItem);
       
   305     QFETCH(bool, isHelpIsAvailable);
       
   306     QFETCH(int, iconIdIdentifier);
       
   307     QFETCH(int, iconIdQualifier);
       
   308     QFETCH(int, iconListQualifier);
       
   309     QFETCH(int, expectReturnValue);
       
   310 
       
   311     // aText
       
   312     HBufC* hText = HBufC::New(text.length());
       
   313     TPtr aText( hText->Des() );
       
   314     aText.Copy( text.utf16() );
       
   315     // aMenuItems
       
   316     TBuf<128> menuItem;
       
   317     CDesCArrayFlat* aMenuItems = new CDesCArrayFlat(4);
       
   318     QVERIFY(aMenuItems);
       
   319     for (int i = 0; i< setupMenuItem.count(); i++) {
       
   320         menuItem = setupMenuItem.at(i).utf16();
       
   321         QT_TRAP_THROWING(aMenuItems->AppendL(menuItem));
       
   322     }
       
   323     // aIconId
       
   324     TSatIconId aIconId;
       
   325     aIconId.iIdentifier = iconIdIdentifier;
       
   326     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   327     // aMenuItemNextActions
       
   328     CArrayFixFlat<TSatAction>* aMenuItemNextActions = 
       
   329           new CArrayFixFlat<TSatAction> (4);
       
   330      QVERIFY(aMenuItemNextActions);
       
   331     // Temp test
       
   332      QT_TRAP_THROWING(aMenuItemNextActions->AppendL(ESatSetUpMenuAction));
       
   333     // aMenuIcons
       
   334     CArrayFixFlat<TInt>* aMenuIcons = new CArrayFixFlat<TInt>(2);
       
   335     QVERIFY(aMenuIcons);
       
   336     // Temp test
       
   337     QT_TRAP_THROWING(aMenuIcons->AppendL(1));
       
   338     // aIconListQualifier
       
   339     TSatIconQualifier aIconListQualifier = 
       
   340         static_cast<TSatIconQualifier>(iconListQualifier);
       
   341     // TSatSelectionPreference, useless
       
   342     TSatSelectionPreference aSelectionPreference(ESatNoSelectionPreference);
       
   343     TSatUiResponse result(ESatSuccess);
       
   344     QT_TRAP_THROWING(result = mSatObserver->SetUpMenuL(
       
   345                               aText,
       
   346                               *aMenuItems,
       
   347                               aMenuItemNextActions,
       
   348                               isHelpIsAvailable,
       
   349                               aIconId,
       
   350                               aMenuIcons,
       
   351                               aIconListQualifier,
       
   352                               aSelectionPreference
       
   353                               ));
       
   354     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectReturnValue);
       
   355     QCOMPARE(exValue, result);
       
   356 
       
   357     delete hText;
       
   358     hText = 0;
       
   359     delete aMenuItems;
       
   360     aMenuItems = 0;
       
   361     delete aMenuItemNextActions;
       
   362     aMenuItemNextActions = 0;
       
   363     delete aMenuIcons;
       
   364     aMenuIcons = 0;
       
   365     qDebug("Ut_CSatUiObserver::testSetUpMenu <");
       
   366 }
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // Ut_CSatUiObserver::testGetInkey_data
       
   370 // 
       
   371 // Connects to test object signal and verifies received data.
       
   372 // -----------------------------------------------------------------------------
       
   373 void Ut_CSatUiObserver::testGetInkey_data()
       
   374 {
       
   375     qDebug("Ut_CSatUiObserver::testGetInkey_data >");
       
   376     QTest::addColumn<QString>("text");
       
   377     QTest::addColumn<int>("characterSet");//enum 0~3
       
   378     QTest::addColumn<QString>("input");
       
   379     QTest::addColumn<bool>("isHelpIsAvailable");
       
   380     QTest::addColumn<int>("iconIdIdentifier");
       
   381     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   382     QTest::addColumn<bool>("isRequestedIconDisplayed");
       
   383     QTest::addColumn<int>("duration");
       
   384     QTest::addColumn<bool>("isImmediateDigitResponse");
       
   385     QTest::addColumn<int>("expectValue");
       
   386     //// test ESatDigitOnly
       
   387     QTest::newRow("first") << "Test GetInKey" << 0 << 
       
   388         "8" << false << 60 << 1 << false << 2500 << true << 0;
       
   389     // null text && EIconGetYesNo
       
   390     QTest::newRow("second") << "" << 0 << 
       
   391         "s" << false<< 60 << 1 << false << 2500 << true << 0;
       
   392     // test EIconGetYesNo
       
   393     QTest::newRow("third") << "Test GetInKey" << 3 << 
       
   394         "s" << false << 60 << 1 << false << 2500 << true << 0;
       
   395     // test ESatCharSmsDefaultAlphabet
       
   396     QTest::newRow("fourth") << "Test GetInKey" << 3 << 
       
   397         "$" << false << 60 << 1 << false << 2500 << true << 0;
       
   398     // ino immediateDigitResponse
       
   399     QTest::newRow("fifth") << "Test GetInKey" << 1 << 
       
   400     "#" << false<< 60 << 1 << false << 2500 << false << 0;
       
   401     // test leave
       
   402     //QTest::newRow("sisth") << "Test GetInKey" << 1 << 
       
   403     //    "" << false << 60 << 1 << false << 2500 << true << 0;
       
   404     qDebug("Ut_CSatUiObserver::testGetInkey_data <");
       
   405 }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // Ut_CSatUiObserver::testGetInkey
       
   409 // 
       
   410 // Connects to test object signal and verifies received data.
       
   411 // -----------------------------------------------------------------------------
       
   412 void Ut_CSatUiObserver::testGetInkey()
       
   413 {
       
   414     qDebug("Ut_CSatUiObserver::testGetInkey >");
       
   415     QVERIFY(mSatObserver);
       
   416     QFETCH(QString, text);
       
   417     QFETCH(int, characterSet);
       
   418     QFETCH(QString, input);
       
   419     QFETCH(bool, isHelpIsAvailable);
       
   420     QFETCH(int, iconIdIdentifier);
       
   421     QFETCH(int, iconIdQualifier);
       
   422     QFETCH(bool, isRequestedIconDisplayed);
       
   423     QFETCH(int, duration);
       
   424     QFETCH(bool, isImmediateDigitResponse);
       
   425     QFETCH(int, expectValue);
       
   426 
       
   427     // text
       
   428     HBufC* hText = HBufC::New(text.length());
       
   429     TPtr aText( hText->Des() );
       
   430     aText.Copy( text.utf16() );
       
   431     // aCharacterSet
       
   432     TSatCharacterSet aCharacterSet = static_cast<TSatCharacterSet>(characterSet);
       
   433     // aInput
       
   434     TBuf<1> tInput = input.utf16();
       
   435     TChar aInput(tInput[0]);
       
   436     // aHelpIsAvailable
       
   437     TBool aHelpIsAvailable(isHelpIsAvailable);
       
   438     // aIconId
       
   439     TSatIconId aIconId;
       
   440     aIconId.iIdentifier = iconIdIdentifier;
       
   441     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   442     // aRequestedIconDisplayed
       
   443     TBool aRequestedIconDisplayed(isRequestedIconDisplayed);
       
   444     // aDuration
       
   445     TUint aDuration= static_cast<TUint>(duration);
       
   446     // aRequestedIconDisplayed
       
   447     //TBool aImmediateDigitResponse(isImmediateDigitResponse);
       
   448 
       
   449     TSatUiResponse result(ESatSuccess);
       
   450     QT_TRAP_THROWING( result = mSatObserver->GetInkeyL(
       
   451                               aText, 
       
   452                               aCharacterSet,
       
   453                               aInput,
       
   454                               aHelpIsAvailable,
       
   455                               aIconId,
       
   456                               aRequestedIconDisplayed,
       
   457                               aDuration,
       
   458                               isImmediateDigitResponse
       
   459                               ));
       
   460     delete hText;
       
   461     hText = 0;
       
   462     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectValue);
       
   463     QCOMPARE(exValue, result);
       
   464 
       
   465     qDebug("Ut_CSatUiObserver::testGetInkey <");
       
   466 }
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // Ut_CSatUiObserver::testGetInput_data
       
   470 // 
       
   471 // Connects to test object signal and verifies received data.
       
   472 // -----------------------------------------------------------------------------
       
   473 void Ut_CSatUiObserver::testGetInput_data()
       
   474 {
       
   475     qDebug("Ut_CSatUiObserver::testGetInput_data >");
       
   476     QTest::addColumn<QString>("text");
       
   477     QTest::addColumn<int>("characterSet");//enum 0~3
       
   478     QTest::addColumn<QString>("input");
       
   479     QTest::addColumn<int>("minLength");
       
   480     QTest::addColumn<int>("maxLength");
       
   481     QTest::addColumn<bool>("isHideInput");
       
   482     QTest::addColumn<bool>("isHelpIsAvailable");
       
   483     QTest::addColumn<int>("iconIdIdentifier");
       
   484     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   485     QTest::addColumn<bool>("isRequestedIconDisplayed");
       
   486     QTest::addColumn<int>("expectValue");
       
   487     // test characterSet ESatCharSmsDefaultAlphabet
       
   488     QTest::newRow("first") << "Test GetInput" << 1 << 
       
   489         "get input" << 1 << 5 << false << false <<60 << 1 << true << 0;
       
   490     // test iconIdQualifier ESatSelfExplanatory
       
   491     QTest::newRow("second") << "Test GetInput" << 0 << 
       
   492       "get input" << 1 << 5 << false << false <<60 << 2 << true << 0;
       
   493     // test leave
       
   494     //QTest::newRow("third") << "Test GetInput" << 0 << 
       
   495     //  "" << 1 << 5 << false << false <<60 << 2 << true << 0;
       
   496     qDebug("Ut_CSatUiObserver::testGetInput_data <");
       
   497 }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // Ut_CSatUiObserver::testGetInput
       
   501 // 
       
   502 // Connects to test object signal and verifies received data.
       
   503 // -----------------------------------------------------------------------------
       
   504 void Ut_CSatUiObserver::testGetInput()
       
   505 {
       
   506     qDebug("Ut_CSatUiObserver::testGetInput >");
       
   507     QVERIFY(mSatObserver);
       
   508     QFETCH(QString, text);
       
   509     QFETCH(int, characterSet);
       
   510     QFETCH(QString, input);
       
   511     QFETCH(int, minLength);
       
   512     QFETCH(int, maxLength);
       
   513     QFETCH(bool, isHideInput);
       
   514     QFETCH(bool, isHelpIsAvailable);
       
   515     QFETCH(int, iconIdIdentifier);
       
   516     QFETCH(int, iconIdQualifier);
       
   517     QFETCH(bool, isRequestedIconDisplayed);
       
   518     QFETCH(int, expectValue);
       
   519 
       
   520     // text
       
   521     HBufC* hText = HBufC::New(text.length());
       
   522     TPtr aText( hText->Des() );
       
   523     aText.Copy( text.utf16() );
       
   524     // aCharacterSet
       
   525     TSatCharacterSet aCharacterSet = static_cast<TSatCharacterSet>(characterSet);
       
   526     // aInput
       
   527     HBufC* hInput = HBufC::New(input.length());
       
   528     TPtr aInput( hInput->Des() );
       
   529     aInput.Copy( input.utf16() );
       
   530     // aIconId
       
   531     TSatIconId aIconId;
       
   532     aIconId.iIdentifier = iconIdIdentifier;
       
   533     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   534     // aRequestedIconDisplayed
       
   535     TBool aRequestedIconDisplayed(isRequestedIconDisplayed);
       
   536 
       
   537     TSatUiResponse result(ESatSuccess);
       
   538     QT_TRAP_THROWING( result = mSatObserver->GetInputL(
       
   539                               aText, 
       
   540                               aCharacterSet,
       
   541                               aInput,
       
   542                               minLength,
       
   543                               maxLength,
       
   544                               isHideInput,
       
   545                               isHelpIsAvailable,
       
   546                               aIconId,
       
   547                               aRequestedIconDisplayed
       
   548                               ));
       
   549     delete hText;
       
   550     hText = 0;
       
   551     delete hInput;
       
   552     hInput = 0;
       
   553     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectValue);
       
   554     QCOMPARE(exValue, result);
       
   555     qDebug("Ut_CSatUiObserver::testGetInput <");
       
   556 }
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // Ut_CSatUiObserver::testConfirmCommand_data
       
   560 // 
       
   561 // Connects to test object signal and verifies received data.
       
   562 // -----------------------------------------------------------------------------
       
   563 void Ut_CSatUiObserver::testConfirmCommand_data()
       
   564 {
       
   565     qDebug("Ut_CSatUiObserver::testConfirmCommand_data >");
       
   566     QTest::addColumn<int>("commandId");// enum 0~6
       
   567     QTest::addColumn<int>("alphaIdStatus");
       
   568     QTest::addColumn<QString>("text");
       
   569     QTest::addColumn<QString>("additionalText");
       
   570     QTest::addColumn<bool>("isctionAccepted");
       
   571     QTest::addColumn<int>("iconIdIdentifier");
       
   572     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   573     QTest::addColumn<bool>("isRequestedIconDisplayed");
       
   574     QTest::addColumn<bool>("isterminatedByUser");
       
   575     // test commandId ESatSSendSmQuery
       
   576     QTest::newRow("first") << 0 << 1 << "ConfirmCommand SendSm" 
       
   577         << "SendSm" <<false << 60 << 1 << false <<false;
       
   578     // test commandId ESatSSendSsQuery
       
   579     QTest::newRow("second") << 1 << 1 << "ConfirmCommand SendSs" 
       
   580         << "SendSs" <<false << 60 << 1 << false <<false;
       
   581     // test commandId ESatSSendUssdQuery
       
   582     QTest::newRow("third") << 2 << 1 << "ConfirmCommand SendUssd" 
       
   583         << "SendUssd" <<false << 60 << 1 << false <<false;
       
   584     // test commandId ESatSRefreshQuery
       
   585     QTest::newRow("fourth") << 3 << 1 << "ConfirmCommand Refresh" 
       
   586         << "First test case" <<false << 60 << 1 << false <<false;
       
   587     // test commandId ESatSLaunchBrowserQuery
       
   588     QTest::newRow("fifth") << 4 << 1 << "ConfirmCommand LaunchBrowser" 
       
   589         << "LaunchBrowser" <<false << 60 << 1 << false <<false;
       
   590     // test commandId ESatOpenChannelQuery
       
   591     QTest::newRow("sixth") << 5 << 1 << "ConfirmCommand OpenChannel" 
       
   592         << "OpenChanne" <<false << 60 << 1 << false <<false;
       
   593     // test commandId ESatSSetUpCallQuery
       
   594     QTest::newRow("seventh") << 6 << 1 << "ConfirmCommand SetUpCall" 
       
   595         << "SetUpCall" <<false << 60 << 1 << false <<false;
       
   596     // test commandId ESatSelfExplanatory
       
   597     QTest::newRow("eighth") << 0 << 1 << "ConfirmCommand SendSm" 
       
   598         << "SendSm SelfExplanatory" <<false << 60 << 2 << true <<false;
       
   599 
       
   600     qDebug("Ut_CSatUiObserver::testConfirmCommand_data <");
       
   601 }
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // Ut_CSatUiObserver::testConfirmCommand
       
   605 // 
       
   606 // Connects to test object signal and verifies received data.
       
   607 // -----------------------------------------------------------------------------
       
   608 void Ut_CSatUiObserver::testConfirmCommand()
       
   609 {
       
   610     qDebug("Ut_CSatUiObserver::testConfirmCommand >");
       
   611     QVERIFY(mSatObserver);
       
   612     QFETCH(int, commandId);
       
   613     QFETCH(int, alphaIdStatus);
       
   614     QFETCH(QString, text);
       
   615     QFETCH(QString, additionalText);
       
   616     QFETCH(bool, isctionAccepted);
       
   617     QFETCH(int, iconIdIdentifier);
       
   618     QFETCH(int, iconIdQualifier);
       
   619     QFETCH(bool, isRequestedIconDisplayed);
       
   620     QFETCH(bool, isterminatedByUser);
       
   621 
       
   622     // aCharacterSet
       
   623     TSatSQueryCommand aCommandId = static_cast<TSatSQueryCommand>(commandId);
       
   624     // aAlphaIdStatus
       
   625     TSatAlphaIdStatus aAlphaIdStatus = static_cast<TSatAlphaIdStatus>(alphaIdStatus);
       
   626     // text
       
   627     HBufC* hText = HBufC::New(text.length());
       
   628     TPtr aText( hText->Des() );
       
   629     aText.Copy( text.utf16() );
       
   630     // aAdditionalText
       
   631     HBufC* hAdditionalText = HBufC::New(additionalText.length());
       
   632     TPtr aAdditionalText( hAdditionalText->Des() );
       
   633     aAdditionalText.Copy( additionalText.utf16() );
       
   634     // aActionAccepted
       
   635     TBool aActionAccepted(isctionAccepted);
       
   636     // aIconId
       
   637     TSatIconId aIconId;
       
   638     aIconId.iIdentifier = iconIdIdentifier;
       
   639     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   640     // aRequestedIconDisplayed
       
   641     TBool aRequestedIconDisplayed(isRequestedIconDisplayed);
       
   642     // aRequestedIconDisplayed
       
   643     TBool aTerminatedByUser(isterminatedByUser);
       
   644 
       
   645     mSatObserver->ConfirmCommand(
       
   646                               aCommandId,
       
   647                               aAlphaIdStatus,
       
   648                               aText, 
       
   649                               aAdditionalText,
       
   650                               aActionAccepted,
       
   651                               aIconId,
       
   652                               aRequestedIconDisplayed,
       
   653                               aTerminatedByUser
       
   654                               );
       
   655     delete hText;
       
   656     hText = 0;
       
   657     delete hAdditionalText;
       
   658     hAdditionalText = 0;
       
   659     qDebug("Ut_CSatUiObserver::testConfirmCommand <");
       
   660 }
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // Ut_CSatUiObserver::testNotification_data
       
   664 // 
       
   665 // Connects to test object signal and verifies received data.
       
   666 // -----------------------------------------------------------------------------
       
   667 void Ut_CSatUiObserver::testNotification_data()
       
   668 {
       
   669     qDebug("Ut_CSatUiObserver::testNotification_data >");
       
   670     QTest::addColumn<int>("commandId");// enum 0~6
       
   671     QTest::addColumn<int>("alphaIdStatus");
       
   672     QTest::addColumn<QString>("text");
       
   673     QTest::addColumn<int>("iconIdIdentifier");
       
   674     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   675     QTest::addColumn<bool>("isRequestedIconDisplayed");
       
   676     QTest::addColumn<int>("controlResult");
       
   677  
       
   678     // test commandId ESatSSendDataNotify    
       
   679     QTest::newRow("Senddata_0id") << 0 << 0 << "Send data notify" 
       
   680     << 2 << 0 << false <<0;
       
   681     // test commandId ESatSSendDataNotify alpha id not null but string length is zero   
       
   682     QTest::newRow("Senddata_1id") << 0 << 1 << "" 
       
   683     << 2 << 0 << false <<0;
       
   684     QTest::newRow("Senddata_2id") << 0 << 2 << "Send data notify AlphaIdNotProvided" 
       
   685     << 2 << 0 << false <<0;
       
   686     // test commandId ESatSReceiveDataNotify
       
   687     QTest::newRow("Recievedata_0id") << 1 << 0 << "Recieve data notify" 
       
   688     << 2 << 3 << false <<0;
       
   689     QTest::newRow("Recievedata_1id") << 1 << 1 << "Recieve data notify" 
       
   690     << 2 << 3 << false <<0;
       
   691     QTest::newRow("Recievedata_2id") << 1 << 2 << "Recieve data notify AlphaIdNotProvided" 
       
   692     << 2 << 3 << false <<0;
       
   693     // test commandId ESatSCloseChannelNotify
       
   694     QTest::newRow("CloseChannel_0id") << 2 << 0 << "Close channel notify" 
       
   695     << 2 << 3 << false <<0;
       
   696     QTest::newRow("CloseChannel_1id") << 2 << 1 << "" 
       
   697     << 2 << 3 << false <<0;
       
   698     QTest::newRow("CloseChannel_2id") << 2 << 2 << "Close channel notify AlphaIdNotProvided" 
       
   699     << 2 << 3 << false <<0;
       
   700     // test commandId ESatSMoSmControlNotify
       
   701     QTest::newRow("MoSm_0id") << 3 << 0 << "SM control notify" 
       
   702     << 2 << 0 << false <<0;
       
   703     QTest::newRow("MoSm_1id") << 3 << 1 << "0" 
       
   704     << 2 << 0 << false <<0;
       
   705     QTest::newRow("MoSm_2id") << 3 << 2 << "SM control notify AlphaIdNotProvided" 
       
   706     << 2 << 0 << false <<0;
       
   707     // test commandId ESatSCallControlNotify
       
   708     QTest::newRow("CallControl_0id") << 4 << 0 << "Call control notify" 
       
   709     << 2 << 1 << false <<0;
       
   710     QTest::newRow("CallControl_1id") << 4 << 1 << ""
       
   711     << 2 << 1 << false <<0;
       
   712     QTest::newRow("CallControl_2id") << 4 << 2 << "Call control notify AlphaIdNotProvided" 
       
   713     << 2 << 1 << false <<0;
       
   714     // test commandId ESatSSendSsNotify
       
   715     QTest::newRow("SendSs_0id") << 5 << 0 << "Send SS notify" 
       
   716     << 2 << 2 << false <<0;
       
   717     QTest::newRow("SendSs_1id") << 5 << 1 << "" 
       
   718     << 2 << 2 << false <<0;
       
   719     QTest::newRow("SendSs_2id") << 5 << 2 << "Send SS notify AlphaIdNotProvided" 
       
   720     << 2 << 2 << false <<0;
       
   721     // test commandId ESatSSendUssdNotify
       
   722     QTest::newRow("SendUssd_0id") << 6 << 0 << "Send Ussd notify" 
       
   723     << 2 << 3 << false <<0;
       
   724     // test commandId ESatSSendUssdNotify
       
   725     QTest::newRow("SendUssd_1id") << 6 << 1 << "" 
       
   726     << 2 << 3 << false <<0;
       
   727     // test commandId ESatSSendUssdNotify
       
   728     QTest::newRow("SendUssd_2id") << 6 << 2 << "Send Ussd notify AlphaIdNotProvided" 
       
   729     << 2 << 3 << false <<0;
       
   730     // test commandId ESatSSendDtmfNotify
       
   731     QTest::newRow("SendDtmf_0id") << 7 << 0 << "Send dtmf notify" 
       
   732     << 2 << 3 << false <<0;
       
   733     QTest::newRow("SendDtmf_1id") << 7 << 1 << "Send dtmf notify" 
       
   734     << 2 << 3 << false <<0;
       
   735     QTest::newRow("SendDtmf_2id") << 7 << 2 << "Send dtmf notify AlphaIdNotProvided" 
       
   736     << 2 << 3 << false <<0;
       
   737     // test commandId ESatSSendSmsNotify
       
   738     QTest::newRow("SendSm_0id") << 8 << 0 << "SendSm notify" 
       
   739     << 2 << 2 << false <<0;
       
   740     QTest::newRow("SendSm_1id") << 8 << 1 << "SendSm notify" 
       
   741     << 2 << 2 << false <<0;
       
   742     QTest::newRow("SendSm_2id") << 8 << 2 << "SendSm notify AlphaIdNotProvided" 
       
   743     << 2 << 2 << false <<0;
       
   744     qDebug("Ut_CSatUiObserver::testNotification_data <");
       
   745 }
       
   746 
       
   747 // -----------------------------------------------------------------------------
       
   748 // Ut_CSatUiObserver::testNotification
       
   749 // 
       
   750 // Connects to test object signal and verifies received data.
       
   751 // -----------------------------------------------------------------------------
       
   752 void Ut_CSatUiObserver::testNotification()
       
   753 {
       
   754     qDebug("Ut_CSatUiObserver::testNotification >");
       
   755     QVERIFY(mSatObserver);
       
   756     QFETCH(int, commandId);
       
   757     QFETCH(int, alphaIdStatus);
       
   758     QFETCH(QString, text);
       
   759     QFETCH(int, iconIdIdentifier);
       
   760     QFETCH(int, iconIdQualifier);
       
   761     QFETCH(bool, isRequestedIconDisplayed);
       
   762     QFETCH(int, controlResult);
       
   763 
       
   764     // aCommandId
       
   765     TSatSNotifyCommand aCommandId = static_cast<TSatSNotifyCommand>(commandId);
       
   766     // aAlphaIdStatus
       
   767     TSatAlphaIdStatus aAlphaIdStatus = static_cast<TSatAlphaIdStatus>(alphaIdStatus);
       
   768     // text
       
   769     HBufC* hText = HBufC::New(text.length());
       
   770     TPtr aText( hText->Des() );
       
   771     aText.Copy( text.utf16() );
       
   772 
       
   773     // aIconId
       
   774     TSatIconId aIconId;
       
   775     aIconId.iIdentifier = iconIdIdentifier;
       
   776     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   777     // aRequestedIconDisplayed
       
   778     TBool aRequestedIconDisplayed(isRequestedIconDisplayed);
       
   779     // aRequestedIconDisplayed
       
   780     TSatControlResult aControlResult = static_cast<TSatControlResult>(controlResult);
       
   781 
       
   782     mSatObserver->Notification(
       
   783                               aCommandId,
       
   784                               aAlphaIdStatus,
       
   785                               aText, 
       
   786                               aIconId,
       
   787                               aRequestedIconDisplayed,
       
   788                               aControlResult
       
   789                               );
       
   790     delete hText;
       
   791     hText = 0;
       
   792     qDebug("Ut_CSatUiObserver::testNotification <");
       
   793 }
       
   794 
       
   795 // -----------------------------------------------------------------------------
       
   796 // Ut_CSatUiObserver::testEventNotification_data
       
   797 // 
       
   798 // Connects to test object signal and verifies received data.
       
   799 // -----------------------------------------------------------------------------
       
   800 void Ut_CSatUiObserver::testEventNotification_data()
       
   801 {
       
   802     qDebug("Ut_CSatUiObserver::testEventNotification_data >");
       
   803     QTest::addColumn<int>("eventId");// enum 0~6
       
   804     
       
   805     // test eventId ESatSRefreshStartEvent    
       
   806     QTest::newRow("RefreshStartEvent") << 0 ;
       
   807     // test eventId ESatSRefreshEndEvent
       
   808     QTest::newRow("RefreshEndEvent") << 1;
       
   809     // test eventId ESatSSmEndEvent
       
   810     QTest::newRow("SSmEndEvent") << 2;
       
   811     // test eventId ESatSClearScreenEvent
       
   812     QTest::newRow("ClearScreenEvent") << 3;
       
   813     // test eventId ESatSCloseSatUiAppEvent
       
   814     QTest::newRow("CloseSatUiAppEvent") << 4;
       
   815     // test eventId ESatSsEndEvent
       
   816     QTest::newRow("SsEndEvent") << 5;
       
   817     // test eventId ESatSsErrorEvent
       
   818     QTest::newRow("SsErrorEvent") << 6;
       
   819     // test eventId ESatSDtmfEndEvent
       
   820     QTest::newRow("DtmfEndEvent") << 7;
       
   821 
       
   822     qDebug("Ut_CSatUiObserver::testEventNotification_data <");
       
   823 }
       
   824 
       
   825 // -----------------------------------------------------------------------------
       
   826 // Ut_CSatUiObserver::testEventNotification
       
   827 // 
       
   828 // Connects to test object signal and verifies received data.
       
   829 // -----------------------------------------------------------------------------
       
   830 void Ut_CSatUiObserver::testEventNotification()
       
   831 {
       
   832     qDebug("Ut_CSatUiObserver::testEventNotification >");
       
   833     QVERIFY(mSatObserver);
       
   834     QFETCH(int, eventId);
       
   835 
       
   836     TSatSEvent aEventId = static_cast<TSatSEvent>(eventId);
       
   837     TSatSEventStatus aEventStatus = ESatEventCompleteOk;
       
   838     mSatObserver->EventNotification(aEventId, aEventStatus, 0);
       
   839     qDebug("Ut_CSatUiObserver::testEventNotification <");
       
   840 }
       
   841 
       
   842 // -----------------------------------------------------------------------------
       
   843 // Ut_CSatUiObserver::testSelectItem_data
       
   844 // 
       
   845 // Connects to test object signal and verifies received data.
       
   846 // -----------------------------------------------------------------------------
       
   847 void Ut_CSatUiObserver::testSelectItem_data()
       
   848 {
       
   849     qDebug("Ut_CSatUiObserver::testSelectItem_data >");
       
   850     QTest::addColumn<QString>("text");
       
   851     QTest::addColumn<QStringList>("selectItemItem");
       
   852     QTest::addColumn<int>("defaultItem");
       
   853     QTest::addColumn<bool>("isHelpIsAvailable");
       
   854     QTest::addColumn<int>("iconIdIdentifier");
       
   855     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   856     QTest::addColumn<int>("iconListQualifier");
       
   857     QTest::addColumn<int>("expectReturnValue");
       
   858 
       
   859     QStringList testSelectItem_1_items;
       
   860     testSelectItem_1_items 
       
   861     << "Select Item 1" 
       
   862     << "Select Item 2" 
       
   863     << "Select Item 3" 
       
   864     << "Select Item 4" 
       
   865     << "Select Item 5";
       
   866 
       
   867     QTest::newRow("first") << "Make a Choice" << testSelectItem_1_items << 
       
   868         0 << false << 80 << 1 << 2 << 0;
       
   869 
       
   870     qDebug("Ut_CSatUiObserver::testSelectItem_data <");
       
   871 }
       
   872 
       
   873 // -----------------------------------------------------------------------------
       
   874 // Ut_CSatUiObserver::testSetUpMenu
       
   875 // 
       
   876 // Connects to test object signal and verifies received data.
       
   877 // -----------------------------------------------------------------------------
       
   878 void Ut_CSatUiObserver::testSelectItem()
       
   879 {
       
   880     qDebug("Ut_CSatUiObserver::testSelectItem >");
       
   881     QVERIFY(mSatObserver);
       
   882     QFETCH(QString, text);
       
   883     QFETCH(QStringList, selectItemItem);
       
   884     QFETCH(int, defaultItem);
       
   885     QFETCH(bool, isHelpIsAvailable);
       
   886     QFETCH(int, iconIdIdentifier);
       
   887     QFETCH(int, iconIdQualifier);
       
   888     QFETCH(int, iconListQualifier);
       
   889     QFETCH(int, expectReturnValue);
       
   890 
       
   891     // aText
       
   892     HBufC* hText = HBufC::New(text.length());
       
   893     TPtr aText( hText->Des() );
       
   894     aText.Copy( text.utf16() );
       
   895     // aMenuItems
       
   896     TBuf<128> menuItem;
       
   897     CDesCArrayFlat* aMenuItems = new CDesCArrayFlat(4);
       
   898     QVERIFY(aMenuItems);
       
   899     for (int i = 0; i< selectItemItem.count(); i++) {
       
   900         menuItem = selectItemItem.at(i).utf16();
       
   901         QT_TRAP_THROWING(aMenuItems->AppendL(menuItem));
       
   902     }
       
   903     
       
   904     TUint8 aSelectedItem( 1 );
       
   905     // aIconId
       
   906     TSatIconId aIconId;
       
   907     aIconId.iIdentifier = iconIdIdentifier;
       
   908     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
   909     // aMenuItemNextActions
       
   910     CArrayFixFlat<TSatAction>* aMenuItemNextActions = 
       
   911           new CArrayFixFlat<TSatAction> (4);
       
   912      QVERIFY(aMenuItemNextActions);
       
   913     // Temp test
       
   914      QT_TRAP_THROWING(aMenuItemNextActions->AppendL(ESatSelectItemAction));
       
   915     // aMenuIcons
       
   916     CArrayFixFlat<TInt>* aMenuIcons = new CArrayFixFlat<TInt>(2);
       
   917     QVERIFY(aMenuIcons);
       
   918     // Temp test
       
   919     QT_TRAP_THROWING(aMenuIcons->AppendL(1));
       
   920     // aIconListQualifier
       
   921     TSatIconQualifier aIconListQualifier = 
       
   922         static_cast<TSatIconQualifier>(iconListQualifier);
       
   923     // TSatSelectionPreference, useless
       
   924     TSatSelectionPreference aSelectionPreference(ESatNoSelectionPreference);
       
   925     TBool aRequestIconDisplayed (EFalse);
       
   926     
       
   927     TSatUiResponse result(ESatSuccess);
       
   928     QT_TRAP_THROWING(result = mSatObserver->SelectItemL(
       
   929                               aText,
       
   930                               *aMenuItems,
       
   931                               aMenuItemNextActions,
       
   932                               defaultItem,
       
   933                               aSelectedItem,
       
   934                               isHelpIsAvailable,
       
   935                               aIconId,
       
   936                               aMenuIcons,
       
   937                               aIconListQualifier,
       
   938                               aRequestIconDisplayed,
       
   939                               aSelectionPreference
       
   940                               ));
       
   941     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectReturnValue);
       
   942     QCOMPARE(exValue, result);
       
   943 
       
   944     delete hText;
       
   945     hText = 0;
       
   946     delete aMenuItems;
       
   947     aMenuItems = 0;
       
   948     delete aMenuItemNextActions;
       
   949     aMenuItemNextActions = 0;
       
   950     delete aMenuIcons;
       
   951     aMenuIcons = 0;
       
   952     qDebug("Ut_CSatUiObserver::testSelectItem <");
       
   953 }
       
   954 
       
   955 // -----------------------------------------------------------------------------
       
   956 // Ut_CSatUiObserver::testSetUpMenu
       
   957 // 
       
   958 // Connects to test object signal and verifies received data.
       
   959 // -----------------------------------------------------------------------------
       
   960 void Ut_CSatUiObserver::testPlayTone_data()
       
   961 {
       
   962     qDebug("Ut_CSatUiObserver::testPlayTone_data >");
       
   963     QTest::addColumn<QString>("text");//enum 0~3
       
   964     QTest::addColumn<int>("satTone");
       
   965     QTest::addColumn<int>("duration");
       
   966     QTest::addColumn<int>("iconIdIdentifier");
       
   967     QTest::addColumn<int>("iconIdQualifier");//enum 0~3
       
   968     QTest::addColumn<bool>("isRequestedIconDisplayed");
       
   969     QTest::addColumn<int>("expectReturnValue");
       
   970     QTest::newRow("Response_Failure") << "PlayStandardTone" << 100 << 
       
   971         0 << 80 << 1 << false << -1;
       
   972     QTest::newRow("ToneNotSet") << "PlayStandardTone" << -1 << 
       
   973         0 << 80<< 0 << false << 0;
       
   974     QTest::newRow("DialTone_0") << "PlayStandardTone" << 1 << 
       
   975         0 << 80<< 1 << false << 0;
       
   976     QTest::newRow("DialTone_2000") << "PlayStandardTone" << 1 << 
       
   977         2000 << 80 << 2 << false << 0;
       
   978     QTest::newRow("DialTone_true") << "PlayStandardTone" << 1 << 
       
   979         2000 << 80 << 3 << true << 0;
       
   980     QTest::newRow("Busy") << "PlayStandardTone" << 2 << 
       
   981         2000 << 80 << 3 << false << 0;
       
   982     QTest::newRow("Congestion") << "PlayStandardTone" << 3 << 
       
   983         25000 << 80 << 3 << false << 0;
       
   984     QTest::newRow("Congestion_0") << "PlayStandardTone" << 3 << 
       
   985         0 << 80 << 3 << false << 0;
       
   986     QTest::newRow("Acknowledge ") << "PlayStandardTone" << 4 << 
       
   987         25000 << 80 << 3 << false << 0;
       
   988     QTest::newRow("Acknowledge_0") << "PlayStandardTone" << 4 << 
       
   989         0 << 80 << 3 << false << 0;
       
   990     QTest::newRow("CallDropped") << "PlayStandardTone" << 5 << 
       
   991         25000 << 80 << 1 << false << 0;
       
   992     QTest::newRow("CallDropped_0") << "PlayStandardTone" << 5 << 
       
   993         0 << 80 << 1 << false << 0;
       
   994     QTest::newRow("SpecialInfo") << "PlayStandardTone" << 6 << 
       
   995         25000 << 80 << 1 << false << 0;
       
   996     QTest::newRow("SpecialInfo_0") << "PlayStandardTone" << 6 << 
       
   997         0 << 80 << 1 << false << 0;
       
   998     QTest::newRow("WaitingTone") << "PlayStandardTone" << 7 << 
       
   999         25000 << 80 << 1 << false << 0;
       
  1000     QTest::newRow("WaitingTone_0") << "PlayStandardTone" << 7 << 
       
  1001         0 << 80 << 1 << false << 0;
       
  1002     QTest::newRow("RingingTone") << "PlayStandardTone" << 8 << 
       
  1003         25000 << 80 << 1 << false << 0;
       
  1004     QTest::newRow("RingingTone_0") << "PlayStandardTone" << 8 << 
       
  1005         0 << 80 << 1 << false << 0;
       
  1006     QTest::newRow("GeneralBeep") << "PlayStandardTone" << 16 << 
       
  1007         25000 << 80 << 1 << false << 0;
       
  1008     QTest::newRow("GeneralBeep_0") << "PlayStandardTone" << 16 << 
       
  1009         0 << 80 << 1 << false << 0;
       
  1010     QTest::newRow("PositiveTone") << "PlayStandardTone" << 17 << 
       
  1011         25000 << 80 << 1 << false << 0;
       
  1012     QTest::newRow("PositiveTone_0") << "PlayStandardTone" << 17 << 
       
  1013         0 << 80 << 1 << false << 0;
       
  1014     QTest::newRow("NegativeTone") << "PlayStandardTone" << 18 << 
       
  1015         25000 << 80 << 1 << false << 0;
       
  1016     QTest::newRow("NegativeTone_0") << "PlayStandardTone" << 18 << 
       
  1017         0 << 80 << 1 << false << 0;
       
  1018     QTest::newRow("Speech") << "PlayStandardTone" << 19 << 
       
  1019         25000 << 80 << 1 << false << 0;
       
  1020     QTest::newRow("Speech_0") << "PlayStandardTone" << 19 << 
       
  1021         25000 << 80 << 1 << false << 0;
       
  1022     QTest::newRow("Sms") << "PlayStandardTone" << 20 << 
       
  1023         25000 << 80 << 1 << false << 0;
       
  1024     QTest::newRow("Sms_0") << "PlayStandardTone" << 20 << 
       
  1025         0 << 80 << 1 << false << 0;
       
  1026     QTest::newRow("Busy_0") << "PlayStandardTone" << 2 << 
       
  1027         0 << 80 << 3 << false << 0;
       
  1028     qDebug("Ut_CSatUiObserver::testPlayTone_data <");
       
  1029 }
       
  1030 
       
  1031 
       
  1032 // -----------------------------------------------------------------------------
       
  1033 // Ut_CSatUiObserver::testSetUpMenu
       
  1034 // 
       
  1035 // Connects to test object signal and verifies received data.
       
  1036 // -----------------------------------------------------------------------------
       
  1037 void Ut_CSatUiObserver::testPlayTone()
       
  1038 {
       
  1039     qDebug("Ut_CSatUiObserver::testPlayTone >");
       
  1040     QVERIFY(mSatObserver);
       
  1041     QFETCH(QString, text);
       
  1042     QFETCH(int, duration);
       
  1043     QFETCH(int, satTone);
       
  1044     QFETCH(int, iconIdIdentifier);
       
  1045     QFETCH(int, iconIdQualifier);
       
  1046     QFETCH(bool, isRequestedIconDisplayed);
       
  1047     QFETCH(int, expectReturnValue);
       
  1048     qDebug("Ut_CSatUiObserver::testPlayTone after fetch");
       
  1049     // text
       
  1050     HBufC* hText = HBufC::New(text.length());
       
  1051     TPtr aText( hText->Des() );
       
  1052     aText.Copy( text.utf16() );
       
  1053     // aTone
       
  1054     TSatTone aTone = static_cast<TSatTone>(satTone);
       
  1055     // aDuration
       
  1056     TUint aDuration= static_cast<TUint>(duration);
       
  1057     // aIconId
       
  1058     TSatIconId aIconId;
       
  1059     aIconId.iIdentifier = iconIdIdentifier;
       
  1060     aIconId.iIconQualifier = static_cast<TSatIconQualifier>(iconIdQualifier);
       
  1061     // aRequestedIconDisplayed
       
  1062     TBool aRequestedIconDisplayed(isRequestedIconDisplayed);
       
  1063     qDebug("Ut_CSatUiObserver::testPlayTone call observer");
       
  1064     TSatUiResponse result(ESatSuccess);
       
  1065     result = mSatObserver->PlayTone(
       
  1066                               aText,
       
  1067                               aTone,
       
  1068                               aDuration,
       
  1069                               aIconId,
       
  1070                               aRequestedIconDisplayed
       
  1071                               );
       
  1072     TSatUiResponse exValue = static_cast<TSatUiResponse>(expectReturnValue);
       
  1073     QCOMPARE(exValue, result);
       
  1074     delete hText;
       
  1075     hText = 0;
       
  1076     qDebug("Ut_CSatUiObserver::testPlayTone <");
       
  1077 }
       
  1078 
       
  1079 // End of file