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