|
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 // |
|
15 |
|
16 #include "CMtfTestActionSaveMsvIdParamToFile.h" |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 #include <s32file.h> |
|
22 |
|
23 #include <msvipc.h> |
|
24 #include "MCLIENT.H" |
|
25 #include "MSERVER.H" |
|
26 |
|
27 |
|
28 #include "CMtfTestCase.h" |
|
29 #include "CMtfTestActionParameters.h" |
|
30 |
|
31 |
|
32 /** |
|
33 Function : NewL |
|
34 Description : |
|
35 @internalTechnology |
|
36 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
37 @param : aActionParams - CMtfTestActionParameters |
|
38 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSaveMsvIdParamToFile object |
|
39 @pre none |
|
40 @post none |
|
41 */ |
|
42 CMtfTestAction* CMtfTestActionSaveMsvIdParamToFile::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
43 { |
|
44 CMtfTestActionSaveMsvIdParamToFile* self = new (ELeave) CMtfTestActionSaveMsvIdParamToFile(aTestCase); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aActionParameters); |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 /** |
|
52 Function : CMtfTestActionSaveMsvIdParamToFile |
|
53 Description : Constructor |
|
54 @internalTechnology |
|
55 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
56 @return : N/A |
|
57 @pre none |
|
58 @post none |
|
59 */ |
|
60 CMtfTestActionSaveMsvIdParamToFile::CMtfTestActionSaveMsvIdParamToFile(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
61 { |
|
62 } |
|
63 |
|
64 /** |
|
65 Function : ~CMtfTestActionSaveMsvIdParamToFile |
|
66 Description : Destructor |
|
67 @internalTechnology |
|
68 @param : |
|
69 @return : |
|
70 @pre |
|
71 @post |
|
72 */ |
|
73 CMtfTestActionSaveMsvIdParamToFile::~CMtfTestActionSaveMsvIdParamToFile() |
|
74 { |
|
75 } |
|
76 |
|
77 /** |
|
78 Function : ExecuteActionL |
|
79 Description : Entry point for the this test action in the test framework |
|
80 @internalTechnology |
|
81 @param : none |
|
82 @return : void |
|
83 @pre none |
|
84 @post none |
|
85 */ |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 void CMtfTestActionSaveMsvIdParamToFile::ExecuteActionL() |
|
91 { |
|
92 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSaveMsvIdParamToFile); |
|
93 |
|
94 TMsvId messageId = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0) ); |
|
95 HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); |
|
96 |
|
97 |
|
98 RFs fs; |
|
99 User::LeaveIfError( fs.Connect() ); |
|
100 CleanupClosePushL( fs ); |
|
101 |
|
102 TInt err = fs.MkDir( *paramFilePath ); |
|
103 |
|
104 if ( ! ( (err == KErrNone ) || ( err == KErrAlreadyExists ) ) ) |
|
105 { |
|
106 User::LeaveIfError( err ); |
|
107 } |
|
108 // else dir created successfully or already created. |
|
109 |
|
110 RFileWriteStream rf; |
|
111 err = rf.Open( fs , *paramFilePath , EFileWrite ); |
|
112 if ( err == KErrNotFound ) |
|
113 { |
|
114 err = rf.Create( fs, *paramFilePath , EFileWrite ); |
|
115 } |
|
116 User::LeaveIfError(err); |
|
117 |
|
118 rf.PushL(); |
|
119 // Writes may leave. |
|
120 |
|
121 rf << messageId; |
|
122 |
|
123 rf.CommitL(); |
|
124 rf.Pop(); |
|
125 rf.Release(); |
|
126 |
|
127 CleanupStack::PopAndDestroy(); // fs |
|
128 |
|
129 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSaveMsvIdParamToFile); |
|
130 TestCase().ActionCompletedL(*this); |
|
131 |
|
132 |
|
133 } |