services/terminalmodeservice/tsrc/upnptmservertest/src/tmservertestcases.cpp
changeset 26 b6b8e90f9863
parent 24 e9457ebcc4df
child 31 b51a6f4f15ba
equal deleted inserted replaced
24:e9457ebcc4df 26:b6b8e90f9863
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <e32math.h>
    20 #include <e32math.h>
    21 #include "tmservertest.h"
       
    22 #include <ecom/ecom.h>
    21 #include <ecom/ecom.h>
    23 #include "testtimer.h"
       
    24 #include "discoverytesttimer.h"
       
    25 #include <upnpdevice.h>
    22 #include <upnpdevice.h>
    26 #include <upnptmserverdeviceinfo.h>
    23 #include <upnptmserverdeviceinfo.h>
    27 #include <upnpsettings.h>
    24 #include <upnpsettings.h>
       
    25 #include "testtimer.h"
       
    26 #include "discoverytesttimer.h"
       
    27 #include "tmservertest.h"
       
    28 
    28 
    29 
    29 // LOCAL CONSTANTS AND MACROS
    30 // LOCAL CONSTANTS AND MACROS
    30 _LIT8(KTestSvgMimeType,           "image/svg+xml");
    31 _LIT8(KTestSvgMimeType,           "image/svg+xml");
    31 _LIT8(KTmServerDevice,            "urn:schemas-upnp-org:device:TmServerDevice:1" );
    32 _LIT8(KTmServerDevice,            "urn:schemas-upnp-org:device:TmServerDevice:1" );
    32 _LIT8(KTmServerService,           "urn:schemas-upnp-org:service:TmApplicationServer:1" );
    33 _LIT8(KTmServerService,           "urn:schemas-upnp-org:service:TmApplicationServer:1" );
    53 _LIT8(KProfileId,                 "ProfileID");
    54 _LIT8(KProfileId,                 "ProfileID");
    54 _LIT8(KProfileId1,                "profileID");
    55 _LIT8(KProfileId1,                "profileID");
    55 _LIT8(KBackground,                "Background");
    56 _LIT8(KBackground,                "Background");
    56 _LIT8(KForeground,                "Foreground");
    57 _LIT8(KForeground,                "Foreground");
    57 _LIT8(KAppListFilterValue1,       "\"icon@mimetype=\"*svg+xml*\",icon@width=\"*\",icon@height=\"*\",icon@depth=\"*\"\"");
    58 _LIT8(KAppListFilterValue1,       "\"icon@mimetype=\"*svg+xml*\",icon@width=\"*\",icon@height=\"*\",icon@depth=\"*\"\"");
    58 _LIT8(KAppListFilterValue2,       "\"name=\"*nav*\",description=\"*\",appInfo@appCategory=\"*\",displayInfo@contentCategory=\"*\",allowedProfileIDs=\"*\"\"");
    59 _LIT8(KAppListFilterValue2,       "\"name=\"*nav*\",description=\"*\",appInfo@appCategory=\"*\",appInfo@trustLevel=\"*\",displayInfo@contentCategory=\"*\",displayInfo@contentRules=\"*\",displayInfo@trustLevel=\"*\",allowedProfileIDs=\"*\"\"");
    59 _LIT8(KAppListFilterValue3,       "\"name=\"*bluetooth*\",description=\"*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
    60 _LIT8(KAppListFilterValue3,       "\"name=\"*bluetooth*\",description=\"*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",remotingInfo@direction=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
    60 _LIT8(KAppListFilterValue4,       "\"name=\"*\",description=\"*Audio*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
    61 _LIT8(KAppListFilterValue4,       "\"name=\"*\",description=\"*Audio*\",icon@mimetype=\"*svg+xml*\",remotingInfo@protocolID=\"*\",remotingInfo@format=\"*\",appInfo@appCategory=\"*\",audioInfo@audioType=\"*\",resourceStatus=\"free\",signature=\"*\"\"");
    61 _LIT8(KWildCard,                  "*");
    62 _LIT8(KWildCard,                  "*");
    62 _LIT(KIconPathMusicUnLaunched,          "c:\\upnptmserver\\icons\\music_unlaunched.svg");
    63 _LIT(KIconPathMusicUnLaunched,          "c:\\upnptmserver\\icons\\music_unlaunched.svg");
    63 _LIT(KIconPathMusicLaunched,            "c:\\upnptmserver\\icons\\music_launched.svg");
    64 _LIT(KIconPathMusicLaunched,            "c:\\upnptmserver\\icons\\music_launched.svg");
    64 _LIT(KIconPathMaps,                     "c:\\upnptmserver\\icons\\maps.svg");
    65 _LIT(KIconPathMaps,                     "c:\\upnptmserver\\icons\\maps.svg");
    65 _LIT(KIconPathBtA2DpUnLaunched,         "c:\\upnptmserver\\icons\\gallery.svg");
    66 _LIT(KIconPathBtA2DpUnLaunched,         "c:\\upnptmserver\\icons\\gallery.svg");
   243 
   244 
   244     //Start the control point and search for device
   245     //Start the control point and search for device
   245     iSearchDevice = CDiscoverDevice::NewL(*this);    
   246     iSearchDevice = CDiscoverDevice::NewL(*this);    
   246     iTestTimer = CTestTimer::NewL(*this);
   247     iTestTimer = CTestTimer::NewL(*this);
   247     iTestTimer->After(15);
   248     iTestTimer->After(15);
   248     CActiveScheduler::Start();  
   249     CActiveScheduler::Start();      
   249     
       
   250     if ( iDeviceVerified)
   250     if ( iDeviceVerified)
   251         {
   251         {
   252         _LIT( KDescription , "Terminalmode Server Device started successfully");
   252         _LIT( KDescription , "Terminalmode Server Device started successfully");
   253         aResult.SetResult( KErrNone, KDescription );
   253         aResult.SetResult( KErrNone, KDescription );
   254         iLog->Log( KDescription );
   254         iLog->Log( KDescription );
   285     
   285     
   286     //Start the control point and search for device
   286     //Start the control point and search for device
   287     iSearchDevice = CDiscoverDevice::NewL(*this);    
   287     iSearchDevice = CDiscoverDevice::NewL(*this);    
   288     iTestTimer = CTestTimer::NewL(*this);
   288     iTestTimer = CTestTimer::NewL(*this);
   289     iTestTimer->After(15);
   289     iTestTimer->After(15);
   290     CActiveScheduler::Start();  
   290     CActiveScheduler::Start();      
   291     
       
   292     if ( iServiceVerified)
   291     if ( iServiceVerified)
   293         {
   292         {
   294         _LIT( KDescription , "Terminalmode server Service published successfully");
   293         _LIT( KDescription , "Terminalmode server Service published successfully");
   295         aResult.SetResult( KErrNone, KDescription );
   294         aResult.SetResult( KErrNone, KDescription );
   296         iLog->Log( KDescription );
   295         iLog->Log( KDescription );
   326     
   325     
   327     //Start the control point and search for device
   326     //Start the control point and search for device
   328     iSearchDevice = CDiscoverDevice::NewL(*this);    
   327     iSearchDevice = CDiscoverDevice::NewL(*this);    
   329     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   328     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   330     iDiscoveryTestTimer->AfterDiscovery(15);
   329     iDiscoveryTestTimer->AfterDiscovery(15);
   331     CActiveScheduler::Start();
   330     CActiveScheduler::Start(); 
   332  
       
   333     if ( iDeviceVerified  )
   331     if ( iDeviceVerified  )
   334         {
   332         {
   335          //Stop the tmserver device and its services
   333          //Stop the tmserver device and its services
   336          iTmServer->StopL(); 
   334          iTmServer->StopL(); 
   337         }
   335         }    
   338     
   336     iTestTimer = CTestTimer::NewL(*this);
   339     iTestTimer = CTestTimer::NewL(*this);
   337     iTestTimer->After(15);
   340     iTestTimer->After(15);
   338     CActiveScheduler::Start();         
   341     CActiveScheduler::Start();  
       
   342        
       
   343     if ( iDeviceLostVerified )
   339     if ( iDeviceLostVerified )
   344         {
   340         {
   345         _LIT( KDescription , "Terminalmode server Device stopped successfully");
   341         _LIT( KDescription , "Terminalmode server Device stopped successfully");
   346         aResult.SetResult( KErrNone, KDescription );
   342         aResult.SetResult( KErrNone, KDescription );
   347         iLog->Log( KDescription );
   343         iLog->Log( KDescription );
   351         aResult.iResult = KErrGeneral;
   347         aResult.iResult = KErrGeneral;
   352         _LIT( KDescription , "Stopping of Terminalmode server Device Failed");
   348         _LIT( KDescription , "Stopping of Terminalmode server Device Failed");
   353         aResult.SetResult( KErrNone, KDescription );
   349         aResult.SetResult( KErrNone, KDescription );
   354         iLog->Log( KDescription );
   350         iLog->Log( KDescription );
   355         }
   351         }
   356 
   352     delete iDiscoveryTestTimer;
   357     delete iDiscoveryTestTimer;
   353     iDiscoveryTestTimer = NULL;
   358     iDiscoveryTestTimer = NULL;
   354     delete iTestTimer;
   359     delete iTestTimer;
   355     iTestTimer = NULL;
   360     iTestTimer = NULL;
   356     REComSession::FinalClose();
   361     REComSession::FinalClose();
   357     return KErrNone;
   362     return KErrNone;
   358     }
   363     }
       
   364 
       
   365 
   359 
   366 TInt CTmServerTest::ReStartTmServerDeviceL ( TTestResult& aResult )
   360 TInt CTmServerTest::ReStartTmServerDeviceL ( TTestResult& aResult )
   367     {
   361     {
   368    _LIT( KLogInfo, "ReStart Terminalmode server Device" );
   362    _LIT( KLogInfo, "ReStart Terminalmode server Device" );
   369     iLog->Log( KLogInfo );
   363     iLog->Log( KLogInfo );
   384     
   378     
   385     //Start the control point and search for device
   379     //Start the control point and search for device
   386     iSearchDevice = CDiscoverDevice::NewL(*this);    
   380     iSearchDevice = CDiscoverDevice::NewL(*this);    
   387     iTestTimer = CTestTimer::NewL(*this);
   381     iTestTimer = CTestTimer::NewL(*this);
   388     iTestTimer->After(15);
   382     iTestTimer->After(15);
   389     CActiveScheduler::Start(); 
   383     CActiveScheduler::Start();    
   390     
       
   391     if ( iDeviceVerified)
   384     if ( iDeviceVerified)
   392         {
   385         {
   393         _LIT( KDescription , "Terminalmode server Device re-started successfully");
   386         _LIT( KDescription , "Terminalmode server Device re-started successfully");
   394         aResult.SetResult( KErrNone, KDescription );
   387         aResult.SetResult( KErrNone, KDescription );
   395         iLog->Log( KDescription );
   388         iLog->Log( KDescription );
   398         {
   391         {
   399         aResult.iResult = KErrGeneral;
   392         aResult.iResult = KErrGeneral;
   400         _LIT( KDescription , "Re-starting of Terminalmode server Device Failed");
   393         _LIT( KDescription , "Re-starting of Terminalmode server Device Failed");
   401         aResult.SetResult( KErrNone, KDescription );
   394         aResult.SetResult( KErrNone, KDescription );
   402         iLog->Log( KDescription );
   395         iLog->Log( KDescription );
   403         }
   396         }    
   404     
   397     delete iTestTimer;
   405     delete iTestTimer;
   398     iTestTimer = NULL;
   406     iTestTimer = NULL;
   399     REComSession::FinalClose();
   407     REComSession::FinalClose();
   400     return KErrNone;
   408     return KErrNone;
   401     } 
   409     }    
       
   410 
       
   411 
   402 
   412 TInt CTmServerTest::RegisterDuplicateAppL(  TTestResult& aResult  )
   403 TInt CTmServerTest::RegisterDuplicateAppL(  TTestResult& aResult  )
   413     {   
   404     {   
   414     _LIT( KLogInfo, "Register Duplicate Application" );
   405     _LIT( KLogInfo, "Register Duplicate Application" );
   415     iLog->Log( KLogInfo );
   406     iLog->Log( KLogInfo );
   546     
   537     
   547     REComSession::FinalClose();
   538     REComSession::FinalClose();
   548     return KErrNone;
   539     return KErrNone;
   549     }
   540     }
   550 
   541 
   551 
       
   552 TInt CTmServerTest::UnRegisterAppL(  TTestResult& aResult  )
   542 TInt CTmServerTest::UnRegisterAppL(  TTestResult& aResult  )
   553     {
   543     {
   554     _LIT( KLogInfo, "UnRegister Application" );
   544     _LIT( KLogInfo, "UnRegister Application" );
   555     iLog->Log( KLogInfo );
   545     iLog->Log( KLogInfo );
   556 
   546 
   676     REComSession::FinalClose();
   666     REComSession::FinalClose();
   677     return KErrNone;
   667     return KErrNone;
   678     }
   668     }
   679 
   669 
   680 TInt CTmServerTest::HandleEventDuplicateAppStatusUpdateL( TTestResult& aResult )
   670 TInt CTmServerTest::HandleEventDuplicateAppStatusUpdateL( TTestResult& aResult )
   681  {
   671     {
   682     _LIT( KLogInfo, "Handle Event For Duplicate AppStatus Update" );
   672     _LIT( KLogInfo, "Handle Event For Duplicate AppStatus Update" );
   683     iLog->Log( KLogInfo ); 
   673     iLog->Log( KLogInfo ); 
   684           
   674           
   685     iTmServerDeviceType = ETrue;
   675     iTmServerDeviceType = ETrue;
   686     //Sets the information associated with the terminal mode server device
   676     //Sets the information associated with the terminal mode server device
   694     iTmServer ->StartL();
   684     iTmServer ->StartL();
   695     //Start the control point and search for device
   685     //Start the control point and search for device
   696     iSearchDevice = CDiscoverDevice::NewL(*this);          
   686     iSearchDevice = CDiscoverDevice::NewL(*this);          
   697     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   687     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   698     iDiscoveryTestTimer->AfterDiscovery(15);
   688     iDiscoveryTestTimer->AfterDiscovery(15);
   699     CActiveScheduler::Start();     
   689     CActiveScheduler::Start();   
   700           
   690     	         
   701     if ( iDeviceVerified  )
   691     if ( iDeviceVerified  )
   702          { 
   692          { 
   703              //Subscribe to Services
   693              //Subscribe to Services
   704            iSearchDevice->SubscribeToServiceL();         
   694            iSearchDevice->SubscribeToServiceL();         
   705           }  
   695           }    
   706   
       
   707     RArray<TUint> updatedAppIdList;
   696     RArray<TUint> updatedAppIdList;
   708     updatedAppIdList.Append(KAppId1Value);
   697     updatedAppIdList.Append(KAppId1Value);
   709     updatedAppIdList.Append(KAppId1Value);
   698     updatedAppIdList.Append(KAppId1Value);
   710     //Update the status of applications which have undergone some change
   699     //Update the status of applications which have undergone some change
   711     iTmServer->UpdateAppStatusL(updatedAppIdList); 
   700     iTmServer->UpdateAppStatusL(updatedAppIdList); 
   735     REComSession::FinalClose();
   724     REComSession::FinalClose();
   736     return KErrNone;
   725     return KErrNone;
   737   }
   726   }
   738 
   727 
   739 TInt CTmServerTest::HandleEventProfileIdListStatusUpdateL( TTestResult& aResult )
   728 TInt CTmServerTest::HandleEventProfileIdListStatusUpdateL( TTestResult& aResult )
   740  {
   729     {
   741     _LIT( KLogInfo, "Handle Event For ProfileIdList Status Update" );
   730     _LIT( KLogInfo, "Handle Event For ProfileIdList Status Update" );
   742     iLog->Log( KLogInfo ); 
   731     iLog->Log( KLogInfo ); 
   743     
   732     
   744     iTmServerDeviceType = ETrue;
   733     iTmServerDeviceType = ETrue;
   745     //Sets the information associated with the terminal mode server device
   734     //Sets the information associated with the terminal mode server device
   765 
   754 
   766     RArray<TUint> UnusedProfileIdList;
   755     RArray<TUint> UnusedProfileIdList;
   767     UnusedProfileIdList.Append(5);
   756     UnusedProfileIdList.Append(5);
   768     UnusedProfileIdList.Append(6);
   757     UnusedProfileIdList.Append(6);
   769     //Update the list of profile IDs for profiles which are not used
   758     //Update the list of profile IDs for profiles which are not used
   770     iTmServer->UpdateUnusedProfileIdsL(UnusedProfileIdList);  
   759     iTmServer->UpdateUnusedProfileIdsL(UnusedProfileIdList);     
   771     
       
   772     iTestTimer = CTestTimer::NewL(*this);
   760     iTestTimer = CTestTimer::NewL(*this);
   773     iTestTimer->After(15);
   761     iTestTimer->After(15);
   774     CActiveScheduler::Start();
   762     CActiveScheduler::Start();
   775 
   763 
   776     if ( iStatusNotified )
   764     if ( iStatusNotified )
   792        iDiscoveryTestTimer = NULL;
   780        iDiscoveryTestTimer = NULL;
   793        delete iTestTimer;
   781        delete iTestTimer;
   794        iTestTimer = NULL;
   782        iTestTimer = NULL;
   795        REComSession::FinalClose();
   783        REComSession::FinalClose();
   796        return KErrNone;
   784        return KErrNone;
   797 }
   785    }
   798 
   786 
   799 TInt CTmServerTest::HandleLaunchAppActionL ( TTestResult& aResult )
   787 TInt CTmServerTest::HandleLaunchAppActionL ( TTestResult& aResult )
   800     {
   788     {
   801     _LIT( KLogInfo, "Handle LaunchApp Command" );
   789     _LIT( KLogInfo , "Handle LaunchApp Command" );
   802     iLog->Log( KLogInfo );
   790     iLog->Log( KLogInfo );
   803     
   791     
   804     iTmServerDeviceType = ETrue;
   792     iTmServerDeviceType = ETrue;
   805 
   793 
   806     //Sets the information associated with the terminal mode server device
   794     //Sets the information associated with the terminal mode server device
   815     //Start the control point and search for device
   803     //Start the control point and search for device
   816     iSearchDevice = CDiscoverDevice::NewL(*this);    
   804     iSearchDevice = CDiscoverDevice::NewL(*this);    
   817     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   805     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
   818     iDiscoveryTestTimer->AfterDiscovery(15);
   806     iDiscoveryTestTimer->AfterDiscovery(15);
   819     CActiveScheduler::Start(); 
   807     CActiveScheduler::Start(); 
   820 
   808     	
   821     if ( iDeviceVerified  )
   809     if ( iDeviceVerified  )
   822         {
   810         {
   823          //Launch the application remotely by specifying appId and profileId 
   811          //Launch the application remotely by specifying appId and profileId 
   824          iSearchDevice->LaunchAppActionL(KAppId1Value,KProfileIdValue);
   812          iSearchDevice->LaunchAppActionL(KAppId1Value,KProfileIdValue);
   825         }   
   813         }   
  1659 
  1647 
  1660     //Start the control point and search for device
  1648     //Start the control point and search for device
  1661     iSearchDevice = CDiscoverDevice::NewL(*this);    
  1649     iSearchDevice = CDiscoverDevice::NewL(*this);    
  1662     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
  1650     iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this);
  1663     iDiscoveryTestTimer->AfterDiscovery(15);
  1651     iDiscoveryTestTimer->AfterDiscovery(15);
  1664     CActiveScheduler::Start();  
  1652     CActiveScheduler::Start(); 
  1665        
  1653     	       
  1666     if ( iDeviceVerified  )
  1654     if ( iDeviceVerified  )
  1667          {
  1655          {
  1668           //Subscribes to a service 
  1656           //Subscribes to a service 
  1669           iSearchDevice->SubscribeToServiceL();
  1657           iSearchDevice->SubscribeToServiceL();
  1670          }
  1658          }
  1700     REComSession::FinalClose();
  1688     REComSession::FinalClose();
  1701     return KErrNone;
  1689     return KErrNone;
  1702   }
  1690   }
  1703 
  1691 
  1704 TInt CTmServerTest::HandleEventAppListUpdateL( TTestResult& aResult )
  1692 TInt CTmServerTest::HandleEventAppListUpdateL( TTestResult& aResult )
  1705  {
  1693     {
  1706     _LIT( KLogInfo, "Handle Event For AppList Update" );
  1694     _LIT( KLogInfo, "Handle Event For AppList Update" );
  1707     iLog->Log( KLogInfo ); 
  1695     iLog->Log( KLogInfo ); 
  1708        
  1696        
  1709     iTmServerDeviceType = ETrue;
  1697     iTmServerDeviceType = ETrue;
  1710     //Sets the information associated with the terminal mode server device
  1698     //Sets the information associated with the terminal mode server device
  3678     else if ( aProfileId == 1 )
  3666     else if ( aProfileId == 1 )
  3679        {
  3667        {
  3680        // different mime type and different dimension
  3668        // different mime type and different dimension
  3681        clientIconPref = CUpnpTmClientIconPref::NewL(1);
  3669        clientIconPref = CUpnpTmClientIconPref::NewL(1);
  3682        clientIconPref->SetMimeTypeL(_L8("image/bmp"));
  3670        clientIconPref->SetMimeTypeL(_L8("image/bmp"));
  3683        clientIconPref->SetWidth(60);
  3671        clientIconPref->SetWidth(70);
  3684        clientIconPref->SetHeight(60);   
  3672        clientIconPref->SetHeight(80);   
  3685        }
  3673        }
  3686     else if ( aProfileId == 2 )
  3674     else if ( aProfileId == 2 )
  3687        {
  3675        {
  3688        // different mime type and no dimension specified by the client
  3676        // different mime type and no dimension specified by the client
  3689        clientIconPref = CUpnpTmClientIconPref::NewL(2); 
  3677        clientIconPref = CUpnpTmClientIconPref::NewL(2); 
  3692     else if ( aProfileId == 3 )
  3680     else if ( aProfileId == 3 )
  3693        {
  3681        {
  3694        // same mime type but different dimension
  3682        // same mime type but different dimension
  3695        clientIconPref = CUpnpTmClientIconPref::NewL(3);
  3683        clientIconPref = CUpnpTmClientIconPref::NewL(3);
  3696        clientIconPref->SetMimeTypeL(_L8("image/svg+xml"));
  3684        clientIconPref->SetMimeTypeL(_L8("image/svg+xml"));
  3697        clientIconPref->SetWidth(36);
  3685        clientIconPref->SetWidth(100);
  3698        clientIconPref->SetHeight(44);       
  3686        clientIconPref->SetHeight(100);       
  3699        }
  3687        }
  3700     else if ( aProfileId == 4 )
  3688     else if ( aProfileId == 4 )
  3701        {
  3689        {
  3702        // same mime type but no dimension specified by the client
  3690        // same mime type but no dimension specified by the client
  3703        clientIconPref = CUpnpTmClientIconPref::NewL(4);
  3691        clientIconPref = CUpnpTmClientIconPref::NewL(4);