|
1 /* |
|
2 * Copyright (c) 2008 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: Pmctest |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "TestHarness.h" |
|
19 |
|
20 #include "commsclientendpoint.h" |
|
21 #include "comms.h" |
|
22 |
|
23 #include "testmessages.h" |
|
24 |
|
25 using namespace java::comms; |
|
26 using namespace java::captain; |
|
27 |
|
28 extern java::comms::CommsClientEndpoint* commsClient; |
|
29 |
|
30 static const int sendReceiveTimeout = 10; |
|
31 |
|
32 TEST_GROUP(Pmc) |
|
33 { |
|
34 TEST_SETUP() |
|
35 { |
|
36 } |
|
37 |
|
38 TEST_TEARDOWN() |
|
39 { |
|
40 } |
|
41 }; |
|
42 |
|
43 TEST(Pmc, PMC04_Kill) |
|
44 { |
|
45 CommsMessage msg; |
|
46 setProcessKillParameters(msg, 100); |
|
47 CHECK(commsClient->send(msg) == 0); |
|
48 } |
|
49 |
|
50 TEST(Pmc, PMC03_Terminate) |
|
51 { |
|
52 CommsMessage msg; |
|
53 setProcessTerminateParameters(msg, 100); |
|
54 CHECK(commsClient->send(msg) == 0); |
|
55 } |
|
56 |
|
57 TEST(Pmc, PMC02_LaunchNonExisting) |
|
58 { |
|
59 CommsMessage msg; |
|
60 std::string exe("javadestroyer"), params("GiveMeAll"); |
|
61 |
|
62 msg.setModuleId(PLUGIN_ID_JAVACAPTAIN_TESTER_C); |
|
63 setProcessStartParameters(msg, exe, params); |
|
64 |
|
65 CommsMessage receivedMsg; |
|
66 CHECK(commsClient->sendReceive(msg, receivedMsg, sendReceiveTimeout) == 0); |
|
67 |
|
68 CHECK(receivedMsg.getMessageId() == IPC_MESSAGE_TEST_ACK); |
|
69 CHECK(msg.getMessageRef() == receivedMsg.getMessageRef()); |
|
70 |
|
71 int status; |
|
72 getAckParameters(receivedMsg, status); |
|
73 #ifdef __SYMBIAN32__ |
|
74 CHECK(status < 1); // pid < 1 == launch failed |
|
75 #else |
|
76 CHECK(status > 0); // Linux: fork() always succeeds |
|
77 #endif |
|
78 } |
|
79 |
|
80 TEST(Pmc, PMC01_LaunchExisting) |
|
81 { |
|
82 CommsMessage msg; |
|
83 std::string exe("javainstaller"), params("list"); |
|
84 |
|
85 msg.setModuleId(PLUGIN_ID_JAVACAPTAIN_TESTER_C); |
|
86 setProcessStartParameters(msg, exe, params); |
|
87 |
|
88 CommsMessage receivedMsg; |
|
89 CHECK(commsClient->sendReceive(msg, receivedMsg, sendReceiveTimeout) == 0); |
|
90 |
|
91 CHECK(receivedMsg.getMessageId() == IPC_MESSAGE_TEST_ACK); |
|
92 CHECK(msg.getMessageRef() == receivedMsg.getMessageRef()); |
|
93 |
|
94 int status; |
|
95 getAckParameters(receivedMsg, status); |
|
96 CHECK(status > 0); // in Linux fork() always succeeds |
|
97 } |
|
98 |