|
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 hspluginmodel library. |
|
15 * |
|
16 */ |
|
17 #include "t_caclient.h" |
|
18 #include "caservice.h" |
|
19 #include "caquery.h" |
|
20 |
|
21 #ifdef Q_OS_SYMBIAN |
|
22 //s60 |
|
23 #include <e32base.h> |
|
24 //#include <> |
|
25 #include <W32STD.H> |
|
26 #include <APGTASK.H> |
|
27 |
|
28 #include "t_cainstaller.h" |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 void TestCaClient::TestExecuteCommandOpen() |
|
34 { |
|
35 { |
|
36 QSharedPointer<CaService> service = CaService::instance(); |
|
37 QSharedPointer<CaEntry> entry; |
|
38 CaQuery query; |
|
39 query.setEntryRoles(ItemEntryRole); |
|
40 QList< QSharedPointer<CaEntry> > items = service->getEntries(query); |
|
41 int itemsCount = items.count(); |
|
42 QVERIFY(itemsCount >0); |
|
43 for (int i=0; i< itemsCount; i++) { |
|
44 QString tmp = items[i]->text(); |
|
45 if (items[i]->text() == "Contacts") { |
|
46 entry=items[i]; |
|
47 break; |
|
48 } |
|
49 } |
|
50 QVERIFY(entry); |
|
51 bool result = service->executeCommand(entry->id(), "open") == 0; |
|
52 QTest::qWait(2500); |
|
53 QVERIFY2(result, "Command *open* failed"); |
|
54 RWsSession session; |
|
55 TInt error = session.Connect(); |
|
56 TApaTaskList taskList(session); |
|
57 TApaTask task = taskList.FindApp(_L("Contacts")); |
|
58 QTest::qWait(250); |
|
59 bool taskExists(false); |
|
60 if (task.Exists()) { |
|
61 taskExists = true; |
|
62 task.EndTask(); |
|
63 } |
|
64 QTest::qWait(250); |
|
65 session.Close(); |
|
66 QTest::qWait(250); |
|
67 QVERIFY(taskExists); |
|
68 } |
|
69 } |
|
70 |
|
71 void TestCaClient::TestExecuteCommandRemove() |
|
72 { |
|
73 { |
|
74 |
|
75 _LIT(KAppTestFile, "c:\\testing\\data\\t_caclient\\installs\\sapiapp_S60_3_X_v_1_0_0.sisx"); |
|
76 CaQuery query; |
|
77 QSharedPointer<CaService> service = CaService::instance(); |
|
78 CaEntry *entry; |
|
79 CaEntry *entryPhonebook; |
|
80 QTest::qWait(250); |
|
81 QStringList list("application"); |
|
82 query.setEntryTypeNames(list); |
|
83 query.setFlagsOn(VisibleEntryFlag); |
|
84 RFs TheFs; |
|
85 User::LeaveIfError(TheFs.Connect()); |
|
86 |
|
87 QScopedPointer<T_CaInstaller> installer; |
|
88 QT_TRAP_THROWING(installer.reset(T_CaInstaller::NewL())); |
|
89 |
|
90 installer->InstallL( KAppTestFile ); |
|
91 |
|
92 QTest::qWait(30000); |
|
93 |
|
94 QList< QSharedPointer<CaEntry> > items = service->getEntries(query); |
|
95 |
|
96 int itemsCountAndOne = items.count(); |
|
97 |
|
98 for (int i=0; i< items.count(); i++) { |
|
99 QString tmp = items[i]->text(); |
|
100 if (items[i]->text() == "Contacts") { |
|
101 entryPhonebook=items[i].data(); |
|
102 break; |
|
103 } |
|
104 } |
|
105 |
|
106 for (int i=0; i< itemsCountAndOne; i++) { |
|
107 if (items[i]->text() == "sapiapp") { |
|
108 entry=items[i].data(); |
|
109 break; |
|
110 } |
|
111 } |
|
112 //entry attribute will be removed by appscanner |
|
113 //after "sapiapp" entry is removed |
|
114 entryPhonebook->setAttribute("mmc_id","0x12345678"); |
|
115 service->updateEntry(*entryPhonebook); |
|
116 bool result = false; |
|
117 if (entry->id() > 0) { |
|
118 result = service->executeCommand(entry->id(), "remove") == 0; |
|
119 } |
|
120 QVERIFY2(result, "Remove command returns false"); |
|
121 QTest::qWait(40000); |
|
122 |
|
123 QList< QSharedPointer<CaEntry> > itemsNew = service->getEntries(query); |
|
124 int itemsCount = itemsNew.count(); |
|
125 |
|
126 QVERIFY2(itemsCountAndOne == itemsCount +1 , "Remove unsuccessful"); |
|
127 |
|
128 } |
|
129 } |
|
130 |
|
131 |
|
132 #endif //Q_OS_SYMBIAN |