aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-06 17:10:54 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:09 -0300
commit05e7ecede5304ee56a805c7b5a10d3df11cf8952 (patch)
tree02980a49df0f0b7b5224dbcf1425e1f2396dfd83 /tests/samplebinding
parent6bd9d58b31cabedbce5131548d2447341df76e21 (diff)
Added tests for a class that its only constructor is the copy one.
This simulates a situation found in QtWebKit's QWebDatabase and QWebSecurityOrigin classes. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/CMakeLists.txt2
-rw-r--r--tests/samplebinding/global.h1
-rw-r--r--tests/samplebinding/onlycopyclass_test.py52
-rw-r--r--tests/samplebinding/typesystem_sample.xml2
4 files changed, 57 insertions, 0 deletions
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 7a8ab7e88..2f4f33ccd 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -25,6 +25,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/derived_someinnerclass_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/echo_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/event_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/expression_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/friendofonlycopy_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/handleholder_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/implicitconv_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/implicitbase_wrapper.cpp
@@ -53,6 +54,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeoperators_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objectview_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objtypereference_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/oddbooluser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/onlycopy_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/overload_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/overload2_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/pairuser_wrapper.cpp
diff --git a/tests/samplebinding/global.h b/tests/samplebinding/global.h
index a4736a784..5f9179138 100644
--- a/tests/samplebinding/global.h
+++ b/tests/samplebinding/global.h
@@ -30,6 +30,7 @@
#include "objecttypeoperators.h"
#include "objectview.h"
#include "oddbool.h"
+#include "onlycopy.h"
#include "overload.h"
#include "pairuser.h"
#include "pen.h"
diff --git a/tests/samplebinding/onlycopyclass_test.py b/tests/samplebinding/onlycopyclass_test.py
new file mode 100644
index 000000000..eeeb201c7
--- /dev/null
+++ b/tests/samplebinding/onlycopyclass_test.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# version 2.1 as published by the Free Software Foundation. Please
+# review the following information to ensure the GNU Lesser General
+# Public License version 2.1 requirements will be met:
+# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+# #
+# This program 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 program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+import unittest
+from sample import OnlyCopy, FriendOfOnlyCopy
+
+class ClassWithOnlyCopyCtorTest(unittest.TestCase):
+ def testGetOne(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(type(obj), OnlyCopy)
+ self.assertEqual(obj.value(), 123)
+
+ def testGetMany(self):
+ objs = FriendOfOnlyCopy.createListOfOnlyCopy(3)
+ self.assertEqual(type(objs), list)
+ self.assertEqual(len(objs), 3)
+ for value, obj in enumerate(objs):
+ self.assertEqual(obj.value(), value)
+
+ def testPassAsValue(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(obj.value(), OnlyCopy.getValue(obj))
+
+ def testPassAsReference(self):
+ obj = FriendOfOnlyCopy.createOnlyCopy(123)
+ self.assertEqual(obj.value(), OnlyCopy.getValueFromReference(obj))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index d52fdbe80..c7d9c6960 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -306,6 +306,8 @@
</object-type>
<value-type name="ObjectTypeHolder"/>
+ <value-type name="OnlyCopy"/>
+ <value-type name="FriendOfOnlyCopy"/>
<object-type name="ObjectModel">
<enum-type name="MethodCalled" />