|
1 // Copyright (c) 1999-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 "msvtestutilsbase.h" |
|
17 #include <watcher.h> |
|
18 |
|
19 _LIT(KWatcherExe, "z:\\system\\libs\\watcher.exe"); |
|
20 |
|
21 EXPORT_C CTestUtilsWatcherStarter* CTestUtilsWatcherStarter::NewL(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aWaitToStart, TInt aPriority) |
|
22 { |
|
23 CTestUtilsWatcherStarter* self = NewL(aPriority); |
|
24 CleanupStack::PushL(self); |
|
25 |
|
26 self->ConstructL(aStatus, aWaitToStart); |
|
27 |
|
28 CleanupStack::Pop(self); |
|
29 return self; |
|
30 } |
|
31 |
|
32 EXPORT_C CTestUtilsWatcherStarter* CTestUtilsWatcherStarter::NewL(TInt aPriority) |
|
33 { |
|
34 CTestUtilsWatcherStarter* self = new (ELeave) CTestUtilsWatcherStarter(aPriority); |
|
35 CleanupStack::PushL(self); |
|
36 |
|
37 self->ConstructL(); |
|
38 |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 EXPORT_C CTestUtilsWatcherStarter::~CTestUtilsWatcherStarter() |
|
44 { |
|
45 Cancel(); |
|
46 iTimer.Close(); |
|
47 if (iConstructed) |
|
48 iWatcher.Kill(KErrNone); |
|
49 |
|
50 iWatcher.Close(); |
|
51 } |
|
52 |
|
53 CTestUtilsWatcherStarter::CTestUtilsWatcherStarter(TInt aPriority) |
|
54 : CActive(aPriority) |
|
55 { |
|
56 CActiveScheduler::Add(this); |
|
57 } |
|
58 |
|
59 void CTestUtilsWatcherStarter::RunL() |
|
60 { |
|
61 //Completes when timer has elapsed |
|
62 User::RequestComplete(iObserver, iStatus.Int()); |
|
63 } |
|
64 |
|
65 void CTestUtilsWatcherStarter::DoCancel() |
|
66 { |
|
67 iTimer.Cancel(); |
|
68 User::RequestComplete(iObserver, KErrCancel); |
|
69 } |
|
70 |
|
71 void CTestUtilsWatcherStarter::ConstructL() |
|
72 { |
|
73 User::LeaveIfError(iWatcher.Create(KWatcherExe, KNullDesC)); |
|
74 iWatcher.Resume(); |
|
75 iConstructed = ETrue; |
|
76 } |
|
77 |
|
78 void CTestUtilsWatcherStarter::ConstructL(TRequestStatus& aStatus, TTimeIntervalMicroSeconds32 aWaitToStart) |
|
79 { |
|
80 ConstructL(); |
|
81 User::LeaveIfError(iTimer.CreateLocal()); |
|
82 iTimer.After(iStatus, aWaitToStart); |
|
83 iObserver = &aStatus; |
|
84 SetActive(); |
|
85 } |
|
86 |
|
87 |