|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include<stdio.h> |
|
20 #include <dbus/dbus.h> |
|
21 #include <stdlib.h> |
|
22 #include <string.h> |
|
23 |
|
24 #define LOG_FILE "c:\\logs\\dbus_connection_get_is_connected0_log1.txt" |
|
25 #include "std_log_result.h" |
|
26 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
27 |
|
28 void create_xml(int result) |
|
29 { |
|
30 if(result) |
|
31 assert_failed = 1; |
|
32 |
|
33 testResultXml("dbus_connection_get_is_connected0"); |
|
34 close_log_file(); |
|
35 } |
|
36 |
|
37 int CheckConnection(DBusConnection* conn, DBusError* error) |
|
38 { |
|
39 if(!conn) |
|
40 { |
|
41 std_log(LOG_FILENAME_LINE, "Failed to get connection with error :: %s\n%s", error->name, error->message); |
|
42 |
|
43 dbus_error_free(error); |
|
44 return FALSE; |
|
45 } |
|
46 |
|
47 return TRUE; |
|
48 } |
|
49 |
|
50 int main() |
|
51 { |
|
52 DBusError error; |
|
53 DBusConnection* connection; |
|
54 |
|
55 dbus_error_init(&error); |
|
56 |
|
57 connection = dbus_bus_get_private(DBUS_BUS_SESSION, &error); |
|
58 if(!CheckConnection(connection, &error)) |
|
59 { |
|
60 create_xml(1); |
|
61 return 1; |
|
62 } |
|
63 |
|
64 if(!dbus_connection_get_is_connected(connection)) |
|
65 { |
|
66 std_log(LOG_FILENAME_LINE, "There is no Connection"); |
|
67 create_xml(1); |
|
68 return 1; |
|
69 } |
|
70 |
|
71 dbus_connection_close(connection); |
|
72 |
|
73 if(dbus_connection_get_is_connected(connection)) |
|
74 { |
|
75 std_log(LOG_FILENAME_LINE, "There is still Connection after connection closed"); |
|
76 create_xml(1); |
|
77 return 1; |
|
78 } |
|
79 |
|
80 dbus_connection_unref(connection); |
|
81 dbus_shutdown(); |
|
82 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
83 create_xml(0); |
|
84 return 0; |
|
85 } |