|
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: DriveObserverServerTest |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "TestHarness.h" |
|
19 |
|
20 #include "comms.h" |
|
21 #include "commsserverendpoint.h" |
|
22 |
|
23 #include "driveutilities.h" |
|
24 |
|
25 using namespace java::fileutils; |
|
26 |
|
27 class testListener : public DriveListenerInterface |
|
28 { |
|
29 public: |
|
30 testListener() |
|
31 { // dummy calls in order to disable false memory leaks in real test cases |
|
32 // DriveUtilities::registerListener(this); |
|
33 // DriveUtilities::unregisterListener(this); |
|
34 } |
|
35 |
|
36 virtual void driveChanged(const int& aOperation, const driveInfo& /*aDriveInfo*/) |
|
37 { |
|
38 CHECK(aOperation == REMOVABLE_MEDIA_INSERTED_C || |
|
39 aOperation == REMOVABLE_MEDIA_REMOVED_C); |
|
40 } |
|
41 } listener2; |
|
42 |
|
43 |
|
44 TEST_GROUP(DriveObserverServer) |
|
45 { |
|
46 java::comms::CommsServerEndpoint comms; |
|
47 |
|
48 TEST_SETUP() |
|
49 { |
|
50 comms.start(java::comms::IPC_ADDRESS_JAVA_CAPTAIN_C+1); |
|
51 } |
|
52 |
|
53 TEST_TEARDOWN() |
|
54 { |
|
55 comms.stop(); |
|
56 } |
|
57 }; |
|
58 |
|
59 TEST(DriveObserverServer, 01_AllInOne) |
|
60 { |
|
61 DriveObserverServerInterface* server = NULL; |
|
62 server = DriveUtilities::getDriveObserverServer(); |
|
63 CHECK(server != NULL); |
|
64 server->startServer(&comms); |
|
65 |
|
66 DriveUtilities::registerListener(&listener2, |
|
67 java::comms::IPC_ADDRESS_JAVA_CAPTAIN_C+1); |
|
68 |
|
69 DriveUtilities::unregisterListener(&listener2, |
|
70 java::comms::IPC_ADDRESS_JAVA_CAPTAIN_C+1); |
|
71 |
|
72 server->stopServer(); |
|
73 |
|
74 delete server; |
|
75 } |
|
76 |