|
1 // Copyright (c) 2001-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 // The implementation of the transition validation classes upon the CWspHeaderReader class methods. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file WspHeaderReaderTransitionValidation.inl |
|
20 */ |
|
21 |
|
22 // Literals |
|
23 _LIT(KTxtTestFailed, "<FONT color=\"red\">***** TEST FAILED *****</FONT>"); |
|
24 _LIT(KTxtTestPassed, "<FONT color=\"green\">***** TEST PASSED OK *****</FONT>"); |
|
25 |
|
26 // ______________________________________________________________________________ |
|
27 // |
|
28 inline TWspHeaderReader_Ctor_TransitionValidator::TWspHeaderReader_Ctor_TransitionValidator(CUnitTestContext& aUTContext) |
|
29 :TTransitionValidator(aUTContext) |
|
30 { |
|
31 // Do nothing |
|
32 } |
|
33 |
|
34 _LIT(KCtorFailedInvariant, |
|
35 "CWspHeaderReader_Ctor_Transition invariant failure"); |
|
36 |
|
37 inline TBool TWspHeaderReader_Ctor_TransitionValidator::ValidatePreConditions() |
|
38 { |
|
39 /* |
|
40 CWspHeaderReader_UnitTestContext& context = REINTERPRET_CAST(CWspHeaderReader_UnitTestContext&,iUTContext); |
|
41 if( context.iCodec != NULL ) |
|
42 { |
|
43 iUTContext.DataLogger().LogInformation(KTxtTestFailed); |
|
44 _LIT(KTxtFail, "*** C'tor pre condition fail - Object already exists ***"); |
|
45 iUTContext.DataLogger().LogInformation(KTxtFail); |
|
46 return EFalse |
|
47 } |
|
48 */ |
|
49 return ETrue; |
|
50 } |
|
51 |
|
52 inline TBool TWspHeaderReader_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
53 { |
|
54 /* |
|
55 CWspHeaderReader_UnitTestContext& context = REINTERPRET_CAST(CWspHeaderReader_UnitTestContext&,iUTContext); |
|
56 if( context.iCodec == NULL ) |
|
57 { |
|
58 iUTContext.DataLogger().LogInformation(KTxtTestFailed); |
|
59 _LIT(KTxtFail, "*** C'tor post condition fail - Object not created ***"); |
|
60 iUTContext.DataLogger().LogInformation(KTxtFail); |
|
61 return EFalse |
|
62 } |
|
63 */ |
|
64 //iUTContext.DataLogger().LogInformation(KTxtTestPassed); |
|
65 return ETrue; |
|
66 } |
|
67 |
|
68 // ______________________________________________________________________________ |
|
69 // |
|
70 inline TWspHeaderReader_Dtor_TransitionValidator::TWspHeaderReader_Dtor_TransitionValidator(CUnitTestContext& aUTContext) |
|
71 :TTransitionValidator(aUTContext) |
|
72 { |
|
73 // Do nothing |
|
74 } |
|
75 |
|
76 _LIT(KDtorFailedInvariant, |
|
77 "CWspHeaderReader_Dtor_Transition invariant failure"); |
|
78 |
|
79 inline TBool TWspHeaderReader_Dtor_TransitionValidator::ValidatePreConditions() |
|
80 { |
|
81 /* |
|
82 CWspHeaderReader_UnitTestContext& context = REINTERPRET_CAST(CWspHeaderReader_UnitTestContext&,iUTContext); |
|
83 if( context.iCodec == NULL ) |
|
84 { |
|
85 iUTContext.DataLogger().LogInformation(KTxtTestFailed); |
|
86 _LIT(KTxtFail, "*** D'tor pre condition fail - Object not created ***"); |
|
87 iUTContext.DataLogger().LogInformation(KTxtFail); |
|
88 return EFalse |
|
89 } |
|
90 */ |
|
91 return ETrue; |
|
92 } |
|
93 |
|
94 inline TBool TWspHeaderReader_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
95 { |
|
96 /* |
|
97 CWspHeaderReader_UnitTestContext& context = REINTERPRET_CAST(CWspHeaderReader_UnitTestContext&,iUTContext); |
|
98 if( context.iCodec != NULL ) |
|
99 { |
|
100 iUTContext.DataLogger().LogInformation(KTxtTestFailed); |
|
101 _LIT(KTxtFail, "*** D'tor post condition fail - Object not destroyed ***"); |
|
102 iUTContext.DataLogger().LogInformation(KTxtFail); |
|
103 return EFalse |
|
104 } |
|
105 */ |
|
106 iUTContext.DataLogger().LogInformation(KTxtTestPassed); |
|
107 return ETrue; |
|
108 } |
|
109 |
|
110 // ______________________________________________________________________________ |
|
111 // |
|
112 inline TWspHeaderReader_DecodeHeaderL_TransitionValidator::TWspHeaderReader_DecodeHeaderL_TransitionValidator(CUnitTestContext& aUTContext) |
|
113 :TTransitionValidator(aUTContext) |
|
114 { |
|
115 // Do nothing |
|
116 } |
|
117 |
|
118 _LIT(KDecodeHeaderLFailedInvariant, |
|
119 "CWspHeaderReader_DecodeHeaderL_Transition invariant failure"); |
|
120 |
|
121 inline TBool TWspHeaderReader_DecodeHeaderL_TransitionValidator::ValidatePreConditions() |
|
122 { |
|
123 // @TODO - do a check that the header field is what we expect |
|
124 return ETrue; |
|
125 } |
|
126 |
|
127 inline TBool TWspHeaderReader_DecodeHeaderL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
128 { |
|
129 CWspHeaderReader_UnitTestContext& context = REINTERPRET_CAST(CWspHeaderReader_UnitTestContext&,iUTContext); |
|
130 TPtrC8 headerNameDes; |
|
131 if( context.iHeaderToken != KErrNotFound ) |
|
132 { |
|
133 RStringF headerName = context.iStrPool.StringF(context.iHeaderToken, context.iStrTable); |
|
134 headerNameDes.Set(headerName.DesC()); |
|
135 } |
|
136 else |
|
137 { |
|
138 headerNameDes.Set(KTxtTestHeader()); |
|
139 } |
|
140 |
|
141 _LIT8(KTxtHeaderName, "Header Name - %S"); |
|
142 iUTContext.DataLogger().LogInformationWithParameters(KTxtHeaderName, &headerNameDes); |
|
143 // Do a check for the buffer sixe size maximum that can be logged is 150 |
|
144 if( (context.iExpectedData->Length() < 100) && (context.iOutputData->Length() < 100) ) |
|
145 { |
|
146 _LIT8(KTxtExpected, "Expected Data - %S"); |
|
147 _LIT8(KTxtActual, "Actual Data - %S"); |
|
148 iUTContext.DataLogger().LogInformationWithParameters(KTxtExpected, context.iExpectedData); |
|
149 iUTContext.DataLogger().LogInformationWithParameters(KTxtActual, context.iOutputData); |
|
150 } |
|
151 |
|
152 if( context.iExpectedData->CompareF(*(context.iOutputData)) != 0 ) |
|
153 { |
|
154 iUTContext.DataLogger().LogInformation(KTxtTestFailed); |
|
155 _LIT(KTxtFail, "*** Decode Header post condition fail - Expected data not same as output ***"); |
|
156 iUTContext.DataLogger().LogInformation(KTxtFail); |
|
157 return EFalse; |
|
158 } |
|
159 //iUTContext.DataLogger().LogInformation(KTxtTestPassed); |
|
160 return ETrue; |
|
161 } |