[Pkg-telepathy-commits] [telepathy-mission-control-6] 209/280: dbus-account-plugin: fail tests on various invalid method calls

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit eb7dc4a25c602de15f87fc63f56610ba5a7a05f8
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Fri Nov 15 13:40:52 2013 +0000

    dbus-account-plugin: fail tests on various invalid method calls
    
    Methods that act on a single account should always be called on an
    account that exists (if it doesn't, where did you get its name from?),
    so treat it as an error if they are called with a nonexistent account.
    
    commit() has a dual role here: the method that takes a non-NULL account
    (which acts on a single account, as described), and the method that
    takes a NULL account name (which is OK to call at any time, to commit
    all of our 0-or-more accounts).
    
    While we are not active, we don't claim to have any accounts at all,
    so treat it as an error if any method is called with a non-NULL account
    name while inactive.
    
    I've temporarily made an exception for delete_async(), although that
    exception is removed in a later patch on this branch. It's less bad
    if delete_async() is called on an account that doesn't exist, because
    if you do, the desired state ("account X doesn't exist") has already
    been reached.
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=27727
---
 tests/twisted/dbus-account-plugin.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/tests/twisted/dbus-account-plugin.c b/tests/twisted/dbus-account-plugin.c
index 493df5a..455095f 100644
--- a/tests/twisted/dbus-account-plugin.c
+++ b/tests/twisted/dbus-account-plugin.c
@@ -972,8 +972,8 @@ test_dbus_account_plugin_get_attribute (McpAccountStorage *storage,
   if (flags != NULL)
     *flags = 0;
 
-  if (!self->active || account == NULL)
-    return NULL;
+  g_return_val_if_fail (self->active, NULL);
+  g_return_val_if_fail (account != NULL, NULL);
 
   v = g_hash_table_lookup (account->attributes, attribute);
 
@@ -1008,8 +1008,8 @@ test_dbus_account_plugin_get_parameter (McpAccountStorage *storage,
   if (flags != NULL)
     *flags = 0;
 
-  if (!self->active || account == NULL)
-    return NULL;
+  g_return_val_if_fail (self->active, NULL);
+  g_return_val_if_fail (account != NULL, NULL);
 
   g_dbus_connection_emit_signal (self->bus, NULL,
       TEST_DBUS_ACCOUNT_PLUGIN_PATH, TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
@@ -1052,8 +1052,8 @@ test_dbus_account_plugin_set_attribute (McpAccountStorage *storage,
 
   DEBUG ("%s of %s", attribute, account_name);
 
-  if (!self->active || account == NULL)
-    return MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED;
+  g_return_val_if_fail (self->active, MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED);
+  g_return_val_if_fail (account != NULL, MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED);
 
   if (value == NULL)
     {
@@ -1112,8 +1112,8 @@ test_dbus_account_plugin_set_parameter (McpAccountStorage *storage,
 
   DEBUG ("%s of %s", parameter, account_name);
 
-  if (!self->active || account == NULL)
-    return MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED;
+  g_return_val_if_fail (self->active, MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED);
+  g_return_val_if_fail (account != NULL, MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED);
 
   if (value == NULL)
     {
@@ -1342,8 +1342,8 @@ test_dbus_account_plugin_commit (const McpAccountStorage *storage,
 
   account = lookup_account (self, account_name);
 
-  if (!self->active || account == NULL)
-    return FALSE;
+  g_return_val_if_fail (self->active, FALSE);
+  g_return_val_if_fail (account != NULL, FALSE);
 
   g_dbus_connection_emit_signal (self->bus, NULL,
       TEST_DBUS_ACCOUNT_PLUGIN_PATH, TEST_DBUS_ACCOUNT_PLUGIN_IFACE,
@@ -1484,8 +1484,8 @@ test_dbus_account_plugin_get_identifier (const McpAccountStorage *storage,
 
   DEBUG ("%s", account_name);
 
-  if (!self->active || account == NULL)
-    return;
+  g_return_if_fail (self->active);
+  g_return_if_fail (account != NULL);
 
   /* Our "library-specific unique identifier" is just the object-path
    * as a string. */
@@ -1503,8 +1503,8 @@ test_dbus_account_plugin_get_additional_info (const McpAccountStorage *storage,
 
   DEBUG ("%s", account_name);
 
-  if (!self->active || account == NULL)
-    return NULL;
+  g_return_val_if_fail (self->active, NULL);
+  g_return_val_if_fail (account != NULL, NULL);
 
   ret = g_hash_table_new_full (g_str_hash, g_str_equal,
       g_free, (GDestroyNotify) tp_g_value_slice_free);
@@ -1523,8 +1523,8 @@ test_dbus_account_plugin_get_restrictions (const McpAccountStorage *storage,
 
   DEBUG ("%s", account_name);
 
-  if (!self->active || account == NULL)
-    return 0;
+  g_return_val_if_fail (self->active, 0);
+  g_return_val_if_fail (account != NULL, 0);
 
   return account->restrictions;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list