1 /* |
1 /* |
2 * ============================================================================== |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
3 * Name : WidgetRegistrySTIF.cpp |
3 * All rights reserved. |
4 * Part of : STIF for WidgetRegistry |
4 * This component and the accompanying materials are made available |
|
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". |
5 * |
8 * |
6 * Description : CWidgetRegistrySTIF class member functions |
9 * Initial Contributors: |
7 * Version: 1.0 |
10 * Nokia Corporation - initial contribution. |
8 * |
11 * |
9 * Copyright (C) 2007 Nokia Corporation. |
12 * Contributors: |
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. |
|
18 * |
13 * |
19 * ============================================================================ |
14 * Description: CWidgetRegistrySTIF class member functions |
|
15 * |
20 */ |
16 */ |
|
17 |
21 |
18 |
22 // INCLUDE FILES |
19 // INCLUDE FILES |
23 #include <Stiftestinterface.h> |
20 #include <Stiftestinterface.h> |
24 #include "WidgetRegistrySTIF.h" |
21 #include "WidgetRegistrySTIF.h" |
25 |
22 |
357 registryClient = new (ELeave) RWidgetRegistryClientSession; |
347 registryClient = new (ELeave) RWidgetRegistryClientSession; |
358 CleanupStack::PushL( registryClient ); |
348 CleanupStack::PushL( registryClient ); |
359 TInt error = registryClient->Connect(); |
349 TInt error = registryClient->Connect(); |
360 if ( KErrNone == error ) |
350 if ( KErrNone == error ) |
361 { |
351 { |
362 //TBool b = registryClient->WidgetExistsL( KValidBundle ); |
352 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 ); |
|
375 if ( b != EFalse ) |
353 if ( b != EFalse ) |
376 { |
354 { |
377 aResult.SetResult( KErrNone, KPassed ); |
355 aResult.SetResult( KErrNone, KPassed ); |
378 } |
356 } |
379 registryClient->Disconnect(); |
357 registryClient->Disconnect(); |
516 registryClient = new (ELeave) RWidgetRegistryClientSession; |
494 registryClient = new (ELeave) RWidgetRegistryClientSession; |
517 CleanupStack::PushL( registryClient ); |
495 CleanupStack::PushL( registryClient ); |
518 TInt error = registryClient->Connect(); |
496 TInt error = registryClient->Connect(); |
519 if ( KErrNone == error ) |
497 if ( KErrNone == error ) |
520 { |
498 { |
521 RWidgetInfoArray widgetInfoArray; |
499 TInt uid = registryClient->GetWidgetUidL( KValidBundle ); |
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 |
|
535 if ( iValidUid == TUid::Uid( uid ) ) |
500 if ( iValidUid == TUid::Uid( uid ) ) |
536 { |
501 { |
537 aResult.SetResult( KErrNone, KPassed ); |
502 aResult.SetResult( KErrNone, KPassed ); |
538 } |
503 } |
539 registryClient->Disconnect(); |
504 registryClient->Disconnect(); |
829 CleanupStack::PopAndDestroy( registryClient ); |
794 CleanupStack::PopAndDestroy( registryClient ); |
830 return KErrNone; |
795 return KErrNone; |
831 } |
796 } |
832 |
797 |
833 |
798 |
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 |
|
1060 const TCaseInfo CWidgetRegistrySTIF::Case ( const TInt aCaseNumber ) const |
799 const TCaseInfo CWidgetRegistrySTIF::Case ( const TInt aCaseNumber ) const |
1061 { |
800 { |
1062 static TCaseInfoInternal const KCases[] = |
801 static TCaseInfoInternal const KCases[] = |
1063 { |
802 { |
1064 // To add new test cases, add new items to this array |
803 // To add new test cases, add new items to this array |
1130 CWidgetRegistrySTIF::ClientSessionSetActiveL ), |
869 CWidgetRegistrySTIF::ClientSessionSetActiveL ), |
1131 ENTRY( "ClientSession GetLprojName", |
870 ENTRY( "ClientSession GetLprojName", |
1132 CWidgetRegistrySTIF::ClientSessionGetLprojNameL ), |
871 CWidgetRegistrySTIF::ClientSessionGetLprojNameL ), |
1133 ENTRY( "ClientSession SecurityPolicyId", |
872 ENTRY( "ClientSession SecurityPolicyId", |
1134 CWidgetRegistrySTIF::ClientSessionSecurityPolicyId ), |
873 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 ), |
|
1149 |
874 |
1150 }; |
875 }; |
1151 /* |
876 /* |
1152 * To add new test cases, implement new test case function and add new |
877 * To add new test cases, implement new test case function and add new |
1153 * line to KCases array specify the name of the case and the function |
878 * line to KCases array specify the name of the case and the function |