|
1 /* |
|
2 * Copyright (c) 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 "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 * |
|
16 */ |
|
17 /* |
|
18 * T_casatmonitor.cpp |
|
19 * |
|
20 * Created on: 2009-09-16 |
|
21 * Author: |
|
22 */ |
|
23 |
|
24 // CLASS HEADER |
|
25 |
|
26 |
|
27 #include <ecom/ecom.h> |
|
28 #include "ca2internalCRkeys.h" |
|
29 #include "T_casatmonitor.h" |
|
30 #include "casatmonitortestutils.h" |
|
31 #include "cadef.h" |
|
32 #include "waitactive.h" |
|
33 #include "casrvengutils.h" |
|
34 #include "castorageproxy.h" |
|
35 #include "casrvmanager.h" |
|
36 #include "cainnerentry.h" |
|
37 #include "cainnerquery.h" |
|
38 #include "caarraycleanup.inl" |
|
39 |
|
40 |
|
41 const TUid KSatPluginUid = {0x20026FAE}; |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void T_CaSatMonitor::WaitL(TInt aMicroSec) |
|
48 { |
|
49 CWaitActive *wait = CWaitActive::NewL(); |
|
50 wait->Wait(aMicroSec); |
|
51 delete wait; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void T_CaSatMonitor::initTestCase() |
|
59 { |
|
60 } |
|
61 |
|
62 void T_CaSatMonitor::cleanupTestCase() |
|
63 { |
|
64 } |
|
65 |
|
66 void T_CaSatMonitor::init() |
|
67 { |
|
68 iTestUtils = CTestUtils::NewL(); |
|
69 iTestUtils->CopyDb(); |
|
70 |
|
71 iStorage = CCaStorageProxy::NewL(); |
|
72 //iSrvEngUtils = CCaSrvEngUtils::NewL(); |
|
73 |
|
74 ///remember preconditions |
|
75 iTestUtils->GetRProperty(KCRUidCa, KCaSatUIName, iSatName); |
|
76 iTestUtils->GetRProperty(KCRUidCa, KCaShowSatUI, iSatVis); |
|
77 iTestUtils->WaitL(1000000); |
|
78 /// |
|
79 |
|
80 RBuf satName; |
|
81 satName.CleanupClosePushL(); |
|
82 satName.CreateL(_L("testname_old")); |
|
83 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
84 innerEntry->SetEntryTypeNameL(KCaTypeApp); |
|
85 innerEntry->SetUid(KSatUid.iUid); |
|
86 innerEntry->SetTextL(satName); |
|
87 innerEntry->AddAttributeL(KCaAttrShortName, satName); |
|
88 |
|
89 iStorage->AddL(innerEntry); |
|
90 |
|
91 TInt err = iTestUtils->DefineIntRProperty(KCRUidCa, KCaShowSatUI); |
|
92 err = iTestUtils->DefineTextRProperty(KCRUidCa, KCaSatUIName); |
|
93 err = iTestUtils->SetRProperty(KCRUidCa, KCaShowSatUI, 1); |
|
94 iTestUtils->WaitL(1000000); |
|
95 iTestUtils->SetRProperty(KCRUidCa, KCaSatUIName, _L("testname_old")); |
|
96 iTestUtils->WaitL(1000000); |
|
97 |
|
98 CleanupStack::PopAndDestroy(innerEntry); |
|
99 CleanupStack::PopAndDestroy(&satName); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void T_CaSatMonitor::cleanup() |
|
107 { |
|
108 ///restore preconditions |
|
109 iTestUtils->SetRProperty(KCRUidCa, KCaSatUIName, iSatName); |
|
110 iTestUtils->SetRProperty(KCRUidCa, KCaShowSatUI, iSatVis); |
|
111 |
|
112 delete iStorage; |
|
113 iStorage = NULL; |
|
114 delete iTestUtils; |
|
115 iTestUtils = NULL; |
|
116 REComSession::FinalClose(); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void T_CaSatMonitor::testSatChange() |
|
124 { |
|
125 bool nonEmptySatList(false); |
|
126 bool nameMatches(false); |
|
127 TInt err(KErrNone); |
|
128 |
|
129 TPluginParams params; |
|
130 params.engUtils = 0; |
|
131 params.storageProxy = iStorage; |
|
132 |
|
133 TRAP(err, |
|
134 CCaSrvPlugin *plug = iTestUtils->LoadPluginL(KSatPluginUid, params); |
|
135 iTestUtils->WaitL(10000000);//load plugin |
|
136 |
|
137 RBuf newSatName; |
|
138 newSatName.CleanupClosePushL(); |
|
139 newSatName.CreateL(_L("testname")); |
|
140 |
|
141 TInt err = iTestUtils->SetRProperty( |
|
142 KCRUidCa, KCaSatUIName, newSatName); |
|
143 err = iTestUtils->SetRProperty( |
|
144 KCRUidCa, KCaShowSatUI, 1); |
|
145 iTestUtils->WaitL(10000000); |
|
146 delete plug; |
|
147 CCaInnerQuery *satAppQuery = CCaInnerQuery::NewLC(); |
|
148 satAppQuery->SetUid(KSatUid.iUid); |
|
149 RPointerArray<CCaInnerEntry> resultArray; |
|
150 CleanupResetAndDestroyPushL(resultArray); |
|
151 iStorage->GetEntriesL(satAppQuery, resultArray); |
|
152 |
|
153 nonEmptySatList = (resultArray.Count() >= 1); |
|
154 nameMatches = newSatName.Compare(resultArray[0]->GetText()) == 0; |
|
155 |
|
156 |
|
157 CleanupStack::PopAndDestroy(&resultArray); |
|
158 CleanupStack::PopAndDestroy(satAppQuery); |
|
159 CleanupStack::PopAndDestroy(&newSatName); |
|
160 ); |
|
161 QCOMPARE(err, KErrNone); |
|
162 QVERIFY(nonEmptySatList); |
|
163 QVERIFY(nameMatches); |
|
164 } |
|
165 |
|
166 QTEST_MAIN(T_CaSatMonitor); |