|
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: Main test class for hsHomeScreenStatePlugin library. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include<hbmessagebox.h> |
|
19 #include<hbaction.h> |
|
20 |
|
21 #ifdef Q_OS_SYMBIAN |
|
22 #include <usif/sif/sif.h> |
|
23 #include <usif/scr/scr.h> |
|
24 #endif//Q_OS_SYMBIAN |
|
25 |
|
26 #include "hsuninstallitemstate.h" |
|
27 #include "t_hsmenuworkerstateplugin.h" |
|
28 #include "hscontentservice.h" |
|
29 #include "hsshortcutservice.h" |
|
30 #include "hsmenueventfactory.h" |
|
31 #include "hsmenuevent.h" |
|
32 #include "hsmenuitemmodel.h" |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 void MenuStatesTest::HsUninstallItemState_construction() |
|
38 { |
|
39 #ifdef Q_OS_SYMBIAN |
|
40 #ifdef UT_MEMORY_CHECK |
|
41 __UHEAP_MARK; |
|
42 #endif//UT_MEMORY_CHECK |
|
43 #endif//Q_OS_SYMBIAN |
|
44 { |
|
45 QState parentState1; |
|
46 parentState1.setObjectName(tr("testName1")); |
|
47 |
|
48 HsUninstallItemState uni1(&parentState1); |
|
49 QString s1 = uni1.objectName(); |
|
50 QVERIFY(s1 == tr("testName1/UninstallItemState")); |
|
51 } |
|
52 #ifdef Q_OS_SYMBIAN |
|
53 #ifdef UT_MEMORY_CHECK |
|
54 __UHEAP_MARKEND; |
|
55 #endif//UT_MEMORY_CHECK |
|
56 #endif//Q_OS_SYMBIAN |
|
57 } |
|
58 |
|
59 |
|
60 void MenuStatesTest::HsUninstallItemState_onEntry() |
|
61 { |
|
62 #ifdef Q_OS_SYMBIAN |
|
63 #ifdef UT_MEMORY_CHECK |
|
64 __UHEAP_MARK; |
|
65 #endif//UT_MEMORY_CHECK |
|
66 #endif//Q_OS_SYMBIAN |
|
67 { |
|
68 QState parentState3; |
|
69 parentState3.setObjectName(tr("testName3")); |
|
70 HsUninstallItemState uni3(&parentState3); |
|
71 |
|
72 int SomeAppId = 14; ////app to uninst |
|
73 |
|
74 QVariantMap params; |
|
75 params.insert(Hs::itemIdKey, SomeAppId); |
|
76 |
|
77 QEvent *e = new HsMenuEvent(HsMenuEvent::UninstallApplication, params); |
|
78 |
|
79 QString s3 = uni3.objectName(); |
|
80 QCOMPARE(s3, tr("testName3/UninstallItemState")); |
|
81 |
|
82 uni3.onEntry( e ); |
|
83 checkDialogController(); |
|
84 |
|
85 QCOMPARE(uni3.mEntry->id(), SomeAppId); |
|
86 |
|
87 uni3.cleanUp(); |
|
88 |
|
89 QVERIFY(uni3.mEntry.isNull()); |
|
90 |
|
91 } |
|
92 #ifdef Q_OS_SYMBIAN |
|
93 #ifdef UT_MEMORY_CHECK |
|
94 __UHEAP_MARKEND; |
|
95 #endif//UT_MEMORY_CHECK |
|
96 #endif//Q_OS_SYMBIAN |
|
97 } |
|
98 |
|
99 #ifdef Q_OS_SYMBIAN |
|
100 void MenuStatesTest::HsUninstallItemState_getApplicationsNames() |
|
101 { |
|
102 #ifdef UT_MEMORY_CHECK |
|
103 __UHEAP_MARK; |
|
104 #endif//UT_MEMORY_CHECK |
|
105 { |
|
106 |
|
107 static const char javaUid[] = "270437153"; //in DS_Snow |
|
108 |
|
109 Usif::RSoftwareInstall sif; |
|
110 CleanupClosePushL( sif ); |
|
111 User::LeaveIfError( sif.Connect() ); |
|
112 |
|
113 // Install the component |
|
114 _LIT16( KDsSnowJadPath, "c:\\testing\\data\\t_hsmenuworkerstateplugin\\installs\\DS_Snow.jad" ); |
|
115 Usif::COpaqueNamedParams* arguments = NULL; |
|
116 Usif::COpaqueNamedParams* results = NULL; |
|
117 arguments = Usif::COpaqueNamedParams::NewLC(); |
|
118 results = Usif::COpaqueNamedParams::NewLC(); |
|
119 arguments->AddIntL( Usif::KSifInParam_InstallSilently, 1 ); |
|
120 TRequestStatus status; |
|
121 sif.Install( KDsSnowJadPath, *arguments, *results, status, EFalse ); |
|
122 User::WaitForRequest( status ); |
|
123 User::LeaveIfError( status.Int() ); |
|
124 |
|
125 CleanupStack::PopAndDestroy( results ); |
|
126 CleanupStack::PopAndDestroy( arguments ); |
|
127 |
|
128 // Disconnect from the SIF server |
|
129 CleanupStack::PopAndDestroy( &sif ); |
|
130 |
|
131 |
|
132 QSharedPointer<CaService> service = CaService::instance(); |
|
133 CaQuery query; |
|
134 query.setAttribute(Hs::applicationUidEntryKey, javaUid); |
|
135 QList< QSharedPointer<CaEntry> > entries = service->getEntries(query); |
|
136 QCOMPARE(entries.length(), 1); |
|
137 QSharedPointer<CaEntry> entry = entries[0]; |
|
138 |
|
139 HsUninstallItemState state; |
|
140 |
|
141 QVariantMap params; |
|
142 params.insert(Hs::itemIdKey, entry->id()); |
|
143 |
|
144 QEvent *e = new HsMenuEvent(HsMenuEvent::UninstallApplication, params); |
|
145 state.onEntry( e ); |
|
146 |
|
147 QCOMPARE(state.mEntry->id(), entry->id()); |
|
148 |
|
149 |
|
150 QString componentName; |
|
151 QStringList appNames; |
|
152 QString confirmationMessage; |
|
153 |
|
154 bool result = state.getApplicationsNames(componentName, |
|
155 appNames, confirmationMessage); |
|
156 QVERIFY(result); |
|
157 QCOMPARE(componentName, QString("DS_Snow")); |
|
158 QCOMPARE(appNames.length(), 0); //in DS_Snow |
|
159 |
|
160 const QString remove("remove"); |
|
161 service->executeCommand(entry->id(), remove); |
|
162 |
|
163 state.cleanUp(); |
|
164 QVERIFY(state.mEntry.isNull()); |
|
165 } |
|
166 #ifdef UT_MEMORY_CHECK |
|
167 __UHEAP_MARKEND; |
|
168 #endif//UT_MEMORY_CHECK |
|
169 } |
|
170 #endif // Q_OS_SYMBIAN |