webengine/widgetregistry/tsrc/public/basic/src/WidgetRegistrySTIF.cpp
branchRCL_3
changeset 70 8bfb9186a8b8
parent 0 dd21522fd290
child 93 79859ed3eea9
equal deleted inserted replaced
67:4917f9bf7995 70:8bfb9186a8b8
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     2 * ==============================================================================
     3 * All rights reserved.
     3 *  Name        : WidgetRegistrySTIF.cpp
     4 * This component and the accompanying materials are made available
     4 *  Part of     : STIF for WidgetRegistry
     5 * under the terms of the License "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 *
     5 *
     9 * Initial Contributors:
     6 *  Description : CWidgetRegistrySTIF class member functions
    10 * Nokia Corporation - initial contribution.
     7 *  Version:   1.0
    11 *
     8 *
    12 * Contributors:
     9 *  Copyright (C) 2007 Nokia Corporation.
       
    10 *  This material, including documentation and any related
       
    11 *  computer programs, is protected by copyright controlled by
       
    12 *  Nokia Corporation. All rights are reserved. Copying,
       
    13 *  including reproducing, storing,  adapting or translating, any
       
    14 *  or all of this material requires the prior written consent of
       
    15 *  Nokia Corporation. This material also contains confidential
       
    16 *  information which may not be disclosed to others without the
       
    17 *  prior written consent of Nokia Corporation.
    13 *
    18 *
    14 * Description:  CWidgetRegistrySTIF class member functions
    19 * ============================================================================
    15 *
       
    16 */
    20 */
    17 
       
    18 
    21 
    19 // INCLUDE FILES
    22 // INCLUDE FILES
    20 #include <Stiftestinterface.h>
    23 #include <Stiftestinterface.h>
    21 #include "WidgetRegistrySTIF.h"
    24 #include "WidgetRegistrySTIF.h"
    22 
    25 
   150     {
   153     {
   151     aResult.SetResult( KErrGeneral, KFailed );
   154     aResult.SetResult( KErrGeneral, KFailed );
   152     RWidgetRegistryClientSession* registryClient;
   155     RWidgetRegistryClientSession* registryClient;
   153     registryClient = new (ELeave) RWidgetRegistryClientSession;
   156     registryClient = new (ELeave) RWidgetRegistryClientSession;
   154     CleanupStack::PushL( registryClient );
   157     CleanupStack::PushL( registryClient );
   155         TInt error = registryClient->Disconnect();
   158     TInt error = registryClient->Connect();
       
   159     if ( KErrNone == error )
       
   160         error = registryClient->Disconnect();
   156         if ( KErrNone == error )
   161         if ( KErrNone == error )
   157             {
   162             {
   158             aResult.SetResult( KErrNone, KPassed );
   163             aResult.SetResult( KErrNone, KPassed );
   159             }
   164             }
   160     CleanupStack::PopAndDestroy( registryClient );
   165     CleanupStack::PopAndDestroy( registryClient );
   186     CleanupStack::PushL( registryClient );
   191     CleanupStack::PushL( registryClient );
   187     registryClient->Connect();
   192     registryClient->Connect();
   188     RWidgetRegistryClientSession* registryClient2;
   193     RWidgetRegistryClientSession* registryClient2;
   189     registryClient2 = new (ELeave) RWidgetRegistryClientSession;
   194     registryClient2 = new (ELeave) RWidgetRegistryClientSession;
   190     CleanupStack::PushL( registryClient2 );
   195     CleanupStack::PushL( registryClient2 );
       
   196     
       
   197   
       
   198             
       
   199     
   191     TInt error = registryClient2->Connect();
   200     TInt error = registryClient2->Connect();
       
   201    
   192     if ( KErrNone == error )
   202     if ( KErrNone == error )
   193         {
   203         {
   194         aResult.SetResult( KErrNone, KPassed );
   204         aResult.SetResult( KErrNone, KPassed );
   195         }
   205         }
   196     registryClient2->Disconnect();
   206     registryClient2->Disconnect();
   347     registryClient = new (ELeave) RWidgetRegistryClientSession;
   357     registryClient = new (ELeave) RWidgetRegistryClientSession;
   348     CleanupStack::PushL( registryClient );
   358     CleanupStack::PushL( registryClient );
   349     TInt error = registryClient->Connect();
   359     TInt error = registryClient->Connect();
   350     if ( KErrNone == error )
   360     if ( KErrNone == error )
   351         {
   361         {
   352         TBool b = registryClient->WidgetExistsL( KValidBundle );
   362         //TBool b = registryClient->WidgetExistsL( KValidBundle );
       
   363         RWidgetInfoArray widgetInfoArray;
       
   364         error = registryClient->InstalledWidgetsL( widgetInfoArray );
       
   365         CWidgetInfo *myInfo = widgetInfoArray[0];
       
   366         //myInfo->iBundleName;
       
   367         
       
   368            TUid     ValidUid = myInfo->iUid;
       
   369            HBufC*  iWidgetBundleId = HBufC::NewL(KWidgetRegistryVal);
       
   370            TPtr widgetBundleId = iWidgetBundleId->Des();
       
   371             
       
   372         //HBufC BundleID( HBufC16::NewL(1024));
       
   373         registryClient->GetWidgetBundleId( ValidUid , widgetBundleId );
       
   374         TBool b = registryClient->WidgetExistsL( widgetBundleId );
   353         if ( b != EFalse )
   375         if ( b != EFalse )
   354             {
   376             {
   355             aResult.SetResult( KErrNone, KPassed );
   377             aResult.SetResult( KErrNone, KPassed );
   356             }
   378             }
   357         registryClient->Disconnect();
   379         registryClient->Disconnect();
   494     registryClient = new (ELeave) RWidgetRegistryClientSession;
   516     registryClient = new (ELeave) RWidgetRegistryClientSession;
   495     CleanupStack::PushL( registryClient );
   517     CleanupStack::PushL( registryClient );
   496     TInt error = registryClient->Connect();
   518     TInt error = registryClient->Connect();
   497     if ( KErrNone == error )
   519     if ( KErrNone == error )
   498         {
   520         {
   499         TInt uid = registryClient->GetWidgetUidL( KValidBundle );
   521         RWidgetInfoArray widgetInfoArray;
       
   522         error = registryClient->InstalledWidgetsL( widgetInfoArray );
       
   523         CWidgetInfo *myInfo = widgetInfoArray[0];
       
   524         //myInfo->iBundleName;
       
   525     
       
   526        TUid     ValidUid = myInfo->iUid;
       
   527        HBufC*  iWidgetBundleId = HBufC::NewL(KWidgetRegistryVal);
       
   528        TPtr widgetBundleId = iWidgetBundleId->Des();
       
   529         
       
   530       //HBufC BundleID( HBufC16::NewL(1024));
       
   531        
       
   532        registryClient->GetWidgetBundleId( ValidUid , widgetBundleId );
       
   533         TInt uid = registryClient->GetWidgetUidL( widgetBundleId );
       
   534         
   500         if ( iValidUid == TUid::Uid( uid ) )
   535         if ( iValidUid == TUid::Uid( uid ) )
   501             {
   536             {
   502             aResult.SetResult( KErrNone, KPassed );
   537             aResult.SetResult( KErrNone, KPassed );
   503             }
   538             }
   504         registryClient->Disconnect();
   539         registryClient->Disconnect();
   794     CleanupStack::PopAndDestroy( registryClient );
   829     CleanupStack::PopAndDestroy( registryClient );
   795     return KErrNone;
   830     return KErrNone;
   796  }
   831  }
   797 
   832 
   798 
   833 
       
   834 //Added as part of homescreen implementation testcases
       
   835     
       
   836 //Method to verify IsWidgetInFullView API
       
   837  TInt CWidgetRegistrySTIF::ClientSessionIsWidgetInFullViewTest( TTestResult& aResult )
       
   838  {
       
   839     aResult.SetResult( KErrGeneral, KFailed );
       
   840     RWidgetRegistryClientSession* registryClient;
       
   841     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   842     CleanupStack::PushL( registryClient );
       
   843     TInt error = registryClient->Connect();
       
   844     if ( KErrNone == error )
       
   845         {
       
   846     
       
   847     const TInt maxExponent = 32;
       
   848     TAny* Cells[maxExponent];
       
   849     TInt j=0;
       
   850 
       
   851     for (TInt i = 0; i < maxExponent; i++)
       
   852         Cells[i] = 0;
       
   853         
       
   854     
       
   855     for (TInt i = KMaxTInt/2-1; i > 0; )
       
   856     {
       
   857         Cells[j] = User::Alloc(i);
       
   858         if( !( Cells[j] ) )
       
   859         {
       
   860             i/=2;
       
   861         }
       
   862         else
       
   863         {
       
   864             j++;
       
   865         }
       
   866     }
       
   867           TBool iswidgetinfullview = registryClient->IsWidgetInFullView( KNullUid );
       
   868           
       
   869           for (TInt i = 0; i < maxExponent; i++) // release all consumed heap memory
       
   870                       if (Cells[i])
       
   871                        User::Free(Cells[i]);
       
   872           
       
   873           
       
   874           if(EFalse == iswidgetinfullview)
       
   875           {
       
   876              aResult.SetResult( KErrNone, KPassed );    
       
   877           }
       
   878         registryClient->Disconnect();
       
   879         } 
       
   880     CleanupStack::PopAndDestroy( registryClient );
       
   881     return KErrNone;
       
   882  }
       
   883 
       
   884 //Method to verify IsWidgetInMiniView API
       
   885  TInt CWidgetRegistrySTIF::ClientSessionIsWidgetInMiniViewTest( TTestResult& aResult )
       
   886  {
       
   887     aResult.SetResult( KErrGeneral, KFailed );
       
   888     RWidgetRegistryClientSession* registryClient;
       
   889     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   890     CleanupStack::PushL( registryClient );
       
   891     TInt error = registryClient->Connect();
       
   892     if ( KErrNone == error )
       
   893         {
       
   894     
       
   895     const TInt maxExponent = 32;
       
   896        TAny* Cells[maxExponent];
       
   897        TInt j=0;
       
   898 
       
   899        for (TInt i = 0; i < maxExponent; i++)
       
   900            Cells[i] = 0;
       
   901            
       
   902        
       
   903        for (TInt i = KMaxTInt/2-1; i > 0; )
       
   904        {
       
   905            Cells[j] = User::Alloc(i);
       
   906            if( !( Cells[j] ) )
       
   907            {
       
   908                i/=2;
       
   909            }
       
   910            else
       
   911            {
       
   912                j++;
       
   913            }
       
   914        }
       
   915           TBool iswidgetinminiview = registryClient->IsWidgetInMiniView( KNullUid );
       
   916           
       
   917           for (TInt i = 0; i < maxExponent; i++) // release all consumed heap memory
       
   918                                if (Cells[i])
       
   919                                 User::Free(Cells[i]);
       
   920           if(EFalse == iswidgetinminiview)
       
   921           {
       
   922               aResult.SetResult( KErrNone, KPassed );    
       
   923           }
       
   924         registryClient->Disconnect();
       
   925         } 
       
   926     CleanupStack::PopAndDestroy( registryClient );
       
   927     return KErrNone;
       
   928  }
       
   929     
       
   930 //Method to verify IsBlanketPermGranted API
       
   931  TInt CWidgetRegistrySTIF::ClientSessionIsBlanketPermGrantedTest( TTestResult& aResult )
       
   932  {
       
   933     aResult.SetResult( KErrGeneral, KFailed );
       
   934     RWidgetRegistryClientSession* registryClient;
       
   935     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   936     CleanupStack::PushL( registryClient );
       
   937     TInt error = registryClient->Connect();
       
   938     if ( KErrNone == error )
       
   939         {
       
   940             TBool iswidgetgranted = registryClient->IsBlanketPermGranted( KNullUid );
       
   941             if(EFalse == iswidgetgranted)
       
   942             {
       
   943                 aResult.SetResult( KErrNone, KPassed );    
       
   944             }
       
   945         registryClient->Disconnect();
       
   946         } 
       
   947     CleanupStack::PopAndDestroy( registryClient );
       
   948     return KErrNone;
       
   949  }
       
   950     
       
   951     
       
   952 //Method to verify SetminiViewL API
       
   953  TInt CWidgetRegistrySTIF::ClientSessionSetMiniViewTestL( TTestResult& aResult )
       
   954  {
       
   955     aResult.SetResult( KErrGeneral, KFailed );
       
   956     RWidgetRegistryClientSession* registryClient;
       
   957     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   958     CleanupStack::PushL( registryClient );
       
   959     TInt error = registryClient->Connect();
       
   960     if ( KErrNone == error )
       
   961         {
       
   962            registryClient->SetMiniViewL( KNullUid, 0 );
       
   963            aResult.SetResult( KErrNone, KPassed );
       
   964            registryClient->Disconnect();
       
   965         }
       
   966     CleanupStack::PopAndDestroy( registryClient );
       
   967     return KErrNone;
       
   968  }
       
   969 
       
   970 
       
   971 //Method to verify SetFullViewL API
       
   972  TInt CWidgetRegistrySTIF::ClientSessionSetFullViewTestL( TTestResult& aResult )
       
   973  {
       
   974     aResult.SetResult( KErrGeneral, KFailed );
       
   975     RWidgetRegistryClientSession* registryClient;
       
   976     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   977     CleanupStack::PushL( registryClient );
       
   978     TInt error = registryClient->Connect();
       
   979     if ( KErrNone == error )
       
   980         {
       
   981            registryClient->SetFullViewL( KNullUid, 0 );
       
   982            aResult.SetResult( KErrNone, KPassed );
       
   983            registryClient->Disconnect();
       
   984         }
       
   985     CleanupStack::PopAndDestroy( registryClient );
       
   986     return KErrNone;
       
   987  }
       
   988 
       
   989 //Method to verify SetBlanketPermissionL API
       
   990  TInt CWidgetRegistrySTIF::ClientSessionSetBlanketPermissionTestL( TTestResult& aResult )
       
   991  {
       
   992     aResult.SetResult( KErrGeneral, KFailed );
       
   993     RWidgetRegistryClientSession* registryClient;
       
   994     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
   995     CleanupStack::PushL( registryClient );
       
   996     TInt error = registryClient->Connect();
       
   997     if ( KErrNone == error )
       
   998         {
       
   999     const TInt maxExponent = 32;
       
  1000       TAny* Cells[maxExponent];
       
  1001       TInt j=0;
       
  1002 
       
  1003       for (TInt i = 0; i < maxExponent; i++)
       
  1004           Cells[i] = 0;
       
  1005           
       
  1006       
       
  1007       for (TInt i = KMaxTInt/2-1; i > 0; )
       
  1008       {
       
  1009           Cells[j] = User::Alloc(i);
       
  1010           if( !( Cells[j] ) )
       
  1011           {
       
  1012               i/=2;
       
  1013           }
       
  1014           else
       
  1015           {
       
  1016               j++;
       
  1017           }
       
  1018       }     
       
  1019            registryClient->SetBlanketPermissionL( KNullUid, 0 );
       
  1020            
       
  1021            for (TInt i = 0; i < maxExponent; i++) // release all consumed heap memory
       
  1022                                if (Cells[i])
       
  1023                                 User::Free(Cells[i]);
       
  1024            
       
  1025            
       
  1026            aResult.SetResult( KErrNone, KPassed );
       
  1027            registryClient->Disconnect();
       
  1028         }
       
  1029     CleanupStack::PopAndDestroy( registryClient );
       
  1030     return KErrNone;
       
  1031  }
       
  1032  
       
  1033 
       
  1034 //Method to verify WidgetSapiAccessState API
       
  1035  TInt CWidgetRegistrySTIF::ClientSessionWidgetSapiAccessStateTest( TTestResult& aResult )
       
  1036  {
       
  1037     aResult.SetResult( KErrGeneral, KFailed );
       
  1038     RWidgetRegistryClientSession* registryClient;
       
  1039     registryClient = new (ELeave) RWidgetRegistryClientSession;
       
  1040     CleanupStack::PushL( registryClient );
       
  1041     TInt error = registryClient->Connect();
       
  1042     if ( KErrNone == error )
       
  1043         {
       
  1044            TInt aAccessState = registryClient->WidgetSapiAccessState( KNullUid );
       
  1045            if(aAccessState == -1)
       
  1046             {
       
  1047                 aResult.SetResult( KErrNone, KPassed );   
       
  1048             }
       
  1049            else
       
  1050             {
       
  1051                 aResult.SetResult( KErrNone, KFailed );      
       
  1052             }
       
  1053         registryClient->Disconnect();
       
  1054         }
       
  1055     CleanupStack::PopAndDestroy( registryClient );
       
  1056     return KErrNone;
       
  1057  }
       
  1058  
       
  1059  
   799 const TCaseInfo CWidgetRegistrySTIF::Case ( const TInt aCaseNumber ) const
  1060 const TCaseInfo CWidgetRegistrySTIF::Case ( const TInt aCaseNumber ) const
   800     {
  1061     {
   801     static TCaseInfoInternal const KCases[] =
  1062     static TCaseInfoInternal const KCases[] =
   802         {
  1063         {
   803         // To add new test cases, add new items to this array
  1064         // To add new test cases, add new items to this array
   869                CWidgetRegistrySTIF::ClientSessionSetActiveL ),
  1130                CWidgetRegistrySTIF::ClientSessionSetActiveL ),
   870         ENTRY( "ClientSession GetLprojName",
  1131         ENTRY( "ClientSession GetLprojName",
   871                CWidgetRegistrySTIF::ClientSessionGetLprojNameL ),
  1132                CWidgetRegistrySTIF::ClientSessionGetLprojNameL ),
   872         ENTRY( "ClientSession SecurityPolicyId",
  1133         ENTRY( "ClientSession SecurityPolicyId",
   873                CWidgetRegistrySTIF::ClientSessionSecurityPolicyId ),
  1134                CWidgetRegistrySTIF::ClientSessionSecurityPolicyId ),
       
  1135         ENTRY( "ClientSession IsWidgetInFullViewTest",
       
  1136                CWidgetRegistrySTIF::ClientSessionIsWidgetInFullViewTest ),
       
  1137         ENTRY( "ClientSession IsWidgetInMiniViewTest",
       
  1138                CWidgetRegistrySTIF::ClientSessionIsWidgetInMiniViewTest ),
       
  1139         ENTRY( "ClientSession IsBlanketPermGrantedTest",
       
  1140                CWidgetRegistrySTIF::ClientSessionIsBlanketPermGrantedTest ),
       
  1141         ENTRY( "ClientSession SetminiViewTestL",
       
  1142                CWidgetRegistrySTIF::ClientSessionSetMiniViewTestL ),
       
  1143         ENTRY( "ClientSession SetFullViewTestL",
       
  1144                CWidgetRegistrySTIF::ClientSessionSetFullViewTestL ),
       
  1145         ENTRY( "ClientSession SetBlanketPermissionTestL",
       
  1146                CWidgetRegistrySTIF::ClientSessionSetBlanketPermissionTestL ),
       
  1147         ENTRY( "ClientSession WidgetSapiAccessStateTest",
       
  1148                CWidgetRegistrySTIF::ClientSessionWidgetSapiAccessStateTest ),
   874         
  1149         
   875         };
  1150         };
   876     /*
  1151     /*
   877      * To add new test cases, implement new test case function and add new
  1152      * To add new test cases, implement new test case function and add new
   878      * line to KCases array specify the name of the case and the function
  1153      * line to KCases array specify the name of the case and the function