phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuiqtviewadapter/unit_tests.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 27 2f8f8080a020
parent 46 bc5a64e5bc3c
--- a/phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuiqtviewadapter/unit_tests.cpp	Tue Jun 15 14:14:38 2010 +0100
+++ b/phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuiqtviewadapter/unit_tests.cpp	Thu Jul 22 16:33:21 2010 +0100
@@ -34,6 +34,7 @@
 #include "tphonecmdparamemergencycallheaderdata.h"
 #include "tphonecmdparamboolean.h"
 #include "tphonecmdparamringtone.h"
+#include "tphonecmdparamkeycapture.h"
 #include "pevirtualengine.h"
 #include "bubblemanagerif.h"
 #include "phoneresourceids.h"
@@ -41,6 +42,7 @@
 #include "phoneuiqtbuttonscontroller.h"
 #include "tphonecmdparamglobalnote.h"
 #include "tphonecmdparamstring.h"
+#include "phoneindicatorcontroller.h"
 
 extern int m_phoneButtonFlags;
 extern bool m_EPhoneViewMuteRingToneOnAnswer_called;
@@ -56,6 +58,8 @@
 extern bool m_removeQueryCalled;
 extern bool m_showNoteCalled;
 extern bool m_removeGlobalWaitNoteCalled;
+extern bool m_ordinalPositionCalled;
+extern bool m_sendToBackgroundCalled;
 
 
 #define PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestObject) \
@@ -102,86 +106,93 @@
     void removeVolumeSlider () { m_removeVolumeSliderCalled = true; };
     void setVolumeSliderValue (
             int value, 
-            int commandId, 
-            int maxVolumeValue, 
-            int minVolumeValue ) { m_setVolumeSliderValueCalled = true; m_volumeSliderValue = value; };
+            int , 
+            int , 
+            int  ) { m_setVolumeSliderValueCalled = true; m_volumeSliderValue = value; };
 
     void setExpandAction(int bubbleId, int commandId) {m_expandAction[bubbleId]=commandId;};
-    void removeExpandAction(int bubbleId) {};
+    void removeExpandAction(int ) {};
     void showDialpad() {m_showDialpadCalled = true;};  
     void hideDialpad() {m_hideDialpadCalled = true;};  
     bool isDialpadVisible() 
         {m_dialpadVisibilityCalled = true;
     return m_isDialpadVisible; }
     QString dialpadText() {return m_dialpadText;};
+    void clearDialpad() {};
     void clearAndHideDialpad() { m_clearAndHideDialpadCalled = true;};
-    void bringToForeground() {;};
-    void setMenuActions(const QList<PhoneAction*>& actions) { m_setMenuActionsCalled = true;};
-    void shutdownPhoneApp() {;};
-    void setBackButtonVisible(bool visible) {;};
+    void bringToForeground() {};
+    void setMenuActions(const QList<PhoneAction*>& ) { m_setMenuActionsCalled = true;};
+    void shutdownPhoneApp() {};
+    void setBackButtonVisible(bool ) {};
     HbMenu &menuReference(){return m_menu;};
+    void captureKey(Qt::Key key, bool capture) {
+        m_capturedKey = key;
+        m_captured = capture;};
     
     // From BubbleManagerIF
     void startChanges () { m_startChangesCalled=true; };
     void endChanges () { m_endChangesCalled=true; };
     int createCallHeader () { return 0; };
-    void removeCallHeader (int bubbleId) {};
-    void setState (int bubbleId, PhoneCallState state) {};
+    void removeCallHeader (int ) {};
+    void setState (int , PhoneCallState ) {};
     void setLabel ( 
-        int bubbleId, 
-        const QString& text, 
-        Qt::TextElideMode clipDirection) {};
-    void setCli (int bubbleId, 
-                 const QString& cliText, 
-                 Qt::TextElideMode clipDirection) {};
+        int , 
+        const QString& , 
+        Qt::TextElideMode ) {};
+    void setCli (int , 
+                 const QString& , 
+                 Qt::TextElideMode ) {};
     void updateCLI ( 
-        int bubbleId, 
-        const QString& cliText, 
-        Qt::TextElideMode clipDirection) {};
+        int , 
+        const QString& , 
+        Qt::TextElideMode ) {};
     void setSecondaryCli ( 
-        int bubbleId, 
-        const QString& cliText, 
-        Qt::TextElideMode clipDirection = Qt::ElideLeft) {};
-    void setCallTime (int bubbleId, const QString& callTime) {};
+        int , 
+        const QString& , 
+        Qt::TextElideMode ) {};
+    void setCallTime (int , const QString& ) {};
     void updateCallTime (int bubbleId, const QString& callTime) { m_updateCallTimeCalled=true; m_int=bubbleId; m_string=callTime; };
-    void setCallObjectImage (int bubbleId, const QString &fileName) {};
-    void setCallObjectFromTheme (int bubbleId) {};
-    void setCallObjectText (int bubbleId, const QString &text) {};
-    void setCallFlags (int bubbleId, int flags) {};
-    void setCallFlag (int bubbleId, PhoneCallFlags flag, bool set) {};
-    void setNumberType (int bubbleId, PhoneNumberType type) {};
+    void setCallObjectImage (int , const QString &) {};
+    void setCallObjectFromTheme (int ) {};
+    void setCallObjectText (int , const QString &) {};
+    void setCallFlags (int , int ) {};
+    void setCallFlag (int , PhoneCallFlags , bool ) {};
+    void setNumberType (int , PhoneNumberType ) {};
     void updateCallHeaderText( 
-        int bubbleId, 
-        const QString &longText, 
-        const QString &shortText, 
-        Qt::TextElideMode clipDirection) {};
+        int , 
+        const QString &, 
+        const QString &, 
+        Qt::TextElideMode ) {};
     void setPhoneMuted (bool muted) { m_setPhoneMutedCalled = muted; };
-    int createConference (int bubble1, int bubble2) { return 1; };
+    int createConference (int , int ) { return 1; };
     void removeConference () {};
-    void addRowToConference (int bubbleId) {};
-    void removeRowFromConference (int bubbleId) {};
+    void addRowToConference (int ) {};
+    void removeRowFromConference (int ) {};
     int conferenceRowCount () const { return 2; };
-    void setSelectionInConference (int rowNumber) {};
-    void setSelectionIdInConference (int bubbleId) {};
+    void setSelectionInConference (int ) {};
+    void setSelectionIdInConference (int ) {};
     int selectionInConference () const { return 0; };
     int selectionIdInConference () const { return 0; };
     void moveHighlightOneUpInConference () {};
     void moveHighlightOneDownInConference () {};
-    void setExpandedConferenceCallHeader (bool expanded) { m_ExpandConferenceCalled = true; };
+    void setExpandedConferenceCallHeader (bool ) { m_ExpandConferenceCalled = true; };
     bool isConferenceExpanded () const { return false; };
     int shownHeaderCount () const { return 1; };
-    void setParticipantListCli (int aBubbleId, ParticipantListCli aParticipantCli) {};
-    void addAction (int bubble, HbAction *action) {};
-    void clearActions (int bubble) {};
-    QGraphicsWidget* graphicsWidgetForAction (HbAction *action) const { return 0;};
-    void addParticipantListAction (HbAction *action) {};
+    void setParticipantListCli (int , ParticipantListCli ) {};
+    void addAction (int , HbAction *) {};
+    void clearActions (int ) {};
+    QGraphicsWidget* graphicsWidgetForAction (HbAction *) const { return 0;};
+    void addParticipantListAction (HbAction *) {};
     int expandedBubble() const { return 1; };
-    void setExpandAction(int bubbleId, HbAction* action) {};
-    void setBubbleSelectionDisabled(bool b) {};
+    void setExpandAction(int , HbAction* ) {};
+    void setBubbleSelectionDisabled(bool ) {};
+    void setRestrictedMode(bool ) {};
     
 signals:
     void dialpadAboutToClose();
     void keyPressReleased(QKeyEvent *event);
+    void windowActivated();
+    void windowDeactivated();
 
 public slots:
     void initTestCase ();
@@ -234,6 +245,10 @@
     void testCipheringInfoChange();
     void testSetHidden();
     void testBeginEndUiUpdate();
+    void testIndicatorController();
+    void testOpenLogs();
+    void testSetFlags();
+    void testCaptureEndKey();
 
 private:
     PhoneUIQtViewAdapter *m_adapter; // class under test
@@ -261,7 +276,9 @@
     bool m_isDialpadVisible;
     QString m_dialpadText;
     HbMenu m_menu;
-
+    bool m_captured;
+    Qt::Key m_capturedKey;
+    QList<int> mParticipantListActions;
 };
 
 TestPhoneUIQtViewAdapter::TestPhoneUIQtViewAdapter () :
@@ -324,15 +341,15 @@
 
 void TestPhoneUIQtViewAdapter::addParticipantListAction(
     int commandId,
-    const QString& text, 
-    const HbIcon& icon)
+    const QString& , 
+    const HbIcon& )
 {
-
+    mParticipantListActions.append(commandId);
 }
 
 void TestPhoneUIQtViewAdapter::clearParticipantListActions()
 {
-
+    mParticipantListActions.clear();
 }
 
 void TestPhoneUIQtViewAdapter::testEPhoneViewSetTopApplicationCommand ()
@@ -406,6 +423,10 @@
     QVERIFY (m_setCipheringCalled == true);
     
     QVERIFY (m_endChangesCalled == true);
+    
+    QVERIFY (m_setActiveCallCalled == true);
+    
+    
 }
 
 void TestPhoneUIQtViewAdapter::testEPhoneViewCreateEmergencyCallHeader ()
@@ -434,7 +455,9 @@
     
     QVERIFY (m_setCipheringCalled == true);
     
-    QVERIFY (m_endChangesCalled == true);    
+    QVERIFY (m_endChangesCalled == true);
+    
+    QVERIFY (m_setActiveCallCalled == true);
 }
 
 void TestPhoneUIQtViewAdapter::testEPhoneViewUpdateBubble ()
@@ -707,13 +730,13 @@
     m_callStateMap.insert(0, EPEStateConnected);
     m_bubblesMap.insert(0, 0);
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);    
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
     
     //Emergency
     boolParam.SetBoolean(true);
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(false == m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
+    QVERIFY(false == m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
     
     //Held and active
@@ -721,9 +744,9 @@
     m_callStateMap.insert(1, EPEStateHeld);
     m_bubblesMap.insert(1, 1);    
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdCreateConference));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
-    QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdCreateConference));
+    QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdEndThisActiveCall));
     clearBubbleCommands(0);
     clearBubbleCommands(1);
@@ -736,7 +759,7 @@
     m_callStateMap.insert(1, EPEStateRinging);
     m_bubblesMap.insert(1, 1);    
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
     QVERIFY(m_actionMap.value(1)->contains(EPhoneCallComingCmdReject));
     clearBubbleCommands(0);
@@ -750,7 +773,7 @@
     m_callStateMap.insert(1, EPEStateRinging);
     m_bubblesMap.insert(1, 1);    
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdUnhold));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
     QVERIFY(m_actionMap.value(1)->contains(EPhoneCallComingCmdReject));
     clearBubbleCommands(0);
@@ -789,7 +812,8 @@
     m_callStateMap.insert(0, EPEStateDialing);
     m_bubblesMap.insert(0, 0);
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(1==m_actionMap.value(0)->size());
+    QVERIFY(2==m_actionMap.value(0)->size());
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisOutgoingCall));
     clearBubbleCommands(0);
     
@@ -810,7 +834,8 @@
     m_callStateMap.insert(0, EPEStateConnecting);
     m_bubblesMap.insert(0, 0);
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(1==m_actionMap.value(0)->size());
+    QVERIFY(2==m_actionMap.value(0)->size());
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisOutgoingCall));
     clearBubbleCommands(0);
 
@@ -821,16 +846,16 @@
     m_bubblesMap.insert(0, 0);
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
     QVERIFY(2==m_actionMap.value(0)->size());
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
 
     // Conference and held
     m_callStateMap.insert(1, EPEStateHeld);
     m_bubblesMap.insert(1, 1);    
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdSwap));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
-    QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdJoin));
+    QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdMute));
     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdEndThisActiveCall));
     clearBubbleCommands(0);
     clearBubbleCommands(1);
@@ -844,7 +869,7 @@
     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
     QVERIFY(2==m_actionMap.value(0)->size());
     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
-    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdUnhold));
+    QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdMute));
     clearBubbleCommands(0);
     m_conferenceCallList.clear();
     
@@ -886,6 +911,9 @@
     
     m_adapter->ExecuteCommandL (EPhoneViewCreateConference, 3, &callHeader);    
     QVERIFY (m_creataConferenceCalled == true);
+    QVERIFY (mParticipantListActions.count()==2);
+    QVERIFY (mParticipantListActions.at(0)==EPhoneInCallCmdPrivate);
+    QVERIFY (mParticipantListActions.at(1)==EPhoneInCallCmdDrop);
     
     //
     TPhoneCmdParamBoolean  conferenceDataValue;
@@ -894,6 +922,7 @@
     
     m_adapter->ExecuteCommandL(EPhoneViewRemoveConferenceBubble);
     QVERIFY (m_removeConferenceCalled == true);
+    QVERIFY (mParticipantListActions.count()==0);
     
     m_adapter->ExecuteCommandL (EPhoneViewGetCallExistsInConference, 0, &conferenceDataValue);
     QVERIFY (conferenceDataValue.Boolean() == false);
@@ -1269,5 +1298,70 @@
     QVERIFY (m_endChangesCalled == true);
 }
 
+void TestPhoneUIQtViewAdapter::testIndicatorController()
+{
+    connect( this, SIGNAL(windowActivated()), m_adapter, SLOT(handleWindowActivated()));
+    connect( this, SIGNAL(windowDeactivated()), m_adapter, SLOT(handleWindowDeactivated()));
+    emit windowActivated();
+    QVERIFY( m_disableCallIndCalled );
+    emit windowDeactivated();
+    QVERIFY( m_enableCallIndCalled );
+    
+}
+
+void TestPhoneUIQtViewAdapter::testOpenLogs()
+{
+    m_ordinalPositionCalled = false;
+    m_sendToBackgroundCalled = false;
+    TPhoneCmdParamString param;
+    m_adapter->ExecuteCommandL(EPhoneViewLaunchLogs, &param);
+    QVERIFY(m_ordinalPositionCalled);
+    QVERIFY(m_sendToBackgroundCalled);
+}
+
+void TestPhoneUIQtViewAdapter::testSetFlags()
+{
+    TPhoneCmdParamBoolean param;
+    param.SetBoolean( ETrue );
+    m_phoneButtonFlags = 0;
+    
+    m_adapter->ExecuteCommand(EPhoneViewSetBlueToothFlag,&param);
+    m_adapter->ExecuteCommand(EPhoneViewSetIhfFlag,&param);
+    m_adapter->ExecuteCommand(EPhoneViewSetMuteFlag,&param);
+    m_adapter->ExecuteCommand(EPhoneViewSetBluetoothAvailableFlag,&param);
+
+    QVERIFY(m_phoneButtonFlags & PhoneUIQtButtonsController::Ihf);
+    QVERIFY(m_phoneButtonFlags & PhoneUIQtButtonsController::Mute);
+    QVERIFY(m_phoneButtonFlags & PhoneUIQtButtonsController::Btaa);
+    QVERIFY(m_phoneButtonFlags & PhoneUIQtButtonsController::BluetoothAvailable);
+}
+
+void TestPhoneUIQtViewAdapter::testCaptureEndKey()
+{
+    TPhoneCmdParamKeyCapture captureParam;
+    captureParam.SetKeyCode( EKeyNo );
+    m_captured = false;
+    m_capturedKey = Qt::Key_0;
+    
+    m_adapter->ExecuteCommand(EPhoneViewStartCapturingKey,&captureParam);
+    QVERIFY(m_captured);
+    QVERIFY(m_capturedKey == Qt::Key_No);
+   
+    m_adapter->ExecuteCommand(EPhoneViewStopCapturingKey,&captureParam);
+    QVERIFY(false == m_captured);
+    QVERIFY(m_capturedKey == Qt::Key_No);
+    
+    m_capturedKey = Qt::Key_0;
+    captureParam.SetKeyCode( EKeyYes );
+    
+    m_adapter->ExecuteCommand(EPhoneViewStartCapturingKey,&captureParam);
+    QVERIFY(false == m_captured);
+    QVERIFY(m_capturedKey == Qt::Key_0);
+    
+    m_adapter->ExecuteCommand(EPhoneViewStopCapturingKey,&captureParam);
+    QVERIFY(false == m_captured);
+    QVERIFY(m_capturedKey == Qt::Key_0);
+}
+
 PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestPhoneUIQtViewAdapter)
 #include "unit_tests.moc"