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