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