phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuiqtviewadapter/unit_tests.cpp
changeset 78 baacf668fe89
parent 76 cfea66083b62
equal deleted inserted replaced
76:cfea66083b62 78:baacf668fe89
    22 #include <hbapplication.h>
    22 #include <hbapplication.h>
    23 #include <QSignalSpy>
    23 #include <QSignalSpy>
    24 #include <hbmainwindow.h>
    24 #include <hbmainwindow.h>
    25 #include <phoneappcommands.hrh>
    25 #include <phoneappcommands.hrh>
    26 #include <hbmenu.h>
    26 #include <hbmenu.h>
       
    27 #include <hbaction.h>
    27 #include "phoneuiqtviewadapter.h"
    28 #include "phoneuiqtviewadapter.h"
    28 #include "tphonecmdparaminteger.h"
    29 #include "tphonecmdparaminteger.h"
    29 #include "tphonecmdparamaudiooutput.h"
    30 #include "tphonecmdparamaudiooutput.h"
    30 #include "phoneuiqtviewif.h"
    31 #include "phoneuiqtviewif.h"
    31 #include "tphonecmdparamcallstatedata.h"
    32 #include "tphonecmdparamcallstatedata.h"
    73 extern bool m_removeConferenceBubbleCalled;
    74 extern bool m_removeConferenceBubbleCalled;
    74 extern int m_removeCallFromConferenceCallId;
    75 extern int m_removeCallFromConferenceCallId;
    75 extern int m_setPrivateFromConferenceCallId;
    76 extern int m_setPrivateFromConferenceCallId;
    76 extern int m_removeCallHeaderCallId;
    77 extern int m_removeCallHeaderCallId;
    77 extern bool m_isVoiceCall;
    78 extern bool m_isVoiceCall;
       
    79 extern bool m_EPhoneViewPlayHandsFreeActivatedTone_called;
    78 
    80 
    79 // Own assert initialization  
    81 // Own assert initialization  
    80 /*void qt_assert(const char *assertion, const char *file, int line)
    82 /*void qt_assert(const char *assertion, const char *file, int line)
    81 {
    83 {
    82     qDebug () << "View test assert FAIL";
    84     qDebug () << "View test assert FAIL";
    89     TestPhoneUIQtViewAdapter();
    91     TestPhoneUIQtViewAdapter();
    90     virtual ~TestPhoneUIQtViewAdapter();
    92     virtual ~TestPhoneUIQtViewAdapter();
    91 
    93 
    92     // From PhoneUIQtViewIF
    94     // From PhoneUIQtViewIF
    93     BubbleManagerIF& bubbleManager ();
    95     BubbleManagerIF& bubbleManager ();
    94     void addBubbleCommand (int bubbleId, const PhoneAction& action);
    96     void addBubbleCommand (int bubbleId, HbAction *action);
    95     void clearBubbleCommands (int bubbleId);
    97     void clearBubbleCommands (int bubbleId);
    96     void addParticipantListAction(
    98     void addParticipantListAction(
    97             int commandId,  
    99             int commandId,  
    98             const QString &text, 
   100             const QString &text, 
    99             const HbIcon &icon);
   101             const HbIcon &icon);
   100     void clearParticipantListActions();
   102     void clearParticipantListActions();
   101     void hideToolbar () { };
   103     void hideToolbar () { };
   102     void showToolbar () { m_showToolbarCalled = true; };
   104     void showToolbar () { m_showToolbarCalled = true; };
   103     void setToolbarActions (const QList<PhoneAction*>& actions) {m_toolbarActionCount = actions.count(); };
   105     void setToolbarActions (const QList<HbAction *> &actions) {m_toolbarActionCount = actions.count(); };
   104     int volumeSliderValue () { m_volumeSliderValueCalled = true; return 5; };
   106     int volumeSliderValue () { m_volumeSliderValueCalled = true; return 5; };
   105     void removeVolumeSlider () { m_removeVolumeSliderCalled = true; };
   107     void removeVolumeSlider () { m_removeVolumeSliderCalled = true; };
   106     void setVolumeSliderValue (
   108     void setVolumeSliderValue (
   107             int value, 
   109             int value, 
   108             int , 
   110             int , 
   118     return m_isDialpadVisible; }
   120     return m_isDialpadVisible; }
   119     QString dialpadText() {return m_dialpadText;};
   121     QString dialpadText() {return m_dialpadText;};
   120     void clearDialpad() { m_clearDialpadCalled = true; };
   122     void clearDialpad() { m_clearDialpadCalled = true; };
   121     void clearAndHideDialpad() { m_clearAndHideDialpadCalled = true;};
   123     void clearAndHideDialpad() { m_clearAndHideDialpadCalled = true;};
   122     void bringToForeground() {};
   124     void bringToForeground() {};
   123     void setMenuActions(const QList<PhoneAction*>& ) { m_setMenuActionsCalled = true;};
   125 	void hide() {};
       
   126     void setMenuActions(const QList<HbAction *> & ) { m_setMenuActionsCalled = true;};
   124     void shutdownPhoneApp() {};
   127     void shutdownPhoneApp() {};
   125     void setBackButtonVisible(bool ) {};
   128     void setBackButtonVisible(bool ) {};
   126     HbMenu &menuReference(){return m_menu;};
   129     HbMenu &menuReference(){return m_menu;};
   127     void captureKey(Qt::Key key, bool capture) {
   130     void captureKey(Qt::Key key, bool capture) {
   128         m_capturedKey = key;
   131         m_capturedKey = key;
   220     void testSetTouchButtons ();
   223     void testSetTouchButtons ();
   221     void testCreateConferenceBubble ();
   224     void testCreateConferenceBubble ();
   222     void testHandleCommandL ();
   225     void testHandleCommandL ();
   223     void testGetSelectedConferenceMember ();
   226     void testGetSelectedConferenceMember ();
   224     void testSetAudioPath ();
   227     void testSetAudioPath ();
   225     void testMuteRingToneOnAnswer ();
       
   226     void testStopRingTone ();
   228     void testStopRingTone ();
   227     void testMuteRingTone ();
       
   228     void testPlayRingTone ();
   229     void testPlayRingTone ();
   229     void testShowGlobalNote ();
   230     void testShowGlobalNote ();
   230     void testSetExpandActions();
   231     void testSetExpandActions();
   231     void testShowDialpad ();
   232     void testShowDialpad ();
   232     void testDialpadVisibility ();
   233     void testDialpadVisibility ();
   244     void testBeginEndUiUpdate();
   245     void testBeginEndUiUpdate();
   245     void testIndicatorController();
   246     void testIndicatorController();
   246     void testOpenLogs();
   247     void testOpenLogs();
   247     void testSetFlags();
   248     void testSetFlags();
   248     void testCaptureEndKey();
   249     void testCaptureEndKey();
       
   250     void testPlayHandsFreeActivatedTone();
   249 
   251 
   250 private:
   252 private:
   251     PhoneUIQtViewAdapter *m_adapter; // class under test
   253     PhoneUIQtViewAdapter *m_adapter; // class under test
   252     bool m_showToolbarCalled;
   254     bool m_showToolbarCalled;
   253     bool m_updateCallTimeCalled;
   255     bool m_updateCallTimeCalled;
   315 {
   317 {
   316     return *this;
   318     return *this;
   317 }
   319 }
   318 
   320 
   319 void TestPhoneUIQtViewAdapter::addBubbleCommand (
   321 void TestPhoneUIQtViewAdapter::addBubbleCommand (
   320         int bubbleId, const PhoneAction& action)
   322         int bubbleId, HbAction* action)
   321 {
   323 {
   322     if (m_actionMap.keys().contains(bubbleId)) {
   324     if (m_actionMap.keys().contains(bubbleId)) {
   323         m_actionMap.value(bubbleId)->append(action.command());
   325         m_actionMap.value(bubbleId)->append(action->property("command").toInt());
   324     } else {
   326     } else {
   325         QList<int> *list = new QList<int>();
   327         QList<int> *list = new QList<int>();
   326         list->append(action.command());
   328         list->append(action->property("command").toInt());
   327         m_actionMap.insert( bubbleId, list);
   329         m_actionMap.insert( bubbleId, list);
   328     }
   330     }
   329 }
   331 }
   330 
   332 
   331 void TestPhoneUIQtViewAdapter::clearBubbleCommands (int bubbleId)
   333 void TestPhoneUIQtViewAdapter::clearBubbleCommands (int bubbleId)
   406 
   408 
   407 void TestPhoneUIQtViewAdapter::testCallIdByState ()
   409 void TestPhoneUIQtViewAdapter::testCallIdByState ()
   408 {
   410 {
   409     TPhoneCmdParamCallStateData data;
   411     TPhoneCmdParamCallStateData data;
   410     data.SetCallState (EPEStateConnected);
   412     data.SetCallState (EPEStateConnected);
   411     m_adapter->HandleCommandL (EPhoneViewGetCallIdByState, &data);
   413     m_adapter->ExecuteCommand (EPhoneViewGetCallIdByState, &data);
   412     QCOMPARE (data.CallId(), 0);
   414     QCOMPARE (data.CallId(), 0);
   413 }
   415 }
   414 
   416 
   415 void TestPhoneUIQtViewAdapter::testSetToolbarButtons ()
   417 void TestPhoneUIQtViewAdapter::testSetToolbarButtons ()
   416 {
   418 {
   760     m_adapter->ExecuteCommandL(EPhoneViewActivateAudioPathUIChanges, &audioOutput);
   762     m_adapter->ExecuteCommandL(EPhoneViewActivateAudioPathUIChanges, &audioOutput);
   761     QVERIFY( m_phoneButtonFlags == PhoneUIQtButtonsController::Btaa );
   763     QVERIFY( m_phoneButtonFlags == PhoneUIQtButtonsController::Btaa );
   762 
   764 
   763 }
   765 }
   764 
   766 
   765 void TestPhoneUIQtViewAdapter::testMuteRingToneOnAnswer ()
       
   766 {
       
   767     m_adapter->ExecuteCommandL(EPhoneViewMuteRingToneOnAnswer);
       
   768     QVERIFY( m_EPhoneViewMuteRingToneOnAnswer_called == true );
       
   769 }
       
   770 
       
   771 void TestPhoneUIQtViewAdapter::testStopRingTone ()
   767 void TestPhoneUIQtViewAdapter::testStopRingTone ()
   772 {
   768 {
   773     m_adapter->ExecuteCommandL(EPhoneViewStopRingTone);
   769     m_adapter->ExecuteCommandL(EPhoneViewStopRingTone);
   774     QVERIFY( m_EPhoneViewStopRingTone_called == true );
   770     QVERIFY( m_EPhoneViewStopRingTone_called == true );
   775 }
       
   776 
       
   777 void TestPhoneUIQtViewAdapter::testMuteRingTone ()
       
   778 {
       
   779     m_adapter->ExecuteCommandL(EPhoneViewMuteRingTone);
       
   780     QVERIFY( m_EPhoneViewMuteRingTone_called == true );
       
   781 }
   771 }
   782 
   772 
   783 void TestPhoneUIQtViewAdapter::testPlayRingTone ()
   773 void TestPhoneUIQtViewAdapter::testPlayRingTone ()
   784 {
   774 {
   785     TPhoneCmdParamRingTone ringToneParam;
   775     TPhoneCmdParamRingTone ringToneParam;
   831     QVERIFY( m_showDialpadCalled == true );
   821     QVERIFY( m_showDialpadCalled == true );
   832     QVERIFY( m_hideDialpadCalled == false );
   822     QVERIFY( m_hideDialpadCalled == false );
   833     
   823     
   834     m_showDialpadCalled = false;
   824     m_showDialpadCalled = false;
   835     m_hideDialpadCalled = false;
   825     m_hideDialpadCalled = false;
       
   826     m_isDialpadVisible = true;
   836     
   827     
   837     param.SetBoolean(EFalse);
   828     param.SetBoolean(EFalse);
   838     m_adapter->ExecuteCommandL(EPhoneViewSetNumberEntryVisible, &param);
   829     m_adapter->ExecuteCommandL(EPhoneViewSetNumberEntryVisible, &param);
   839     QVERIFY( m_showDialpadCalled == false );
   830     QVERIFY( m_showDialpadCalled == false );
   840     QVERIFY( m_hideDialpadCalled == true );
   831     QVERIFY( m_hideDialpadCalled == true );
  1101     m_adapter->ExecuteCommand(EPhoneViewStopCapturingKey,&captureParam);
  1092     m_adapter->ExecuteCommand(EPhoneViewStopCapturingKey,&captureParam);
  1102     QVERIFY(false == m_captured);
  1093     QVERIFY(false == m_captured);
  1103     QVERIFY(m_capturedKey == Qt::Key_0);
  1094     QVERIFY(m_capturedKey == Qt::Key_0);
  1104 }
  1095 }
  1105 
  1096 
       
  1097 void TestPhoneUIQtViewAdapter::testPlayHandsFreeActivatedTone()
       
  1098 {
       
  1099     m_adapter->ExecuteCommandL(EPhoneViewPlayHandsFreeActivatedTone);
       
  1100     QVERIFY( m_EPhoneViewPlayHandsFreeActivatedTone_called == true );
       
  1101 }
       
  1102 
       
  1103 
  1106 PHONE_UITEST_MAIN(TestPhoneUIQtViewAdapter)
  1104 PHONE_UITEST_MAIN(TestPhoneUIQtViewAdapter)
  1107 #include "unit_tests.moc"
  1105 #include "unit_tests.moc"