|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 |
|
23 #define private public |
|
24 #include "launcher.h" |
|
25 #undef private |
|
26 |
|
27 #include "sishelpercaptest.h" |
|
28 #include "sisuihandler.h" |
|
29 |
|
30 |
|
31 #include "sishelperclient.h" |
|
32 |
|
33 #include <e32def.h> |
|
34 #include <e32math.h> |
|
35 |
|
36 |
|
37 _LIT(KSisHelperCapTestName, "SisHelper capability test"); |
|
38 |
|
39 using namespace Swi; |
|
40 |
|
41 CSisHelperCapTest* CSisHelperCapTest::NewL() |
|
42 { |
|
43 CSisHelperCapTest* self=new(ELeave) CSisHelperCapTest(); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CSisHelperCapTest::CSisHelperCapTest() |
|
51 { |
|
52 SetCapabilityRequired(ECapabilityTrustedUI); |
|
53 } |
|
54 |
|
55 void CSisHelperCapTest::ConstructL() |
|
56 { |
|
57 SetNameL(KSisHelperCapTestName); |
|
58 } |
|
59 |
|
60 void CSisHelperCapTest::RunTestL() |
|
61 { |
|
62 Swi::RSisHelper sisHelper; |
|
63 CleanupClosePushL(sisHelper); |
|
64 |
|
65 // start sishelper |
|
66 StartSisHelperL(); |
|
67 |
|
68 TInt err= CheckFailL(sisHelper.Connect(), _L("Connect")); |
|
69 |
|
70 if (KErrNone != err) |
|
71 { |
|
72 // if we get here we didn't connect and expected not to, but cannot carry on with tests |
|
73 CleanupStack::PopAndDestroy(&sisHelper); |
|
74 return; |
|
75 } |
|
76 |
|
77 |
|
78 TRAP(err, sisHelper.OpenDrmContentL(ContentAccess::TIntent(1))); |
|
79 CheckFailL(err, _L("OpenDrmContentL")); |
|
80 |
|
81 HBufC8* buf=0; |
|
82 TRAP(err, |
|
83 { |
|
84 buf=sisHelper.SisControllerLC(); |
|
85 CleanupStack::PopAndDestroy(buf); |
|
86 }) |
|
87 CheckFailL(err, _L("SisControllerLC")); |
|
88 |
|
89 RFs fs; |
|
90 User::LeaveIfError(fs.Connect()); |
|
91 CleanupClosePushL(fs); |
|
92 |
|
93 fs.ShareProtected(); |
|
94 |
|
95 RFile file; |
|
96 _LIT(KTempFilePath , "\\tswi\\swicaptests\\temp.file"); |
|
97 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
98 |
|
99 TBuf<128> tempFileOnSysDrive = sysDrive.Name(); |
|
100 tempFileOnSysDrive.Append(KTempFilePath); |
|
101 User::LeaveIfError(file.Replace(fs, tempFileOnSysDrive, 0)); |
|
102 CleanupClosePushL(file); |
|
103 RUiHandler ui; |
|
104 |
|
105 TRAP(err, sisHelper.ExtractFileL(fs, file, 0, 0, ui)); |
|
106 CheckFailL(err, _L("ExtractFileL")); |
|
107 |
|
108 |
|
109 TRAP(err, sisHelper.SetupAsyncExtractionL(fs, file, 0, 0)); |
|
110 CheckFailL(err, _L("SetupAsyncExtractionL")); |
|
111 |
|
112 TRequestStatus s; |
|
113 TRequestStatus &a=s; |
|
114 TRAP(err, sisHelper.AsyncExtractionL(3, a)); |
|
115 User::WaitForRequest(a); |
|
116 err+=s.Int(); |
|
117 CheckFailL(err, _L("AsyncExtractionL")); |
|
118 |
|
119 |
|
120 TRAP(err, sisHelper.EndAsyncExtractionL()); |
|
121 CheckFailL(err, _L("EndAsyncExtractionL")); |
|
122 |
|
123 CleanupStack::PopAndDestroy(2, &fs); |
|
124 |
|
125 RArray<TChar> driveLetters; |
|
126 RArray<TInt64> driveSpaces; |
|
127 |
|
128 TRAP(err, sisHelper.FillDrivesAndSpacesL(driveLetters, driveSpaces)); |
|
129 CheckFailL(err, _L("FillDrivesAndSpacesL")); |
|
130 |
|
131 |
|
132 TRAP(err, sisHelper.ExecuteDrmIntentL(ContentAccess::TIntent(1))); |
|
133 CheckFailL(err, _L("ExecuteDrmIntentL")); |
|
134 |
|
135 driveLetters.Close(); |
|
136 driveSpaces.Close(); |
|
137 |
|
138 CleanupStack::PopAndDestroy(&sisHelper); |
|
139 } |
|
140 |
|
141 |
|
142 void CSisHelperCapTest::StartSisHelperL() |
|
143 { |
|
144 _LIT(KTestSisFile, "z:\\tswi\\tsis\\data\\cancel.sis"); |
|
145 |
|
146 RProcess p; |
|
147 |
|
148 //Launching process |
|
149 User::LeaveIfError(p.Create(_L("sishelperstarter.exe"), KNullDesC)); |
|
150 |
|
151 p.SetParameter(7, KTestSisFile); |
|
152 |
|
153 |
|
154 // Wait for the test to finish |
|
155 TRequestStatus s; |
|
156 TRequestStatus& a=s; |
|
157 p.Rendezvous(a); |
|
158 |
|
159 p.Resume(); |
|
160 User::WaitForRequest(a); |
|
161 p.Close(); |
|
162 } |