|
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 "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 * Example CTestStep derived implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file WriteStringStep.cpp |
|
23 */ |
|
24 #include "writestringstep.h" |
|
25 #include "te_regsteptestsuitedefs.h" |
|
26 |
|
27 CWriteStringStep::~CWriteStringStep() |
|
28 /** |
|
29 * Destructor |
|
30 */ |
|
31 { |
|
32 } |
|
33 |
|
34 CWriteStringStep::CWriteStringStep() |
|
35 /** |
|
36 * Constructor |
|
37 */ |
|
38 { |
|
39 // **MUST** call SetTestStepName in the constructor as the controlling |
|
40 // framework uses the test step name immediately following construction to set |
|
41 // up the step's unique logging ID. |
|
42 SetTestStepName(KWriteStringStep); |
|
43 } |
|
44 |
|
45 TVerdict CWriteStringStep::doTestStepPreambleL() |
|
46 /** |
|
47 * @return - TVerdict code |
|
48 * Override of base class virtual |
|
49 */ |
|
50 { |
|
51 // process some pre setting to this test step then set SetTestStepResult to EFail or Epass. |
|
52 SetTestStepResult(EPass); |
|
53 return TestStepResult(); |
|
54 } |
|
55 |
|
56 |
|
57 TVerdict CWriteStringStep::doTestStepL() |
|
58 /** |
|
59 * @return - TVerdict code |
|
60 * Override of base class pure virtual |
|
61 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
62 * not leave. That being the case, the current test result value will be EPass. |
|
63 */ |
|
64 { |
|
65 INFO_PRINTF1(_L("This step tests WriteStringToConfig function.")); |
|
66 SetTestStepResult(EFail); |
|
67 |
|
68 TPtrC originalValue; |
|
69 TBool ret = EFalse; |
|
70 |
|
71 if(!GetStringFromConfig(ConfigSection(),KTe_RegStepTestSuiteString, originalValue)) |
|
72 { |
|
73 // Leave if there's any error. |
|
74 User::Leave(KErrNotFound); |
|
75 } |
|
76 |
|
77 INFO_PRINTF2(_L("The Original String is %S"), &originalValue); // Block end |
|
78 |
|
79 RBuf buf; |
|
80 buf.Create(originalValue.Length()); |
|
81 buf.Copy(originalValue); |
|
82 |
|
83 _LIT(KText,"GoodBye Jason"); |
|
84 TBufC<16> buf1(KText); |
|
85 TPtrC TheString1(buf1); |
|
86 if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1)) |
|
87 { |
|
88 if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1) && 0==TheString1.Compare(KText())) |
|
89 { |
|
90 INFO_PRINTF2(_L("Changed String To %S"),&TheString1); |
|
91 ret = ETrue; |
|
92 } |
|
93 } |
|
94 |
|
95 _LIT(KText2,"Hello Jason"); |
|
96 TBufC<16> buf2(KText2); |
|
97 TPtrC TheString2(buf2); |
|
98 |
|
99 if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2)) |
|
100 { |
|
101 if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2) && 0==TheString2.Compare(KText2())) |
|
102 { |
|
103 INFO_PRINTF2(_L("Changed String To %S"), &TheString2); |
|
104 } |
|
105 } |
|
106 else |
|
107 { |
|
108 ret = EFalse; |
|
109 } |
|
110 |
|
111 if (!WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, buf)) |
|
112 { |
|
113 ret = EFalse; |
|
114 } |
|
115 buf.Close(); |
|
116 |
|
117 if (ret) |
|
118 { |
|
119 SetTestStepResult(EPass); |
|
120 } |
|
121 |
|
122 return TestStepResult(); |
|
123 } |
|
124 |
|
125 |
|
126 |
|
127 TVerdict CWriteStringStep::doTestStepPostambleL() |
|
128 /** |
|
129 * @return - TVerdict code |
|
130 * Override of base class virtual |
|
131 */ |
|
132 { |
|
133 return TestStepResult(); |
|
134 } |