aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-12-16 14:08:29 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:49 -0300
commit36c80e6daab7b8d69458c1a8154f4a17ee1ea303 (patch)
treeec11e8808640f67d27530f8f3ac18d62f1463751 /tests/libsample
parent18fedbce6893ee76c3dce04f0aaf814c93d57a34 (diff)
Added tests to check the release of ownership of objects returned from Python.
The ObjectModel test class was introduced to check if the transference of ownership of objects returned from Python to C++ through a virtual method is working properly. Also updated the other test that uses the ObjectView class. Reviewed by Lauro Moura <lauro.neto@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/CMakeLists.txt1
-rw-r--r--tests/libsample/objectmodel.cpp36
-rw-r--r--tests/libsample/objectmodel.h46
-rw-r--r--tests/libsample/objectview.cpp8
-rw-r--r--tests/libsample/objectview.h11
5 files changed, 97 insertions, 5 deletions
diff --git a/tests/libsample/CMakeLists.txt b/tests/libsample/CMakeLists.txt
index 3452c5761..b6cd1b923 100644
--- a/tests/libsample/CMakeLists.txt
+++ b/tests/libsample/CMakeLists.txt
@@ -16,6 +16,7 @@ modifications.cpp
mapuser.cpp
modified_constructor.cpp
multiple_derived.cpp
+objectmodel.cpp
objecttype.cpp
objecttypelayout.cpp
objectview.cpp
diff --git a/tests/libsample/objectmodel.cpp b/tests/libsample/objectmodel.cpp
new file mode 100644
index 000000000..93c25645e
--- /dev/null
+++ b/tests/libsample/objectmodel.cpp
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "objectmodel.h"
+
+void
+ObjectModel::setData(ObjectType* data)
+{
+ m_data = data;
+}
+
+ObjectType*
+ObjectModel::data() const
+{
+ return m_data;
+}
+
diff --git a/tests/libsample/objectmodel.h b/tests/libsample/objectmodel.h
new file mode 100644
index 000000000..b226b1f92
--- /dev/null
+++ b/tests/libsample/objectmodel.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef OBJECTMODEL_H
+#define OBJECTMODEL_H
+
+#include "objecttype.h"
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API ObjectModel : public ObjectType
+{
+public:
+ ObjectModel(ObjectType* parent = 0)
+ : ObjectType(parent), m_data(0)
+ {}
+
+ void setData(ObjectType* data);
+ virtual ObjectType* data() const;
+
+private:
+ // The model holds only one piece of data.
+ // (This is just a test after all.)
+ ObjectType* m_data;
+};
+
+#endif // OBJECTMODEL_H
+
diff --git a/tests/libsample/objectview.cpp b/tests/libsample/objectview.cpp
index 835e71839..a5dbc0f19 100644
--- a/tests/libsample/objectview.cpp
+++ b/tests/libsample/objectview.cpp
@@ -21,7 +21,7 @@
*/
#include "objectview.h"
-#include "objecttype.h"
+#include "objectmodel.h"
#include "str.h"
Str
@@ -40,3 +40,9 @@ ObjectView::modifyModelData(Str& data)
}
+ObjectType*
+ObjectView::getRawModelData()
+{
+ return m_model->data();
+}
+
diff --git a/tests/libsample/objectview.h b/tests/libsample/objectview.h
index fd3d640b4..3402b6d89 100644
--- a/tests/libsample/objectview.h
+++ b/tests/libsample/objectview.h
@@ -27,22 +27,25 @@
#include "libsamplemacros.h"
class Str;
+class ObjectModel;
class LIBSAMPLE_API ObjectView : public ObjectType
{
public:
- ObjectView(ObjectType* model = 0, ObjectType* parent = 0)
+ ObjectView(ObjectModel* model = 0, ObjectType* parent = 0)
: ObjectType(parent), m_model(model)
{}
- inline void setModel(ObjectType* model) { m_model = model; }
- inline ObjectType* model() const { return m_model; }
+ inline void setModel(ObjectModel* model) { m_model = model; }
+ inline ObjectModel* model() const { return m_model; }
Str displayModelData();
void modifyModelData(Str& data);
+ ObjectType* getRawModelData();
+
private:
- ObjectType* m_model;
+ ObjectModel* m_model;
};
#endif // OBJECTVIEW_H