|
1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This test case is used to verify that a recognizer can be installed and used |
|
15 // without reboot. See comment in header file. |
|
16 // |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include "testableapalssession.h" |
|
27 |
|
28 #include "T_ApsScan.h" |
|
29 #include "appfwk_test_utils.h" |
|
30 #include "tmimerec\constants.hrh" |
|
31 #include "tmimerec\constants.h" |
|
32 |
|
33 ///////////////////////////////////////////////// |
|
34 |
|
35 const TInt KDelay = 4000000; // Should be enough for CApaEComMonitor to detect new plugin |
|
36 |
|
37 ///////////////////////////////////////////////// |
|
38 |
|
39 CT_ApsScanStep::CT_ApsScanStep() |
|
40 { |
|
41 // Call base class method to set up the human readable name for logging |
|
42 SetTestStepName(KT_ApsScanStep); |
|
43 } |
|
44 |
|
45 CT_ApsScanStep::~CT_ApsScanStep() |
|
46 { |
|
47 } |
|
48 |
|
49 /** |
|
50 Check that the test plugin file has not been left in the filesystem from a previous aborted test. |
|
51 */ |
|
52 TVerdict CT_ApsScanStep::doTestStepPreambleL() |
|
53 { |
|
54 RSmlTestUtils fs; |
|
55 CleanupClosePushL(fs); |
|
56 User::LeaveIfError(fs.Connect()); |
|
57 |
|
58 INFO_PRINTF1(_L("Verifies that dummy.rsc was not present during boot.")); |
|
59 TBool fileExists = ETrue; |
|
60 TInt err = fs.IsFilePresent(KRscTargetPath, fileExists); |
|
61 TESTE(fileExists==EFalse, err); |
|
62 |
|
63 CleanupStack::PopAndDestroy(&fs); |
|
64 return TestStepResult(); |
|
65 } |
|
66 |
|
67 /* |
|
68 Delete the plugin file which was installed during the test from c:. |
|
69 */ |
|
70 TVerdict CT_ApsScanStep::doTestStepPostambleL() |
|
71 { |
|
72 RSmlTestUtils fs; |
|
73 CleanupClosePushL(fs); |
|
74 User::LeaveIfError(fs.Connect()); |
|
75 |
|
76 TBool fileExists = EFalse; |
|
77 fs.IsFilePresent(KRscTargetPath, fileExists); |
|
78 if(fileExists) |
|
79 { |
|
80 fs.ChangeFilePermissionL(KRscTargetPath); // clear readonly attribute inherited from z: |
|
81 const TInt err = fs.DeleteFileL(KRscTargetPath); |
|
82 if(err == KErrNone) |
|
83 INFO_PRINTF1(_L("Removed temporary file dummy.rsc")); |
|
84 else |
|
85 INFO_PRINTF1(_L("Failed to remove temporary file dummy.rsc")); |
|
86 } |
|
87 |
|
88 CleanupStack::PopAndDestroy(&fs); |
|
89 return TestStepResult(); |
|
90 } |
|
91 |
|
92 /* |
|
93 The test entry point |
|
94 */ |
|
95 TVerdict CT_ApsScanStep::doTestStepL() |
|
96 { |
|
97 RTestableApaLsSession apparcServer; |
|
98 CleanupClosePushL(apparcServer); |
|
99 User::LeaveIfError(apparcServer.Connect()); |
|
100 |
|
101 HEAP_TEST_LS_SESSION(apparcServer, 0, DONT_CHECK, TestDynInstallRecognizerL(apparcServer), NO_CLEANUP); |
|
102 |
|
103 CleanupStack::PopAndDestroy(&apparcServer); |
|
104 |
|
105 return TestStepResult(); |
|
106 } |
|
107 |
|
108 /** |
|
109 @SYMTestCaseID APPFWK-APPARC-0049 |
|
110 |
|
111 @SYMDEF DEF082982 |
|
112 |
|
113 @SYMTestCaseDesc This test verify that apparc can dynamically install an Ecom recognizer plugin. |
|
114 |
|
115 @SYMTestPriority High |
|
116 |
|
117 @SYMTestStatus Implemented |
|
118 |
|
119 @SYMTestActions To avoid using a precompiled recognizer for this test, following workaround is used: |
|
120 |
|
121 1. The test plugin are copied into z: by the build tools when building apparc tef tests. |
|
122 2. The plugin will not be installed during startup because CreateRecognizerL will leave |
|
123 3. During the test a dummy plugin.rsc will be copied into c:\resource\plugins to trig Ecom |
|
124 4. Apparc will be notified and make sure all recognizers listed by Ecom are properly installed |
|
125 5. Ecom will not be able install the copied dummy file as it has no matching dll on the same drive, but |
|
126 6. The recognizer will detect existence of the dummy file and chose not to leave from CreateRecognizerL |
|
127 |
|
128 Due to platsec we can't build plugin.dll to an alternative location and we can't |
|
129 copy files from epoc32\release\winscw\udeb in runtime. Both plugin.rsc and plugin.dll |
|
130 must be on the same drive to be accepted by Ecom. |
|
131 |
|
132 @SYMTestExpectedResults Test should complete without any leave, panic or error. |
|
133 */ |
|
134 void CT_ApsScanStep::TestDynInstallRecognizerL(RApaLsSession& aApparcServer) |
|
135 { |
|
136 INFO_PRINTF1(_L("Step 1 of 4: Verifies that recognizer isn't installed.")); |
|
137 // TESTL will leave and abort this teststep if DoRecognizeL returns ETrue |
|
138 TESTL(EFalse == DoRecognizeL(aApparcServer, TDataType(KDataTypeNew))); |
|
139 |
|
140 INFO_PRINTF1(_L("Step 2 of 4: Installs recognizer plugin file ")); |
|
141 CopyRecognizerFileL(); |
|
142 |
|
143 INFO_PRINTF2(_L("Step 3 of 4: Waits %d seconds for new recognizer to be installed."), KDelay/1000000); |
|
144 User::After(KDelay); |
|
145 |
|
146 INFO_PRINTF1(_L("Step 4 of 4: Verifies that the new recognizer was installed successfully")); |
|
147 TEST(DoRecognizeL(aApparcServer, TDataType(KDataTypeNew))); |
|
148 } |
|
149 |
|
150 /** |
|
151 Copies the test file dummy.rsc from z: to c: using RSmlTestUtils rather than aFs due to |
|
152 platsec protection of involved directories. |
|
153 */ |
|
154 void CT_ApsScanStep::CopyRecognizerFileL() |
|
155 { |
|
156 RSmlTestUtils fs; |
|
157 CleanupClosePushL(fs); |
|
158 User::LeaveIfError(fs.Connect()); |
|
159 |
|
160 // Ensure c:\\resource\\plugins is created, otherwise leave and abort this teststep |
|
161 TInt err = fs.CreateDirectoryL(KRscTargetDir); |
|
162 TESTEL((err==KErrNone || err==KErrAlreadyExists), err); |
|
163 |
|
164 // Copy resource file from z: to c:, if unsuccessful - leave and abort this teststep |
|
165 #if defined (__WINSCW__) |
|
166 err = fs.CopyFileL(KRscSourcePathWinscw, KRscTargetPath); |
|
167 #else |
|
168 err = fs.CopyFileL(KRscSourcePathArmv5, KRscTargetPath); |
|
169 #endif |
|
170 TESTEL(err==KErrNone, err); |
|
171 |
|
172 CleanupStack::PopAndDestroy(&fs); |
|
173 |
|
174 } |
|
175 |
|
176 /** |
|
177 Check if a certain datatype is known/recognized by apparc. |
|
178 |
|
179 @param aApparcServer an open session to apparc |
|
180 @param aDataType the datatype you want to test |
|
181 @return ETrue if @c aDataType is one of those returned from RApaLsSession::GetSupportedDataTypesL |
|
182 */ |
|
183 TBool CT_ApsScanStep::DoRecognizeL(RApaLsSession& aApparcServer, const TDataType& aDataType) |
|
184 { |
|
185 TBool recognized = EFalse; |
|
186 |
|
187 CDataTypeArray* dataTypes=new(ELeave) CDataTypeArray(64); |
|
188 CleanupStack::PushL(dataTypes); |
|
189 aApparcServer.GetSupportedDataTypesL(*dataTypes); |
|
190 |
|
191 const TInt count = dataTypes->Count(); |
|
192 for(TInt i=0; i<count; i++) |
|
193 { |
|
194 const TDataType& tmp = dataTypes->At(i); |
|
195 if(tmp == aDataType) |
|
196 { |
|
197 recognized = ETrue; |
|
198 break; |
|
199 } |
|
200 } |
|
201 |
|
202 CleanupStack::PopAndDestroy(dataTypes); |
|
203 return recognized; |
|
204 } |