|
1 // Copyright (c) 2007-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 "uloggerfileplugintest.h" |
|
17 #include "uloggerdatatypes.h" |
|
18 using namespace Ulogger; |
|
19 |
|
20 /* |
|
21 * TestNewL: Test that the NewL method correctly constructs a CFileWriter object |
|
22 * |
|
23 * Expected Verdict: PASS/FAIL/PANIC |
|
24 * |
|
25 * Prerequisites: |
|
26 * |
|
27 * Description: Invoke CFileWriter::NewL() and check that a non-NULL pointer is |
|
28 * returned. |
|
29 * |
|
30 */ |
|
31 void CFile0Step::TestNewL() |
|
32 { |
|
33 CFileWriter* fileWriter = CFileWriter::NewL(); |
|
34 INFO_PRINTF1(_L("Checking that pointer returned by CFileWriter::NewL() is not NULL")); |
|
35 ASSERT_NOT_NULL(fileWriter); |
|
36 delete fileWriter; |
|
37 } |
|
38 /* |
|
39 * TestUnlockResources: Test that the CloseOutputPlugin method ??? |
|
40 * |
|
41 * Expected Verdict: PASS/FAIL/PANIC |
|
42 * |
|
43 * Prerequisites: |
|
44 * |
|
45 * Description: Retrieve and print some data from an external ini data file |
|
46 * |
|
47 */ |
|
48 void CFile0Step::TestUnlockResources() |
|
49 { |
|
50 CFileWriter* fileWriter = CFileWriter::NewL(); |
|
51 INFO_PRINTF1(_L("Invoking CFileWriter::CloseOutputPlugin(). CloseOutputPlugin() is supposed to do nothing.")); |
|
52 fileWriter->CloseOutputPlugin(); |
|
53 ASSERT_TRUE(ETrue); |
|
54 delete fileWriter; |
|
55 } |
|
56 |
|
57 /* |
|
58 * TestSettings: Test that the Settings method ??? |
|
59 * |
|
60 * Expected Verdict: PASS/FAIL/PANIC |
|
61 * |
|
62 * Prerequisites: |
|
63 * |
|
64 * Description: Retrieve and print some data from an external ini data file |
|
65 * |
|
66 */ |
|
67 void CFile0Step::TestSettings() |
|
68 { |
|
69 CFileWriter* fileWriter = CFileWriter::NewL(); |
|
70 INFO_PRINTF1(_L("Passing empty RPointerArray to CFileWriter::ConfigureOutputPlugin()")); |
|
71 RPointerArray<TPluginConfiguration> emptyPointerArray; |
|
72 fileWriter->ConfigureOutputPlugin(emptyPointerArray); |
|
73 |
|
74 delete fileWriter; |
|
75 } |
|
76 |
|
77 /* |
|
78 * TestWrite: Test that the Write method ??? |
|
79 * |
|
80 * Expected Verdict: PASS/FAIL/PANIC |
|
81 * |
|
82 * Prerequisites: |
|
83 * |
|
84 * Description: Invoke CFileWriter::Write() and check that test string is |
|
85 * written to KLogDefaultFileName correctly. |
|
86 * |
|
87 */ |
|
88 // The implementation for this is not working correctly! Check this |
|
89 void CFile0Step::TestWrite() |
|
90 { |
|
91 INFO_PRINTF1(_L("Checking that CFileWriter::Write(const TDesC8&) writes a String correctly to C:\\logs\\log.txt")); |
|
92 |
|
93 // Create new CFileWriter instance |
|
94 CFileWriter* fileWriter = CFileWriter::NewL(); |
|
95 _LIT8(KTxt, "Test"); |
|
96 INFO_PRINTF1(_L("Writing 'Test' to the log using CFileWriter::Write()")); |
|
97 ASSERT_EQUALS(KErrNone, fileWriter->Write(KTxt)); |
|
98 |
|
99 delete fileWriter; |
|
100 } |
|
101 |
|
102 |
|
103 CFile0Step::~CFile0Step() |
|
104 { |
|
105 } |
|
106 |
|
107 CFile0Step::CFile0Step() |
|
108 /** |
|
109 * Constructor |
|
110 */ |
|
111 { |
|
112 // **MUST** call SetTestStepName in the constructor as the controlling |
|
113 // framework uses the test step name immediately following construction to set |
|
114 // up the step's unique logging ID. |
|
115 SetTestStepName(KFile0Step); |
|
116 } |
|
117 |
|
118 TVerdict CFile0Step::doTestStepPreambleL() |
|
119 { |
|
120 CTe_fileSuiteStepBase::doTestStepPreambleL(); |
|
121 |
|
122 INFO_PRINTF1(_L("Connecting to file server")); |
|
123 User::LeaveIfError(iFileServer.Connect()); |
|
124 SetTestStepResult(EPass); |
|
125 return TestStepResult(); |
|
126 } |
|
127 |
|
128 TVerdict CFile0Step::doTestStepL() |
|
129 /** |
|
130 * @return - TVerdict code |
|
131 * Override of base class pure virtual |
|
132 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
133 * not leave. That being the case, the current test result value will be EPass. |
|
134 */ |
|
135 { |
|
136 if (TestStepResult()==EPass) |
|
137 { |
|
138 TestNewL(); |
|
139 TestUnlockResources(); |
|
140 TestSettings(); |
|
141 TestWrite(); |
|
142 |
|
143 if(iErrors == 0) |
|
144 SetTestStepResult(EPass); |
|
145 else |
|
146 { |
|
147 SetTestStepResult(EFail); |
|
148 TBuf<64> buf; |
|
149 INFO_PRINTF1(_L("********")); |
|
150 buf.AppendFormat(_L("%d errors were found!"), iErrors); |
|
151 INFO_PRINTF1(buf); |
|
152 INFO_PRINTF1(_L("********")); |
|
153 } |
|
154 } |
|
155 return TestStepResult(); |
|
156 } |
|
157 |
|
158 TVerdict CFile0Step::doTestStepPostambleL() |
|
159 /** |
|
160 * @return - TVerdict code |
|
161 * Override of base class virtual |
|
162 */ |
|
163 { |
|
164 CTe_fileSuiteStepBase::doTestStepPostambleL(); |
|
165 iFileServer.Close(); |
|
166 SetTestStepResult(EPass); |
|
167 return TestStepResult(); |
|
168 } |