|
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: timerserverhelpers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "TestHarness.h" |
|
20 |
|
21 #include "timerserverhelpers.h" |
|
22 |
|
23 using namespace java::comms; |
|
24 using namespace java::captain; |
|
25 using namespace java::util; |
|
26 |
|
27 static const int sendReceiveTimeout = 10; |
|
28 |
|
29 void tsCommsListener::processMessage(CommsMessage& message) |
|
30 { |
|
31 switch (message.getMessageId()) |
|
32 { |
|
33 case IPC_MESSAGE_TEST_TIMEOUT: |
|
34 getTimeoutParameters(message, mTimerId); |
|
35 mMonitor1->notify(); |
|
36 mMonitor2->wait(); |
|
37 } |
|
38 } |
|
39 |
|
40 |
|
41 void startSecondsTimer(int& timerId, int timeout) |
|
42 { |
|
43 CommsMessage msg; |
|
44 msg.setModuleId(PLUGIN_ID_JAVACAPTAIN_TESTER_C); |
|
45 setTimerStartSecondsParameters(msg, timeout); |
|
46 |
|
47 CommsMessage receivedMsg; |
|
48 CHECK(commsClient->sendReceive(msg, receivedMsg, sendReceiveTimeout) == 0); |
|
49 |
|
50 CHECK(msg.getModuleId() == receivedMsg.getModuleId()); |
|
51 CHECK(receivedMsg.getMessageId() == IPC_MESSAGE_TEST_TIMER_ACK); |
|
52 CHECK(msg.getMessageRef() == receivedMsg.getMessageRef()); |
|
53 |
|
54 getTimerAckParameters(receivedMsg, timerId); |
|
55 CHECK(timerId != 0); |
|
56 } |
|
57 |
|
58 void startJavaTimeTimer(int& timerId, long long timeout) |
|
59 { |
|
60 CommsMessage msg; |
|
61 msg.setModuleId(PLUGIN_ID_JAVACAPTAIN_TESTER_C); |
|
62 setTimerStartJavaTimeParameters(msg, timeout); |
|
63 |
|
64 CommsMessage receivedMsg; |
|
65 CHECK(commsClient->sendReceive(msg, receivedMsg, sendReceiveTimeout) == 0); |
|
66 |
|
67 CHECK(msg.getModuleId() == receivedMsg.getModuleId()); |
|
68 CHECK(receivedMsg.getMessageId() == IPC_MESSAGE_TEST_TIMER_ACK); |
|
69 CHECK(msg.getMessageRef() == receivedMsg.getMessageRef()); |
|
70 |
|
71 getTimerAckParameters(receivedMsg, timerId); |
|
72 CHECK(timerId != 0); |
|
73 } |
|
74 |
|
75 void stopTimer(int aTimerId) |
|
76 { |
|
77 CommsMessage msg; |
|
78 msg.setModuleId(PLUGIN_ID_JAVACAPTAIN_TESTER_C); |
|
79 setTimerStopParameters(msg, aTimerId); |
|
80 |
|
81 CommsMessage receivedMsg; |
|
82 CHECK(commsClient->sendReceive(msg, receivedMsg, sendReceiveTimeout) == 0); |
|
83 |
|
84 CHECK(msg.getModuleId() == receivedMsg.getModuleId()); |
|
85 CHECK(receivedMsg.getMessageId() == IPC_MESSAGE_TEST_TIMER_ACK); |
|
86 CHECK(msg.getMessageRef() == receivedMsg.getMessageRef()); |
|
87 |
|
88 int timerId; |
|
89 getTimerAckParameters(receivedMsg, timerId); |
|
90 CHECK(timerId == aTimerId); |
|
91 return; |
|
92 } |
|
93 |