[glibmm] Rename Gio::DBus::DBusError to Gio::DBus::Error.



commit e83194f152f896b344da937b8f3512b933e1fb10
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Feb 24 12:40:59 2011 +0100

    Rename Gio::DBus::DBusError to Gio::DBus::Error.
    
    * gio/src/dbuserror.hg: Rename the class to Error.
    * examples/dbus/busserver.cc: Adapated.
    * tests/giomm_ioerror_and_iodbuserror/main.cc: Added a test to check that
    both Gio::Error and Gio::DBus::Error are working.
    * tests/Makefile.am: Set TESTS, so that the test is actually run.
    We should add others to this too.
    
    This current fails, so I need to fix the problem in a subsequent commit.

 ChangeLog                                   |   13 +++++
 examples/dbus/busserver.cc                  |    6 +-
 gio/src/dbuserror.hg                        |    2 +-
 tests/Makefile.am                           |    6 ++
 tests/giomm_ioerror_and_iodbuserror/main.cc |   76 +++++++++++++++++++++++++++
 5 files changed, 99 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 13ed818..a85bb14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2011-02-24  Murray Cumming  <murrayc murrayc com>
 
+	Rename Gio::DBus::DBusError to Gio::DBus::Error.
+
+	* gio/src/dbuserror.hg: Rename the class to Error.
+	* examples/dbus/busserver.cc: Adapated.
+	* tests/giomm_ioerror_and_iodbuserror/main.cc: Added a test to check that 
+	both Gio::Error and Gio::DBus::Error are working.
+	* tests/Makefile.am: Set TESTS, so that the test is actually run.
+	We should add others to this too.
+	
+	This current fails, so I need to fix the problem in a subsequent commit.
+
+2011-02-24  Murray Cumming  <murrayc murrayc com>
+
 	Move Gio::DBusError to Gio::Dbus::DBusError.
 
 	* tools/m4/base.m4: Added a SECTION_H_GERROR_PRIVATE section.
diff --git a/examples/dbus/busserver.cc b/examples/dbus/busserver.cc
index 8d87e4f..3beeca2 100644
--- a/examples/dbus/busserver.cc
+++ b/examples/dbus/busserver.cc
@@ -100,7 +100,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& connection
     if(!curr_alarm.assign_from_iso8601(time_str))
     {
       // If setting alarm was not successful, return an error.
-      Gio::DBus::DBusError error(Gio::DBus::DBusError::INVALID_ARGS,
+      Gio::DBus::Error error(Gio::DBus::Error::INVALID_ARGS,
           "Alarm string is not in ISO8601 format.");
       invocation->return_gerror(error);
     }
@@ -144,7 +144,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& connection
   else
   {
     // Non-existent method on the interface.
-    Gio::DBus::DBusError error(Gio::DBus::DBusError::UNKNOWN_METHOD,
+    Gio::DBus::Error error(Gio::DBus::Error::UNKNOWN_METHOD,
       "Method does not exist.");
     invocation->return_gerror(error);
   }
@@ -174,7 +174,7 @@ void on_get_property(Glib::VariantBase& property,
   }
   else
   {
-    throw Gio::DBus::DBusError(Gio::DBus::DBusError::FAILED, "Unknown property name.");
+    throw Gio::DBus::Error(Gio::DBus::Error::FAILED, "Unknown property name.");
   }
 }
 
diff --git a/gio/src/dbuserror.hg b/gio/src/dbuserror.hg
index 15fb8ef..0828ebf 100644
--- a/gio/src/dbuserror.hg
+++ b/gio/src/dbuserror.hg
@@ -41,7 +41,7 @@ _GMMPROC_EXTRA_NAMESPACE(DBus)
   friend void Gio::wrap_init(); // uses throw_func()
 #m4 _POP()
 
-_WRAP_GERROR(DBusError, GDBusError, G_DBUS_ERROR, NO_GTYPE)
+_WRAP_GERROR(Error, GDBusError, G_DBUS_ERROR, NO_GTYPE)
 
 } //namespace DBus
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b2015ff..66adf20 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 check_PROGRAMS =				\
 	giomm_ioerror/test			\
+	giomm_ioerror_and_iodbuserror/test			\
 	giomm_simple/test			\
 	giomm_asyncresult_sourceobject/test	\
 	glibmm_btree/test			\
@@ -33,6 +34,8 @@ check_PROGRAMS =				\
 	glibmm_vector/test			\
 	glibmm_bool_vector/test			\
 	glibmm_bool_arrayhandle/test
+	
+TESTS =	giomm_ioerror_and_iodbuserror/test
 
 glibmm_includes = -I$(top_builddir)/glib $(if $(srcdir:.=),-I$(top_srcdir)/glib)
 giomm_includes  = -I$(top_builddir)/gio $(if $(srcdir:.=),-I$(top_srcdir)/gio)
@@ -50,6 +53,9 @@ giomm_ldadd = $(local_libglibmm) $(local_libgiomm) $(GIOMM_LIBS)
 giomm_ioerror_test_SOURCES = giomm_ioerror/main.cc
 giomm_ioerror_test_LDADD   = $(giomm_ldadd)
 
+giomm_ioerror_and_iodbuserror_test_SOURCES = giomm_ioerror_and_iodbuserror/main.cc
+giomm_ioerror_and_iodbuserror_test_LDADD   = $(giomm_ldadd)
+
 giomm_simple_test_SOURCES  = giomm_simple/main.cc
 giomm_simple_test_LDADD    = $(giomm_ldadd)
 
diff --git a/tests/giomm_ioerror_and_iodbuserror/main.cc b/tests/giomm_ioerror_and_iodbuserror/main.cc
new file mode 100644
index 0000000..1e7dbc6
--- /dev/null
+++ b/tests/giomm_ioerror_and_iodbuserror/main.cc
@@ -0,0 +1,76 @@
+#include <giomm.h>
+#include <gio/gio.h> //For the C enum values.
+#include <iostream>
+#include <string.h>
+
+// This tests that both Gio::Error and Gio::DBus::Error are registered in 
+// Gio::wrap_init(), and that they are properly registered.
+// This was previously a problem, but is now fixed, and we want to make sure 
+// that we don't regress.
+
+int main(int, char**)
+{
+  Glib::init();
+  Gio::init();
+
+  //Check that Gio::Error is thrown:
+  bool gio_error_thrown = false;
+  try
+  {
+    GError* gerror = g_error_new_literal (G_IO_ERROR,
+      G_IO_ERROR_INVALID_ARGUMENT, "Arbitrary test error text.");
+    ::Glib::Error::throw_exception(gerror);
+  }
+  catch(const Gio::Error& /* ex */)
+  {
+    gio_error_thrown = true;
+  }
+  catch(const Gio::DBus::Error& ex)
+  {
+    std::cerr << "Gio::DBus::Error caught when a Gio::Error was expected." << std::endl;
+    return EXIT_FAILURE;
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << "Glib::Error caught when a Gio::Error was expected." << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  if(!gio_error_thrown)
+  {
+    std::cerr << "Gio::Error was not thrown, but should have been thrown." << std::endl; 
+    return EXIT_FAILURE;
+  }
+  
+  //Check that Gio::DBus::Error is thrown:
+  bool gio_dbus_error_thrown = false;
+  try
+  {
+    GError* gerror = g_error_new_literal (G_DBUS_ERROR,
+      G_DBUS_ERROR_FAILED, "Arbitrary test error text.");
+    ::Glib::Error::throw_exception(gerror);
+  }
+  catch(const Gio::DBus::Error& /* ex */)
+  {
+    gio_dbus_error_thrown = true;
+  }
+  catch(const Gio::Error& ex)
+  {
+    std::cerr << "Gio::Error caught when a Gio::Dbus::Error was expected." << std::endl;
+    return EXIT_FAILURE;
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << "Glib::Error caught when a Gio::DBus::Error was expected." << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  if(!gio_dbus_error_thrown)
+  {
+    std::cerr << "Gio::DBus::Error was not thrown, but should have been thrown." << std::endl; 
+    return EXIT_FAILURE;
+  }
+  
+  return EXIT_SUCCESS;
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]