|
1 /* |
|
2 * Copyright (c) 2008-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 the License "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 * testutil - server classes |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 @test |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include "testutilsdpfilewatcher.h" |
|
30 |
|
31 class CTestUtilServer; |
|
32 |
|
33 class MTimeoutClient |
|
34 { |
|
35 public: |
|
36 /** Client's implementation gets called on timer expiry */ |
|
37 virtual void HandleTimeout() = 0; |
|
38 }; |
|
39 |
|
40 /** Simple timer class which calls a callback on timer expiry */ |
|
41 class CGenericTimer : public CTimer |
|
42 { |
|
43 public: |
|
44 static CGenericTimer* NewL(MTimeoutClient& aClient); |
|
45 private: |
|
46 CGenericTimer(MTimeoutClient& aClient); |
|
47 void RunL(); |
|
48 private: |
|
49 MTimeoutClient& iClient; |
|
50 }; |
|
51 |
|
52 class CTestFileDetector : public CActive, public MTimeoutClient |
|
53 { |
|
54 public: |
|
55 static CTestFileDetector* NewL(const RMessage2& iMessage, RFs& aFs); |
|
56 CTestFileDetector(const RMessage2& iMessage, RFs& aFs); |
|
57 ~CTestFileDetector(); |
|
58 void DetectFile(); |
|
59 private: |
|
60 void ConstructL(); |
|
61 virtual void HandleTimeout(); |
|
62 void RunL(); |
|
63 void DoCancel(); |
|
64 void CheckAndComplete(); |
|
65 private: |
|
66 RFs& iFs; |
|
67 CGenericTimer* iTimer; |
|
68 HBufC* iFileName; |
|
69 TInt iTimeInterval; |
|
70 const RMessage2& iMessage; |
|
71 }; |
|
72 |
|
73 class CTestUtilSession : public CSession2 |
|
74 { |
|
75 public: |
|
76 CTestUtilSession(); |
|
77 void CreateL(); |
|
78 private: |
|
79 ~CTestUtilSession(); |
|
80 inline CTestUtilServer& Server(); |
|
81 void ServiceL(const RMessage2& aMessage); |
|
82 void ServiceError(const RMessage2& aMessage,TInt aError); |
|
83 private: |
|
84 RArray<RFile> iLockedFileHandles; |
|
85 CFileWatcher* iFileWatcher; |
|
86 CTestFileDetector* iDetector; |
|
87 }; |
|
88 |
|
89 |
|
90 inline CTestUtilServer& CTestUtilSession::Server() |
|
91 {return *static_cast<CTestUtilServer*>(const_cast<CServer2*>(CSession2::Server()));} |