|
1 // Copyright (c) 2008-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 "tcustcmd_step_activateemergencycall.h" |
|
17 |
|
18 CCustomCmdTestActivateEmergencyCall::~CCustomCmdTestActivateEmergencyCall() |
|
19 { |
|
20 delete iAsyncStopScheduler; |
|
21 delete iActiveSchedulerWait; |
|
22 delete iActiveScheduler; |
|
23 } |
|
24 |
|
25 CCustomCmdTestActivateEmergencyCall::CCustomCmdTestActivateEmergencyCall() |
|
26 { |
|
27 SetTestStepName(KTCCustomCmdTestActivateEmergencyCall); |
|
28 } |
|
29 |
|
30 TVerdict CCustomCmdTestActivateEmergencyCall::doTestStepPreambleL() |
|
31 { |
|
32 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
33 CActiveScheduler::Install (iActiveScheduler); |
|
34 |
|
35 iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait; |
|
36 |
|
37 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
|
38 |
|
39 return TestStepResult(); |
|
40 } |
|
41 |
|
42 TVerdict CCustomCmdTestActivateEmergencyCall::doTestStepL() |
|
43 { |
|
44 INFO_PRINTF1(_L("doTestStepL")); |
|
45 TInt err = 0; |
|
46 __UHEAP_MARK; |
|
47 TRAP(err,TestHandleActivateEmergencyCallL()); |
|
48 TEST(KErrNone == err); |
|
49 TRAP(err,TestHandleActivateEmergencyCallCancelL()); |
|
50 TEST(KErrNone == err); |
|
51 __UHEAP_MARKEND; |
|
52 return TestStepResult(); |
|
53 } |
|
54 /** |
|
55 Old Test CaseID APPFWK-CUSTCMD-0021 |
|
56 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0021 |
|
57 */ |
|
58 |
|
59 |
|
60 void CCustomCmdTestActivateEmergencyCall::TestHandleActivateEmergencyCallL() |
|
61 { |
|
62 INFO_PRINTF1(_L("TestHandleActivateEmergencyCallL")); |
|
63 RSsmStateManager client; |
|
64 const TInt connect = client.Connect(); |
|
65 TEST(KErrNone == connect); |
|
66 |
|
67 // Create swps |
|
68 INFO_PRINTF1(_L("Creating swp...")); |
|
69 TSsmSwp swp(KTestSwp, 11); |
|
70 RProperty property; |
|
71 TInt err = property.Define(KCustomcmdServerSID, swp.Key(), RProperty::EInt); |
|
72 TEST(KErrNone == err || KErrAlreadyExists == err); |
|
73 TEST(KErrNone == property.Set(KCustomcmdServerSID, swp.Key(), swp.Value())); |
|
74 |
|
75 //Ensure the environment is clean |
|
76 TInt value = 0; |
|
77 TEST(KErrNone == property.Get(KCustomcmdServerSID, swp.Key(), value)); |
|
78 TESTE(11 == value, value); |
|
79 |
|
80 // Register mapping between keys and swp policy DLL (done once per ssmserver) |
|
81 err = client.RegisterSwpMapping(KTestSwp, KTestSwpPolicyCustomCmd); |
|
82 INFO_PRINTF2(_L("Registering swp...completed with % err"),err); |
|
83 |
|
84 //Let client request swp changes |
|
85 INFO_PRINTF1(_L("Request several swp changes")); |
|
86 swp.Set(KTestSwp, -99); |
|
87 TRequestStatus status; |
|
88 client.RequestSwpChange(swp, status); |
|
89 TEST(status == KRequestPending); |
|
90 User::WaitForRequest(status); |
|
91 User::After(500000); // Wait for 0.5sec to allow transitions to fully complete |
|
92 TEST(status.Int() == KErrNone); |
|
93 // clean-up |
|
94 TEST(KErrNone == property.Delete(KCustomcmdServerSID, swp.Key())); |
|
95 property.Close(); |
|
96 client.Close(); |
|
97 INFO_PRINTF3(_L("TestHandleActivateEmergencyCallL completed with %d Expected %d"),status.Int(),KErrNone); |
|
98 } |
|
99 |
|
100 /** |
|
101 Old Test CaseID APPFWK-CUSTCMD-0022 |
|
102 New Test CaseID DEVSRVS-SSREFPLUGINS-CUSTCMD-0021 |
|
103 */ |
|
104 |
|
105 void CCustomCmdTestActivateEmergencyCall::TestHandleActivateEmergencyCallCancelL() |
|
106 { |
|
107 INFO_PRINTF1(_L("TestHandleActivateEmergencyCallCancelL")); |
|
108 RSsmStateManager client; |
|
109 const TInt connect = client.Connect(); |
|
110 TEST(KErrNone == connect); |
|
111 |
|
112 // Create swps |
|
113 INFO_PRINTF1(_L("Creating swp...")); |
|
114 TSsmSwp swp(KTestSwp, 11); |
|
115 RProperty property; |
|
116 |
|
117 TInt ret = property.Define(KCustomcmdServerSID, swp.Key(), RProperty::EInt); |
|
118 TEST(KErrNone == ret || KErrAlreadyExists == ret); |
|
119 |
|
120 TEST(KErrNone == property.Set(KCustomcmdServerSID, swp.Key(), swp.Value())); |
|
121 |
|
122 //Ensure the environment is clean |
|
123 TInt value = 0; |
|
124 TEST(KErrNone == property.Get(KCustomcmdServerSID, swp.Key(), value)); |
|
125 TESTE(11 == value, value); |
|
126 |
|
127 |
|
128 //Let client request swp changes |
|
129 INFO_PRINTF1(_L("Request several swp changes ")); |
|
130 swp.Set(KTestSwp, -99); |
|
131 TRequestStatus status; |
|
132 client.RequestSwpChange(swp, status); |
|
133 TEST(status == KRequestPending); |
|
134 client.RequestSwpChangeCancel(); |
|
135 User::WaitForRequest(status); |
|
136 TEST(status.Int() == KErrCancel); |
|
137 |
|
138 // clean-up |
|
139 TEST(KErrNone == property.Delete(KCustomcmdServerSID, swp.Key())); |
|
140 property.Close(); |
|
141 client.Close(); |
|
142 INFO_PRINTF3(_L("TestHandleActivateEmergencyCallCancelL completed with %d Expected %d"),status.Int(),KErrCancel); |
|
143 } |
|
144 |
|
145 TVerdict CCustomCmdTestActivateEmergencyCall::doTestStepPostambleL() |
|
146 { |
|
147 return TestStepResult(); |
|
148 } |
|
149 |
|
150 |