|
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 // |
|
15 |
|
16 |
|
17 #include "DiscovererObserverStub.h" |
|
18 |
|
19 // ______________________________________________________________________________ |
|
20 // |
|
21 CObserverStub* CObserverStub::NewL(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
22 { |
|
23 CObserverStub* self= NewLC(aOwner, aContext); // calls c'tor and ConstructL |
|
24 CleanupStack::Pop(); // removes self |
|
25 return self; |
|
26 } |
|
27 |
|
28 CObserverStub* CObserverStub::NewLC(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
29 { |
|
30 CObserverStub* self=new(ELeave) CObserverStub(aOwner, aContext); // calls c'tor |
|
31 CleanupStack::PushL(self); // Make the construction safe by using the cleanup stack |
|
32 self->ConstructL(); // Complete the 'construction'. |
|
33 return self; |
|
34 } |
|
35 |
|
36 CObserverStub::~CObserverStub() |
|
37 { |
|
38 // Do nothing |
|
39 } |
|
40 |
|
41 CObserverStub::CObserverStub(CUnitTest& aOwner, CDiscoverer_UnitTestContext& aContext) |
|
42 : CBase(), iOwner(aOwner), iContext(aContext) |
|
43 { |
|
44 // Deliberately do nothing here : See ConstructL() for initialisation completion. |
|
45 } |
|
46 |
|
47 void CObserverStub::ConstructL() |
|
48 { |
|
49 // Do nothing |
|
50 } |
|
51 |
|
52 // Support of the CDiscovererObserver interface |
|
53 void CObserverStub::DiscoveriesBegin() |
|
54 { |
|
55 // Log out some information |
|
56 _LIT(KDiscoveriesBegin,"CObserverStub::DiscoveriesBegin called"); |
|
57 iContext.DataLogger().LogInformation(KDiscoveriesBegin); |
|
58 } |
|
59 |
|
60 void CObserverStub::RegisterDiscoveryL(const TEntry& /* aDirEntry */) |
|
61 { |
|
62 // Check the iteration and leave if its the first one |
|
63 // after asking for a repeat |
|
64 CTransition& transition = iOwner.GetCurrentTransition(); |
|
65 const TTransitionInfo& info = transition.TransitionInfo(); |
|
66 if(info.iIteration == KFirstTransitionIteration) |
|
67 { |
|
68 _LIT(KRegisterDiscoverRepeat,"CObserverStub::RegisterDiscoveryL repeat requested"); |
|
69 iContext.DataLogger().LogInformation(KRegisterDiscoverRepeat); |
|
70 transition.RepeatOnce(); |
|
71 User::Leave(KTestBedRepeatTest); |
|
72 } |
|
73 else |
|
74 { |
|
75 _LIT(KRegisterDiscoverSuccess,"CObserverStub::RegisterDiscoveryL completed"); |
|
76 iContext.DataLogger().LogInformation(KRegisterDiscoverSuccess); |
|
77 } |
|
78 } |
|
79 |
|
80 void CObserverStub::DiscoveriesComplete(TBool aSuccessful) |
|
81 { |
|
82 // Log out some info and cleanup the context |
|
83 _LIT(KDiscoveriesComplete,"CObserverStub::DiscoveriesComplete called"); |
|
84 iContext.DataLogger().LogInformation(KDiscoveriesComplete); |
|
85 TInt error = KErrNone; |
|
86 if(!aSuccessful) |
|
87 error = KErrCancel; |
|
88 if(iContext.iNotificationStatus) |
|
89 { |
|
90 User::RequestComplete(iContext.iNotificationStatus, error); |
|
91 iContext.iNotificationStatus = NULL; |
|
92 } |
|
93 } |
|
94 |
|
95 void CObserverStub::DriveRemovedL(TDriveUnit aDrive) |
|
96 { |
|
97 _LIT(KDriveRemovedL,"CObserverStub::DriveRemovedL called for drive %d "); |
|
98 iContext.DataLogger().LogInformationWithParameters(KDriveRemovedL,aDrive); |
|
99 } |
|
100 |
|
101 void CObserverStub::DriveReinstatedL(TDriveUnit aDrive) |
|
102 { |
|
103 // Check the iteration and leave if its the first one |
|
104 // after asking for a repeat |
|
105 CTransition& transition = iOwner.GetCurrentTransition(); |
|
106 const TTransitionInfo& info = transition.TransitionInfo(); |
|
107 if(info.iIteration == KFirstTransitionIteration) |
|
108 { |
|
109 _LIT(KRegisterDiscoverRepeat,"CObserverStub::DriveReinstatedL for drive %d repeat requested"); |
|
110 iContext.DataLogger().LogInformationWithParameters(KRegisterDiscoverRepeat, aDrive); |
|
111 transition.RepeatOnce(); |
|
112 User::Leave(KTestBedRepeatTest); |
|
113 } |
|
114 else |
|
115 { |
|
116 _LIT(KRegisterDiscoverSuccess,"CObserverStub::DriveReinstatedL for drive %d completed"); |
|
117 iContext.DataLogger().LogInformationWithParameters(KRegisterDiscoverSuccess, aDrive); |
|
118 } |
|
119 } |
|
120 |
|
121 TBool CObserverStub::NotifiedWithErrorCode(TInt aError) |
|
122 { |
|
123 // Log out some info and cleanup the context |
|
124 _LIT(KNotifiedWithErrorCode,"CObserverStub::NotifiedWithErrorCode called"); |
|
125 iContext.DataLogger().LogInformation(KNotifiedWithErrorCode); |
|
126 if(iContext.iNotificationStatus) |
|
127 { |
|
128 User::RequestComplete(iContext.iNotificationStatus, aError); |
|
129 iContext.iNotificationStatus = NULL; |
|
130 } |
|
131 return EFalse; |
|
132 } |