summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2013-04-06 22:52:27 +0200
committerMurray Cumming <murrayc@murrayc.com>2013-04-06 22:52:27 +0200
commit98ace3653edcb7590904f6e7d997deacff08fcd5 (patch)
tree2f4c1834633a9ff1d478d58da16f7db486859953
parent4c4fef8a57a0532d390a1542720aa9f2cc47568f (diff)
downloadglibmm-98ace3653edcb7590904f6e7d997deacff08fcd5.tar.gz
Add a test of implementing an interface.
* tests/Makefile.am: * tests/glibmm_interface_implementation/main.cc: Add a very simple test that implements an interface, with a vfunc implementation and make sure that the vfunc is called when the caller method is called.
-rw-r--r--ChangeLog9
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/glibmm_interface_implementation/main.cc41
3 files changed, 55 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a595f0c..ce0349de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-04-06 Murray Cumming <murrayc@murrayc.com>
+
+ Add a test of implementing an interface.
+
+ * tests/Makefile.am:
+ * tests/glibmm_interface_implementation/main.cc: Add a very simple
+ test that implements an interface, with a vfunc implementation and
+ make sure that the vfunc is called when the caller method is called.
+
2013-04-02 José Alburquerque <jaalburquerque@gmail.com>
ByteArray: Add a Glib::Value<> template specialization for it.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f58e18c7..bfee2a5e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,6 +25,7 @@ check_PROGRAMS = \
glibmm_btree/test \
glibmm_date/test \
glibmm_buildfilename/test \
+ glibmm_interface_implementation/test \
glibmm_nodetree/test \
glibmm_ustring_compose/test \
glibmm_ustring_format/test \
@@ -69,6 +70,10 @@ giomm_asyncresult_sourceobject_test_LDADD = $(giomm_ldadd)
glibmm_btree_test_SOURCES = glibmm_btree/main.cc
glibmm_buildfilename_test_SOURCES = glibmm_buildfilename/main.cc
glibmm_date_test_SOURCES = glibmm_date/main.cc
+
+glibmm_interface_implementation_test_SOURCES = glibmm_interface_implementation/main.cc
+glibmm_interface_implementation_test_LDADD = $(giomm_ldadd)
+
glibmm_nodetree_test_SOURCES = glibmm_nodetree/main.cc
glibmm_ustring_compose_test_SOURCES = glibmm_ustring_compose/main.cc
glibmm_ustring_format_test_SOURCES = glibmm_ustring_format/main.cc
diff --git a/tests/glibmm_interface_implementation/main.cc b/tests/glibmm_interface_implementation/main.cc
new file mode 100644
index 00000000..dfbb7169
--- /dev/null
+++ b/tests/glibmm_interface_implementation/main.cc
@@ -0,0 +1,41 @@
+#include <glibmm.h>
+#include <giomm.h> //There are no Interfaces in glibmm, but there are in giomm.
+#include <iostream>
+
+//TODO: I also tried Glib::Action, but that needs us to implement interface properties. murrayc
+class CustomConverter :
+ public Glib::Object,
+ public Gio::Converter
+{
+public:
+ CustomConverter();
+
+protected:
+ //Implement a vfunc:
+ virtual void reset_vfunc();
+};
+
+CustomConverter::CustomConverter()
+: Glib::ObjectBase( typeid(CustomConverter) ),
+ Glib::Object()
+{
+}
+
+static bool reset_called = false;
+
+void CustomConverter::reset_vfunc()
+{
+ reset_called = true;
+}
+
+
+int main(int, char**)
+{
+ Glib::init();
+
+ CustomConverter converter;
+ converter.reset();
+ g_assert(reset_called);
+
+ return EXIT_SUCCESS;
+}