|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The following test case is used to test whether untrusted applications |
|
15 // are able to override MIME types mappings using InsertDataMappingIfHigher API. |
|
16 // It is to ensure that priority checking mechanism (downgrading priority of |
|
17 // untrusted apps) works as was designed. |
|
18 // |
|
19 // t_datatypemappingwithsid1.cpp |
|
20 // |
|
21 |
|
22 /** |
|
23 @file t_datatypemappingwithsid1.cpp |
|
24 @internalComponent - Internal Symbian test code |
|
25 */ |
|
26 |
|
27 #include "T_DataTypeMappingWithSid1.h" |
|
28 #include "tstapp.h" |
|
29 #include "testableapalssession.h" |
|
30 #include "appfwk_test.h" |
|
31 |
|
32 /** |
|
33 @SYMTestCaseID APPFWK-APPARC-0036 |
|
34 |
|
35 @SYMPREQ Policing server apis |
|
36 |
|
37 @SYMTestCaseDesc Testing whether untrusted applications are able to override MIME types mapping |
|
38 |
|
39 @SYMTestPriority High |
|
40 |
|
41 @SYMTestStatus Implemented |
|
42 |
|
43 @SYMTestActions To connect to RApaLsSession and try to register trusted and untrusted apps for mime types. |
|
44 @SYMTestExpectedResults Test should complete without any panic. |
|
45 |
|
46 */ |
|
47 void CT_DataTypeMappingWithSid1::ExecuteL(RApaLsSession& aLs) |
|
48 { |
|
49 TInt ret; |
|
50 TBool added=EFalse; |
|
51 _LIT8(KLitAudioFake, "audio/fakedata"); |
|
52 |
|
53 TDataType dataType( KLitAudioFake ); |
|
54 |
|
55 TUid trustedAppUid = {0x10207f8f}; |
|
56 TUid untrustedAppUid = {0xA3010010}; |
|
57 TUid retAppUid( KNullUid ); |
|
58 |
|
59 ret=aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, trustedAppUid); |
|
60 INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityHigh")); |
|
61 INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
62 TEST(ret==KErrNone); |
|
63 ret = aLs.AppForDataType(dataType,retAppUid); |
|
64 INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
65 TEST(ret==KErrNone); |
|
66 INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); |
|
67 TEST(retAppUid == trustedAppUid); |
|
68 |
|
69 ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, untrustedAppUid, added); |
|
70 INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); |
|
71 INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
72 TEST(ret==KErrNone); |
|
73 ret = aLs.AppForDataType(dataType,retAppUid); |
|
74 INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
75 TEST(ret==KErrNone); |
|
76 INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), untrustedAppUid, retAppUid); |
|
77 TEST(retAppUid == untrustedAppUid); |
|
78 |
|
79 ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, trustedAppUid, added); |
|
80 INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); |
|
81 INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
82 TEST(ret==KErrNone); |
|
83 ret = aLs.AppForDataType(dataType,retAppUid); |
|
84 INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
85 TEST(ret==KErrNone); |
|
86 INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); |
|
87 TEST(retAppUid == trustedAppUid); |
|
88 |
|
89 ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh+1, untrustedAppUid, added); |
|
90 INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with KDataTypePriorityTrustedHigh+1")); |
|
91 INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
92 TEST(ret==KErrNone); |
|
93 ret = aLs.AppForDataType(dataType,retAppUid); |
|
94 INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
95 TEST(ret==KErrNone); |
|
96 INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); |
|
97 TEST(retAppUid == trustedAppUid); |
|
98 |
|
99 //delete data type mapping |
|
100 ret=aLs.DeleteDataMapping(dataType); |
|
101 INFO_PRINTF3(_L("Deleting data mapping: Expected return code: %d, Actual return code: %d"), KErrNone, ret); |
|
102 TEST(ret==KErrNone); |
|
103 } |
|
104 |
|
105 CT_DataTypeMappingWithSid1::CT_DataTypeMappingWithSid1() |
|
106 /** |
|
107 Constructor |
|
108 */ |
|
109 { |
|
110 // Call base class method to set up the human readable name for logging |
|
111 SetTestStepName(KT_DataTypeMappingWithSid1); |
|
112 } |
|
113 |
|
114 CT_DataTypeMappingWithSid1::~CT_DataTypeMappingWithSid1() |
|
115 { |
|
116 } |
|
117 |
|
118 TVerdict CT_DataTypeMappingWithSid1::doTestStepL() |
|
119 { |
|
120 INFO_PRINTF1(_L("APPFWK-APPARC-0036: DataTypeMappingWithSid1 - Started")); |
|
121 |
|
122 RTestableApaLsSession apaLsSession; |
|
123 TEST(apaLsSession.Connect()==KErrNone); |
|
124 CleanupClosePushL(apaLsSession); |
|
125 |
|
126 //DONT_CHECK since array in type store is uncompressed |
|
127 HEAP_TEST_LS_SESSION(apaLsSession, 0, DONT_CHECK, ExecuteL(apaLsSession), NO_CLEANUP); |
|
128 |
|
129 CleanupStack::PopAndDestroy(&apaLsSession); |
|
130 |
|
131 |
|
132 INFO_PRINTF1(_L("APPFWK-APPARC-0036: DataTypeMappingWithSid1 - Finished")); |
|
133 |
|
134 return TestStepResult(); |
|
135 } |