|
1 // Copyright (c) 2004-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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // OpenAttachment |
|
17 // [Action Parameters] |
|
18 // EntryId <input> : Value of the attachment entry Id to be opened. |
|
19 // FileName <input> : Name of the attachment file name to be opened |
|
20 // [Action Description] |
|
21 // Allows clients to view/read the attachment |
|
22 // [APIs Used] |
|
23 // RMsvServerSession::OpenAttachment |
|
24 // __ACTION_INFO_END__ |
|
25 // |
|
26 // |
|
27 |
|
28 /** |
|
29 @file |
|
30 */ |
|
31 |
|
32 #include "CMtfTestActionOpenAttachment.h" |
|
33 #include "MCLIENT.H" |
|
34 #include "CMtfTestActionParameters.h" |
|
35 #include "CMtfTestCase.h" |
|
36 |
|
37 CMtfTestAction* CMtfTestActionOpenAttachment::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
38 { |
|
39 CMtfTestActionOpenAttachment* self = new (ELeave) CMtfTestActionOpenAttachment(aTestCase); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(aActionParameters); |
|
42 CleanupStack::Pop(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CMtfTestActionOpenAttachment::CMtfTestActionOpenAttachment(CMtfTestCase& aTestCase) |
|
47 : CMtfSynchronousTestAction(aTestCase) |
|
48 { |
|
49 } |
|
50 |
|
51 CMtfTestActionOpenAttachment::~CMtfTestActionOpenAttachment() |
|
52 { |
|
53 } |
|
54 |
|
55 void CMtfTestActionOpenAttachment::ExecuteActionL() |
|
56 { |
|
57 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionOpenAttachment); |
|
58 // Obtain the input parameters |
|
59 TMsvId paramEntryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0)); |
|
60 HBufC* paramAttachmentFileName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); |
|
61 |
|
62 // Create file session at the client side |
|
63 RFs fs; |
|
64 User::LeaveIfError(fs.Connect()); |
|
65 CleanupClosePushL(fs); |
|
66 |
|
67 RMsvServerSession serverSession; |
|
68 serverSession.Connect(fs); |
|
69 CleanupClosePushL(serverSession); |
|
70 |
|
71 RFile file; |
|
72 serverSession.OpenAttachmentL(paramEntryId,*paramAttachmentFileName,file); |
|
73 CleanupClosePushL(file); |
|
74 |
|
75 TBuf8<100> bufFileData(_L8("")); // To read test data |
|
76 TInt error = file.Read(bufFileData,bufFileData.MaxLength()); |
|
77 if(error) |
|
78 { |
|
79 TestCase().ERR_PRINTF2(_L("Error Reading Client file , Error = %d"), error); |
|
80 TestCase().SetTestStepResult(EFail); |
|
81 } |
|
82 else |
|
83 { |
|
84 TestCase().INFO_PRINTF1(_L("Test Data successfully read from Attachment file")); |
|
85 } |
|
86 |
|
87 CleanupStack::PopAndDestroy(3,&fs); |
|
88 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionOpenAttachment); |
|
89 TestCase().ActionCompletedL(*this); |
|
90 } |