|
1 // Copyright (c) 1997-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 accessor class upon the CComponentTester |
|
15 // |
|
16 // |
|
17 |
|
18 // ______________________________________________________________________________ |
|
19 // |
|
20 _LIT(KTComponentTester_DumpName,"C:\\System\\Data\\Logs\\TComponentTester_StateDump.bin"); |
|
21 |
|
22 inline TInt TComponentTester_StateAccessor::InvariantTest(TAny* aTestObject) |
|
23 { |
|
24 if(aTestObject) |
|
25 { |
|
26 CComponentTester* theComponentTester = REINTERPRET_CAST(CComponentTester*, aTestObject); |
|
27 if(theComponentTester->iUnitTests == NULL) |
|
28 return KTestBedFailedInvariant; |
|
29 } |
|
30 return KErrNone; |
|
31 } |
|
32 |
|
33 inline TInt TComponentTester_StateAccessor::Internalize(TAny* aTestObject) |
|
34 { |
|
35 TInt error = KErrNone; |
|
36 if(aTestObject != NULL) |
|
37 { |
|
38 CComponentTester* ComponentTester = REINTERPRET_CAST(CComponentTester*, aTestObject); |
|
39 TRAP(error,InternalizeL(ComponentTester)); |
|
40 } |
|
41 return error; |
|
42 } |
|
43 |
|
44 inline TInt TComponentTester_StateAccessor::Externalize(TAny* aTestObject) |
|
45 { |
|
46 TInt error = KErrNone; |
|
47 if(aTestObject != NULL) |
|
48 { |
|
49 CComponentTester* ComponentTester = REINTERPRET_CAST(CComponentTester*, aTestObject); |
|
50 TRAP(error,ExternalizeL(ComponentTester)); |
|
51 } |
|
52 return error; |
|
53 } |
|
54 |
|
55 inline void TComponentTester_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CComponentTester* /* aLoadManager */) |
|
56 { |
|
57 // Not required |
|
58 } |
|
59 |
|
60 inline void TComponentTester_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CComponentTester* /* aLoadManager */) |
|
61 { |
|
62 // Not required |
|
63 } |
|
64 |
|
65 |
|
66 inline CComponentTesterTestDerivation::CComponentTesterTestDerivation(CDataLogger& aDataLogger, MComponentTestObserver& aObserver) |
|
67 : CComponentTester(aDataLogger, aObserver) |
|
68 { |
|
69 } |
|
70 |
|
71 inline void CComponentTesterTestDerivation::ConstructL() |
|
72 { |
|
73 ComponentTesterConstructL(); |
|
74 } |
|
75 |
|
76 inline CComponentTesterTestDerivation* TComponentTester_StateAccessor::CreateComponentTester(CComponentTester& /*aCompTest*/, |
|
77 CDataLogger& aDataLogger, |
|
78 MComponentTestObserver& aObserver) |
|
79 { |
|
80 return new(ELeave)CComponentTesterTestDerivation(aDataLogger, aObserver); |
|
81 } |
|
82 |
|
83 inline void TComponentTester_StateAccessor::AddUnitTestL(CComponentTester& aCompTest, CUnitTest* aUnitTest) |
|
84 { |
|
85 aCompTest.AddUnitTestL(aUnitTest); |
|
86 } |
|
87 |
|
88 inline void TComponentTester_StateAccessor::AddParamUnitTestL(CComponentTester& aCompTest, CUnitTest* aUnitTest) |
|
89 { |
|
90 aCompTest.AddParamUnitTestL(aUnitTest); |
|
91 } |
|
92 |
|
93 inline void TComponentTester_StateAccessor::RunL(CComponentTester& aCompTest) |
|
94 { |
|
95 aCompTest.RunL(); |
|
96 } |
|
97 |
|
98 // internal helpers |
|
99 inline void TComponentTester_StateAccessor::InternalizeL(CComponentTester* aComponentTester) |
|
100 { |
|
101 // Read in the dumped data |
|
102 RFs fs; |
|
103 User::LeaveIfError(fs.Connect()); |
|
104 CleanupClosePushL(fs); |
|
105 // Read the object dump |
|
106 TParse filename; |
|
107 filename.Set(KTComponentTester_DumpName(),NULL,NULL); |
|
108 RFileReadStream stream; |
|
109 User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead)); |
|
110 CleanupClosePushL(stream); |
|
111 InternalizeL(stream, aComponentTester); |
|
112 CleanupStack::PopAndDestroy(2); // stream & fs |
|
113 } |
|
114 |
|
115 inline void TComponentTester_StateAccessor::ExternalizeL(CComponentTester* aComponentTester) |
|
116 { |
|
117 RFs fs; |
|
118 User::LeaveIfError(fs.Connect()); |
|
119 CleanupClosePushL(fs); |
|
120 // Write out the object dump |
|
121 TParse filename; |
|
122 filename.Set(KTComponentTester_DumpName(),NULL,NULL); |
|
123 RFileWriteStream stream; |
|
124 User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite)); |
|
125 CleanupClosePushL(stream); |
|
126 ExternalizeL(stream, aComponentTester); |
|
127 CleanupStack::PopAndDestroy(2); // stream & fs |
|
128 } |
|
129 |