aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-04-01 16:06:27 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:19 -0300
commit2c2aa96d191135f68177df8029e891bcec56a39a (patch)
tree9d1e5329ab4893c561ba7c1ba46719d514725fc3 /tests
parent009daead512428205ac730012d4d81ec49fc47e6 (diff)
Expanded the tests that simulate QPainter::drawText even further.
The purpose of this is to provide more and more test cases for the overload decisor. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/overload.h17
-rw-r--r--tests/samplebinding/overload_test.py30
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/libsample/overload.h b/tests/libsample/overload.h
index c170be4a4..a0682fe18 100644
--- a/tests/libsample/overload.h
+++ b/tests/libsample/overload.h
@@ -89,6 +89,23 @@ public:
FunctionEnum drawText(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
FunctionEnum drawText(int a0, int a1, const Str& a2) { return Function5; }
FunctionEnum drawText(int a0, int a1, int a2, int a3, int a4, const Str& a5) { return Function6; }
+
+ // A variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText2(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText2(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText2(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText2(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ FunctionEnum drawText2(const RectF& a0, const Str& a1, const Echo& a2 = Echo()) { return Function4; }
+ FunctionEnum drawText2(int a0, int a1, const Str& a2) { return Function5; }
+ FunctionEnum drawText2(int a0, int a1, int a2, int a3 = 0, int a4 = 0, const Str& a5 = Str()) { return Function6; }
+
+ // A simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText3(const Str& a0, const Str& a1, const Str& a2) { return Function0; }
+ FunctionEnum drawText3(int a0, int a1, int a2, int a3, int a4) { return Function1; }
+
+ // Another simpler variant of the one similar to QPainter::drawText(...)
+ FunctionEnum drawText4(int a0, int a1, int a2) { return Function0; }
+ FunctionEnum drawText4(int a0, int a1, int a2, int a3, int a4) { return Function1; }
};
class LIBSAMPLE_API Overload2 : public Overload
diff --git a/tests/samplebinding/overload_test.py b/tests/samplebinding/overload_test.py
index 14a30c88b..e165ef854 100644
--- a/tests/samplebinding/overload_test.py
+++ b/tests/samplebinding/overload_test.py
@@ -116,6 +116,36 @@ class OverloadTest(unittest.TestCase):
self.assertEqual(overload.drawText(1, 2, 3, 4, 5, Str()), Overload.Function6)
self.assertEqual(overload.drawText(1, 2, 3, 4, 5, ''), Overload.Function6)
+ def testDrawText2IntIntIntIntStr(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, Str()), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5, ''), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4, 5), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3, 4), Overload.Function6)
+ self.assertEqual(overload.drawText2(1, 2, 3), Overload.Function6)
+
+ def testDrawText3(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText3(Str(), Str(), Str()), Overload.Function0)
+ self.assertEqual(overload.drawText3('', '', ''), Overload.Function0)
+ self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1)
+ self.assertEqual(overload.drawText3(1, 2, 3, 4, 5), Overload.Function1)
+
+ def testDrawText3Exception(self):
+ overload = Overload()
+ # NOTE: Using 'try' because assertRaisesRegexp is not available.
+ # to check the error text.
+ try:
+ overload.drawText3(Str(), Str(), Str(), 4, 5)
+ except Exception as err:
+ self.assertEqual(type(err), TypeError)
+ self.assertTrue('called with wrong argument types:' in str(err))
+
+ def testDrawText4(self):
+ overload = Overload()
+ self.assertEqual(overload.drawText4(1, 2, 3), Overload.Function0)
+ self.assertEqual(overload.drawText4(1, 2, 3, 4, 5), Overload.Function1)
+
if __name__ == '__main__':
unittest.main()