Test FDN Daemon info
This commit is contained in:
		
							parent
							
								
									fb483347ed
								
							
						
					
					
						commit
						57a6baae85
					
				
							
								
								
									
										22
									
								
								src/dbus.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/dbus.c
									
									
									
									
									
								
							| @ -451,7 +451,7 @@ static void dbus_cb_name_acquired(GDBusConnection *connection, | |||||||
|  * If name or vendor specified, the name and vendor |  * If name or vendor specified, the name and vendor | ||||||
|  * will get additionally get via the FDN GetServerInformation method |  * will get additionally get via the FDN GetServerInformation method | ||||||
|  * |  * | ||||||
|  * @param connection The dbus connection |  * @param connection The DBus connection | ||||||
|  * @param pid The place to report the PID to |  * @param pid The place to report the PID to | ||||||
|  * @param name The place to report the name to, if not required set to NULL |  * @param name The place to report the name to, if not required set to NULL | ||||||
|  * @param vendor The place to report the vendor to, if not required set to NULL |  * @param vendor The place to report the vendor to, if not required set to NULL | ||||||
| @ -459,9 +459,9 @@ static void dbus_cb_name_acquired(GDBusConnection *connection, | |||||||
|  * @returns `true` on success, otherwise `false` |  * @returns `true` on success, otherwise `false` | ||||||
|  */ |  */ | ||||||
| static bool dbus_get_fdn_daemon_info(GDBusConnection  *connection, | static bool dbus_get_fdn_daemon_info(GDBusConnection  *connection, | ||||||
|                                     int   *pid, |                                      guint   *pid, | ||||||
|                                     char **name, |                                      char   **name, | ||||||
|                                     char **vendor) |                                      char   **vendor) | ||||||
| { | { | ||||||
|         g_return_val_if_fail(pid, false); |         g_return_val_if_fail(pid, false); | ||||||
|         g_return_val_if_fail(connection, false); |         g_return_val_if_fail(connection, false); | ||||||
| @ -542,17 +542,19 @@ static bool dbus_get_fdn_daemon_info(GDBusConnection  *connection, | |||||||
|                 return false; |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         g_variant_get(pidinfo, "(u)", &pid); |  | ||||||
| 
 |  | ||||||
|         g_object_unref(proxy_fdn); |         g_object_unref(proxy_fdn); | ||||||
|         g_object_unref(proxy_dbus); |         g_object_unref(proxy_dbus); | ||||||
|         g_free(owner); |         g_free(owner); | ||||||
|         if (daemoninfo) |         if (daemoninfo) | ||||||
|                 g_variant_unref(daemoninfo); |                 g_variant_unref(daemoninfo); | ||||||
|         if (pidinfo) |  | ||||||
|                 g_variant_unref(pidinfo); |  | ||||||
| 
 | 
 | ||||||
|         return true; |         if (pidinfo) { | ||||||
|  |                 g_variant_get(pidinfo, "(u)", &pid); | ||||||
|  |                 g_variant_unref(pidinfo); | ||||||
|  |                 return true; | ||||||
|  |         } else { | ||||||
|  |                 return false; | ||||||
|  |         } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -562,7 +564,7 @@ static void dbus_cb_name_lost(GDBusConnection *connection, | |||||||
| { | { | ||||||
|         if (connection) { |         if (connection) { | ||||||
|                 char *name; |                 char *name; | ||||||
|                 int pid; |                 unsigned int pid; | ||||||
|                 if (dbus_get_fdn_daemon_info(connection, &pid, &name, NULL)) { |                 if (dbus_get_fdn_daemon_info(connection, &pid, &name, NULL)) { | ||||||
|                         DIE("Cannot acquire '"FDN_NAME"': " |                         DIE("Cannot acquire '"FDN_NAME"': " | ||||||
|                             "Name is acquired by '%s' with PID '%d'.", name, pid); |                             "Name is acquired by '%s' with PID '%d'.", name, pid); | ||||||
|  | |||||||
							
								
								
									
										25
									
								
								test/dbus.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								test/dbus.c
									
									
									
									
									
								
							| @ -362,6 +362,29 @@ TEST test_close_and_signal(void) | |||||||
|         PASS(); |         PASS(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | TEST test_get_fdn_daemon_info(void) | ||||||
|  | { | ||||||
|  |         unsigned int pid_is; | ||||||
|  |         pid_t pid_should; | ||||||
|  |         char *name, *vendor; | ||||||
|  |         GDBusConnection *conn; | ||||||
|  | 
 | ||||||
|  |         pid_should = getpid(); | ||||||
|  |         conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); | ||||||
|  | 
 | ||||||
|  |         ASSERT(dbus_get_fdn_daemon_info(conn, &pid_is, &name, &vendor)); | ||||||
|  | 
 | ||||||
|  |         ASSERT_EQ_FMT(pid_should, pid_is, "%d"); | ||||||
|  |         ASSERT_STR_EQ("dunst", name); | ||||||
|  |         ASSERT_STR_EQ("knopwob", vendor); | ||||||
|  | 
 | ||||||
|  |         g_free(name); | ||||||
|  |         g_free(vendor); | ||||||
|  | 
 | ||||||
|  |         g_object_unref(conn); | ||||||
|  |         PASS(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| TEST assert_methodlists_sorted(void) | TEST assert_methodlists_sorted(void) | ||||||
| { | { | ||||||
|         for (size_t i = 0; i+1 < G_N_ELEMENTS(methods_fdn); i++) { |         for (size_t i = 0; i+1 < G_N_ELEMENTS(methods_fdn); i++) { | ||||||
| @ -383,6 +406,8 @@ gpointer run_threaded_tests(gpointer data) | |||||||
| { | { | ||||||
|         RUN_TEST(test_dbus_init); |         RUN_TEST(test_dbus_init); | ||||||
| 
 | 
 | ||||||
|  |         RUN_TEST(test_get_fdn_daemon_info); | ||||||
|  | 
 | ||||||
|         RUN_TEST(test_empty_notification); |         RUN_TEST(test_empty_notification); | ||||||
|         RUN_TEST(test_basic_notification); |         RUN_TEST(test_basic_notification); | ||||||
|         RUN_TEST(test_invalid_notification); |         RUN_TEST(test_invalid_notification); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine