mmsharing/livecommsui/lcuiengine/tsrc/ut_lcuieng/src/ut_lcuiengine.cpp
changeset 34 01f0bb65bcf1
parent 29 36d7ded3ca23
child 39 4bcc59142325
equal deleted inserted replaced
29:36d7ded3ca23 34:01f0bb65bcf1
    38 #include <hbview.h>
    38 #include <hbview.h>
    39 
    39 
    40 #include <xqsettingsmanager.h>
    40 #include <xqsettingsmanager.h>
    41 #include <xqsettingskey.h>
    41 #include <xqsettingskey.h>
    42 #include <settingsinternalcrkeys.h>
    42 #include <settingsinternalcrkeys.h>
       
    43 #include <telincallvolcntrlcrkeys.h>
    43 
    44 
    44 const char lcutMultimediaSharingEng[] = "MultimediaSharing";
    45 const char lcutMultimediaSharingEng[] = "MultimediaSharing";
    45 const char lcutVideotelephonyEng[] = "Videotelephony";
    46 const char lcutVideotelephonyEng[] = "Videotelephony";
    46 
    47 
    47 const char lcutMultimediaSharingApp[] = "Multimedia Sharing";
    48 const char lcutMultimediaSharingApp[] = "Multimedia Sharing";
   416     lcutStub_LcEngine_setLcFeatureSupported( true );
   417     lcutStub_LcEngine_setLcFeatureSupported( true );
   417     mEngine->d->StateChanged( *LC_SESSION( mEngine ) );
   418     mEngine->d->StateChanged( *LC_SESSION( mEngine ) );
   418     QVERIFY( mEngine->d->mShareOwnVideoQuery );
   419     QVERIFY( mEngine->d->mShareOwnVideoQuery );
   419     QVERIFY( mEngine->d->mShareOwnVideoQuery->isVisible() );
   420     QVERIFY( mEngine->d->mShareOwnVideoQuery->isVisible() );
   420     CLcVideoPlayer* localPlayer = LC_SESSION( mEngine )->iLocalPlayer;
   421     CLcVideoPlayer* localPlayer = LC_SESSION( mEngine )->iLocalPlayer;
   421     //QVERIFY( localPlayer->iState == MLcVideoPlayer::EPaused );
   422     localPlayer = 0;
   422     
   423     
   423     // MO call and sharing own video allowed by default , popup query not shown
   424     // MO call and sharing own video allowed by default , popup query not shown
   424     lcutStub_LcSession_reset();
   425     lcutStub_LcSession_reset();
   425     lcutStub_LcPlayer_reset();
   426     lcutStub_LcPlayer_reset();
   426     mShareOwnVideoQuery->hide();
   427     mShareOwnVideoQuery->hide();
   428     LC_SESSION( mEngine )->iState = MLcSession::EOpen;
   429     LC_SESSION( mEngine )->iState = MLcSession::EOpen;
   429     lcutStub_LcEngine_setLcFeatureSupported( false );
   430     lcutStub_LcEngine_setLcFeatureSupported( false );
   430     mEngine->d->StateChanged( *LC_SESSION( mEngine ) );    
   431     mEngine->d->StateChanged( *LC_SESSION( mEngine ) );    
   431     QVERIFY( mEngine->d->mShareOwnVideoQuery );
   432     QVERIFY( mEngine->d->mShareOwnVideoQuery );
   432     QVERIFY( !mEngine->d->mShareOwnVideoQuery->isVisible() );
   433     QVERIFY( !mEngine->d->mShareOwnVideoQuery->isVisible() );
   433     localPlayer = LC_SESSION( mEngine )->iLocalPlayer;
       
   434     QVERIFY( localPlayer->iState == MLcVideoPlayer::EPlaying );
       
   435         
   434         
   436 }
   435 }
   437 
   436 
   438 void UT_LcUiEngine::testPlayerStateChanged()
   437 void UT_LcUiEngine::testPlayerStateChanged()
   439 {
   438 {
   832     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall,1 ) );
   831     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall,1 ) );
   833 }
   832 }
   834 
   833 
   835 void UT_LcUiEngine::testStop()
   834 void UT_LcUiEngine::testStop()
   836 {
   835 {
   837     // Ensure that in MLcSession::EClosing state, "stopped" signal won't be emited
   836     // Ensure that in MLcSession::EOpen state, "stopped" signal won't be emited
   838     // Check also that session duration timer is stopped
   837     // Check also that session duration timer is stopped
   839     LC_SESSION( mEngine )->iState = MLcSession::EClosing;
   838     LC_SESSION( mEngine )->iState = MLcSession::EOpen;
   840     mEngine->d->startSessionDurationTimer();
   839     mEngine->d->startSessionDurationTimer();
   841     QVERIFY( mEngine->d->mSessionDurationTimerId != 0 );
   840     QVERIFY( mEngine->d->mSessionDurationTimerId != 0 );
   842     QSignalSpy spy(mEngine, SIGNAL(stopped()));
   841     QSignalSpy spy(mEngine, SIGNAL(stopped()));
   843     mEngine->d->mActivityManager->enableActivitySimulation(true);
   842     mEngine->d->mActivityManager->enableActivitySimulation(true);
   844     mEngine->d->stop();
   843     mEngine->d->stop();
   846     QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) );
   845     QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) );
   847     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) );
   846     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) );
   848     QCOMPARE( spy.count(), 0 );
   847     QCOMPARE( spy.count(), 0 );
   849     QVERIFY( mEngine->d->mSessionDurationTimerId == 0 );
   848     QVERIFY( mEngine->d->mSessionDurationTimerId == 0 );
   850 
   849 
   851     // Ensure that any other state than MLcSession::EClosing, will cause emition
   850     // Ensure that MLcSession::EClosed, will cause emition of "stopped" signal
   852     // of "stopped" signal
   851     lcutStub_LcSession_reset();
   853     lcutStub_LcSession_reset();
   852     lcutStub_LcPlayer_reset();
   854     lcutStub_LcPlayer_reset();
   853     LC_SESSION( mEngine )->iState = MLcSession::EClosed;
   855     LC_SESSION( mEngine )->iState = MLcSession::EInitialized;
       
   856     mEngine->d->stop();
   854     mEngine->d->stop();
   857     QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) );
   855     QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) );
   858     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) );
   856     QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) );
   859     QCOMPARE( spy.count(), 1 );
   857     QCOMPARE( spy.count(), 1 );
   860 }
   858 }
  1204     //Dumy test: Ensure Conversion does not cause any problem.
  1202     //Dumy test: Ensure Conversion does not cause any problem.
  1205     QVERIFY( mEngine->d->SendDialTone('3') );
  1203     QVERIFY( mEngine->d->SendDialTone('3') );
  1206 }
  1204 }
  1207 
  1205 
  1208 
  1206 
  1209 void UT_LcUiEngine::testVtVideoSendingSetting() 
       
  1210 {
       
  1211     int settingsKeyValueDoNotShow = 1;
       
  1212     if (!setVtVideoSendingSetting(settingsKeyValueDoNotShow))
       
  1213         QFAIL("Writing test key to central repository failed.");
       
  1214     QCOMPARE(mEngine->d->vtVideoSendingSetting(), settingsKeyValueDoNotShow);
       
  1215 }
       
  1216 
       
  1217 
       
  1218 void UT_LcUiEngine::testShareVideoIsAllowedShownAutomatically() 
  1207 void UT_LcUiEngine::testShareVideoIsAllowedShownAutomatically() 
  1219 {
  1208 {
       
  1209     lcutStub_LcEngine_setLcFeatureSupported( false );
  1220     mShareOwnVideoQuery->hide();
  1210     mShareOwnVideoQuery->hide();
  1221     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1211     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1222     int settingsKeyValueShowAutomatically = 2;
  1212     mEngine->d->showSendVideoQueryWhenNecessary();
  1223     if (!setVtVideoSendingSetting(settingsKeyValueShowAutomatically))
       
  1224         QFAIL("Writing test key to central repository failed.");
       
  1225     QVERIFY(mEngine->d->isAllowedToShareVideo());
       
  1226     QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible());
  1213     QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible());
  1227 }
  1214 }
  1228 
  1215 
  1229 
  1216 
  1230 void UT_LcUiEngine::testShareVideoIsNotAllowedShown() 
  1217 void UT_LcUiEngine::testShareVideoIsNotAllowedShown() 
  1231 {
  1218 {
       
  1219     lcutStub_LcEngine_setLcFeatureSupported( false );
  1232     mShareOwnVideoQuery->hide();
  1220     mShareOwnVideoQuery->hide();
  1233     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1221     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1234     int settingsKeyValueDoNotShow = 1;
  1222     mEngine->d->showSendVideoQueryWhenNecessary();
  1235     if (!setVtVideoSendingSetting(settingsKeyValueDoNotShow))
       
  1236         QFAIL("Writing test key to central repository failed.");
       
  1237     QVERIFY(!mEngine->d->isAllowedToShareVideo());
       
  1238     QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible());    
  1223     QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible());    
  1239 }
  1224 }
  1240 
  1225 
  1241 
  1226 
  1242 void UT_LcUiEngine::testShareVideoPermissionAskedAlways() 
  1227 void UT_LcUiEngine::testShareVideoPermissionAskedAlways() 
  1243 {
  1228 {
       
  1229     lcutStub_LcEngine_setLcFeatureSupported( true );
  1244     mShareOwnVideoQuery->hide();
  1230     mShareOwnVideoQuery->hide();
  1245     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1231     mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery);
  1246     int settingsKeyValueAlwaysAsk = 0;
  1232     mEngine->d->showSendVideoQueryWhenNecessary();
  1247     if (!setVtVideoSendingSetting(settingsKeyValueAlwaysAsk))
       
  1248         QFAIL("Writing test key to central repository failed.");
       
  1249     QVERIFY(!mEngine->d->isAllowedToShareVideo());
       
  1250     QVERIFY(mEngine->d->mShareOwnVideoQuery && mEngine->d->mShareOwnVideoQuery->isVisible());
  1233     QVERIFY(mEngine->d->mShareOwnVideoQuery && mEngine->d->mShareOwnVideoQuery->isVisible());
  1251 }
  1234 }
  1252 
  1235 
  1253 
  1236 
  1254 bool UT_LcUiEngine::setVtVideoSendingSetting(int key)
  1237 void UT_LcUiEngine::testVolumeLevelChanged()
  1255 {
  1238 {
  1256     QVariant settingsKeyValue(key);  
  1239     // Subscribe to the events.
  1257     XQSettingsManager settings;
  1240     mEngine->d->subscribeVolumeEvents();
  1258     XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, 
  1241 
  1259                               KCRUidTelephonySettings.iUid, 
  1242     QSignalSpy spy(mEngine, SIGNAL(volumeChanged(int)));
  1260                               KSettingsVTVideoSending);
  1243     QCOMPARE( spy.count(), 0 );
  1261     return settings.writeItemValue(settingsKey, settingsKeyValue);
  1244 
  1262 }
  1245     
       
  1246     //Test1: Known Key Event handled
       
  1247     QVariant value;
       
  1248     value.setValue(5);
       
  1249     
       
  1250     XQSettingsKey validKey1(XQSettingsKey::TargetCentralRepository, 
       
  1251                             KCRUidInCallVolume.iUid, KTelIncallEarVolume);
       
  1252     mEngine->d->volumeLevelChanged(validKey1, value);
       
  1253     QCOMPARE( spy.count(), 1 );
       
  1254     spy.clear();
       
  1255 
       
  1256     
       
  1257     //Test2: Known Key Event-2 handled
       
  1258     XQSettingsKey validKey2(XQSettingsKey::TargetCentralRepository, 
       
  1259                             KCRUidInCallVolume.iUid,KTelIncallLoudspeakerVolume);
       
  1260     mEngine->d->volumeLevelChanged(validKey2, value);
       
  1261     QCOMPARE( spy.count(), 1 );
       
  1262     spy.clear();
       
  1263     
       
  1264     //Test3: Unknow Key Event Ignored.
       
  1265     XQSettingsKey unKnownKey(XQSettingsKey::TargetCentralRepository, 
       
  1266                             787,899);
       
  1267     mEngine->d->volumeLevelChanged(unKnownKey, value);
       
  1268     QCOMPARE( spy.count(), 0 );
       
  1269     
       
  1270     // Un-Subscribe Events.
       
  1271     mEngine->d->unSubscribeVolumeEvents();
       
  1272 }
       
  1273 
       
  1274 
       
  1275 
       
  1276 // End of file