|
1 /* |
|
2 * Copyright (c) 2004 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 |
|
19 |
|
20 #include "t_carunningappmonitor.h" |
|
21 #include "carunningappmonitortestutils.h" |
|
22 |
|
23 |
|
24 #include "cadef.h" |
|
25 |
|
26 #include "casrvplugin.h" |
|
27 #include "castorageproxy.h" |
|
28 #include "casrvengutils.h" |
|
29 |
|
30 TUid KTestAppUid0 = {0x20022EF9}; |
|
31 TUid KTestAppUid1 = {0x20025FD9}; |
|
32 |
|
33 // phonebook 0x20022EF9 537014009 |
|
34 // control panel 0x20025FD9 537026521 |
|
35 // Bluetooth 0x10005951 268458321 |
|
36 // SW Update 0x2001FE2F 537001519 |
|
37 // notes 20029F80 537042816 |
|
38 // file mgr 2002BCC0 537050304 |
|
39 const TUid KTestedPluginUid = {0x200267B5}; |
|
40 |
|
41 |
|
42 void T_CaRunningAppMonitor::initTestCase() |
|
43 { |
|
44 } |
|
45 |
|
46 void T_CaRunningAppMonitor::cleanupTestCase() |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void T_CaRunningAppMonitor::init() |
|
55 { |
|
56 //CA env |
|
57 iTestUtils = CTestUtils::NewL(); |
|
58 iTestUtils->CopyDb(); |
|
59 iStorage = CCaStorageProxy::NewL(); |
|
60 iSrvEngUtils = CCaSrvEngUtils::NewL(); |
|
61 |
|
62 //Plugin itself |
|
63 TPluginParams params = {iStorage, iSrvEngUtils}; |
|
64 iPlugin = CCaSrvPlugin::NewL(KTestedPluginUid, ¶ms); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void T_CaRunningAppMonitor::cleanup( ) |
|
72 { |
|
73 delete iPlugin; iPlugin = 0; |
|
74 delete iSrvEngUtils; iSrvEngUtils = 0; |
|
75 delete iStorage; iStorage = 0; |
|
76 delete iTestUtils; iTestUtils = 0; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void T_CaRunningAppMonitor::T_Constuction() |
|
84 { |
|
85 //test if plugin will be loaded without proper initialization |
|
86 TInt err(KErrNone); |
|
87 CCaSrvPlugin* plugin(0); |
|
88 |
|
89 TRAP(err, plugin = CCaSrvPlugin::NewL(KTestedPluginUid,0)); |
|
90 QVERIFY(err != KErrNone); |
|
91 delete plugin; plugin = 0; |
|
92 |
|
93 TPluginParams params = {0, 0}; |
|
94 TRAP(err, plugin = CCaSrvPlugin::NewL(KTestedPluginUid,¶ms)); |
|
95 QVERIFY(err != KErrNone); |
|
96 delete plugin; plugin = 0; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void T_CaRunningAppMonitor::T_RunL() |
|
104 { |
|
105 TBool appIsRunning(EFalse); |
|
106 TInt err(KErrNone); |
|
107 |
|
108 TRAP(err, iTestUtils->LaunchApplicationL(KTestAppUid0)); |
|
109 QTest::qWait(5000); |
|
110 QCOMPARE(err, KErrNone); |
|
111 |
|
112 TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid0, *iStorage)); |
|
113 QCOMPARE(err, KErrNone); |
|
114 QVERIFY(appIsRunning != EFalse); |
|
115 |
|
116 TRAP(err, iTestUtils->TerminateApplicationL(KTestAppUid0)); |
|
117 QTest::qWait(10000); |
|
118 QCOMPARE(err, KErrNone); |
|
119 TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid0, *iStorage)); |
|
120 QTest::qWait(5000); |
|
121 QCOMPARE(err, KErrNone); |
|
122 QVERIFY(appIsRunning == EFalse); |
|
123 |
|
124 TRAP(err, iTestUtils->LaunchApplicationL(KTestAppUid1)); |
|
125 QTest::qWait(10000); |
|
126 QCOMPARE(err, KErrNone); |
|
127 TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid1, *iStorage)); |
|
128 QCOMPARE(err, KErrNone); |
|
129 QVERIFY(appIsRunning != EFalse); |
|
130 |
|
131 |
|
132 TRAP(err, iTestUtils->TerminateApplicationL(KTestAppUid1)); |
|
133 QCOMPARE(err, KErrNone); |
|
134 QTest::qWait(5000); |
|
135 TRAP(err, appIsRunning = iTestUtils->IsRunningL(KTestAppUid1, *iStorage)); |
|
136 QCOMPARE(err, KErrNone); |
|
137 QVERIFY(appIsRunning == EFalse); |
|
138 |
|
139 } |
|
140 |
|
141 QTEST_MAIN(T_CaRunningAppMonitor); |
|
142 |
|
143 // END OF FILE |