|
1 // Copyright (c) 2007-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 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <sysmonclisess.h> |
|
23 #include <startupproperties.h> |
|
24 #include "testprocgoodsession.h" |
|
25 #include "tsysmon_stepselfmoncancel.h" |
|
26 |
|
27 CStepSelfMonCancel::CStepSelfMonCancel() |
|
28 { |
|
29 SetTestStepName(KCTestCaseSelfMonCancel); |
|
30 } |
|
31 |
|
32 |
|
33 /** |
|
34 Old Test CaseID APPFWK-SYSMON-0008 |
|
35 New Test CaseID DEVSRVS-SYSSTART-SYSMON-0008 |
|
36 */ |
|
37 |
|
38 TVerdict CStepSelfMonCancel::doTestStepL() |
|
39 { |
|
40 INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0008")); |
|
41 |
|
42 INFO_PRINTF1(_L("Going to start a process")); |
|
43 RProcess process; |
|
44 CleanupClosePushL(process); |
|
45 User::LeaveIfError(process.Create(KTestProcGood, KLaunchServerCommandLineOption)); |
|
46 ResumeL(process); |
|
47 |
|
48 INFO_PRINTF1(_L("Going to request process monitoring")); |
|
49 CStartupProperties* prop = CStartupProperties::NewLC(KTestProcGood, KLaunchServerCommandLineOption); |
|
50 prop->SetStartMethod(EWaitForStart); |
|
51 prop->SetMonitored(ETrue); |
|
52 prop->SetNoOfRetries(1); |
|
53 |
|
54 RSysMonSession sysmon; |
|
55 CleanupClosePushL(sysmon); |
|
56 sysmon.OpenL(); |
|
57 TRAPD(err, sysmon.MonitorL(*prop, process)); |
|
58 TESTEL(err == KErrNone, err); |
|
59 |
|
60 INFO_PRINTF1(_L("Monitoring is now setup, we will now make a request to cancel monitoring.")); |
|
61 RTestProcGoodSession server; |
|
62 User::LeaveIfError(server.Connect()); |
|
63 TEST(KErrNone == server.CancelMonitor()); |
|
64 server.Close(); |
|
65 |
|
66 //Now, killing the process will not cause sysmon to restart after KWaitTime |
|
67 TEST(Exists(KTestProcGood)); |
|
68 process.Kill(KErrNone); |
|
69 TEST(EFalse == Exists(KTestProcGood)); |
|
70 INFO_PRINTF1(_L("Killed monitored process.")); |
|
71 |
|
72 CleanupStack::PopAndDestroy(&sysmon); |
|
73 CleanupStack::PopAndDestroy(prop); |
|
74 CleanupStack::PopAndDestroy(&process); |
|
75 |
|
76 INFO_PRINTF1(_L("Going to sleep for 16 seconds.")); |
|
77 User::After(KThrottleTime + 1000000); |
|
78 |
|
79 INFO_PRINTF1(_L("Check that the process wasn't restarted")); |
|
80 TEST(EFalse == Exists(KTestProcGood)); |
|
81 |
|
82 INFO_PRINTF1(_L("Test complete")); |
|
83 return TestStepResult(); |
|
84 } |