aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-03-30 16:42:08 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:19 -0300
commit009daead512428205ac730012d4d81ec49fc47e6 (patch)
tree555dfbdf7f81d0526c780060a17f435c6d6f3930 /tests/libsample
parent93787c322144f3c11acf261655b89a25176ce528 (diff)
Added unit tests to simulate the QPainter::drawText overloads.
The classes Rect and RectF were added to help with the imitation.
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/overload.h17
-rw-r--r--tests/libsample/rect.h80
2 files changed, 96 insertions, 1 deletions
diff --git a/tests/libsample/overload.h b/tests/libsample/overload.h
index 3ffd0ac92..c170be4a4 100644
--- a/tests/libsample/overload.h
+++ b/tests/libsample/overload.h
@@ -23,10 +23,13 @@
#ifndef OVERLOAD_H
#define OVERLOAD_H
+#include "echo.h"
#include "str.h"
#include "size.h"
#include "point.h"
+#include "pointf.h"
#include "polygon.h"
+#include "rect.h"
#include "libsamplemacros.h"
@@ -37,7 +40,10 @@ public:
Function0,
Function1,
Function2,
- Function3
+ Function3,
+ Function4,
+ Function5,
+ Function6
};
enum ParamEnum {
@@ -74,6 +80,15 @@ public:
FunctionEnum strBufferOverloads(const Str& arg0, const char* arg1 = 0, bool arg2 = true) { return Function0; }
FunctionEnum strBufferOverloads(unsigned char* arg0, int arg1) { return Function1; }
FunctionEnum strBufferOverloads() { return Function2; }
+
+ // Similar to QPainter::drawText(...)
+ FunctionEnum drawText(const Point& a0, const Str& a1) { return Function0; }
+ FunctionEnum drawText(const PointF& a0, const Str& a1) { return Function1; }
+ FunctionEnum drawText(const Rect& a0, int a1, const Str& a2) { return Function2; }
+ FunctionEnum drawText(const RectF& a0, int a1, const Str& a2) { return Function3; }
+ 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; }
};
class LIBSAMPLE_API Overload2 : public Overload
diff --git a/tests/libsample/rect.h b/tests/libsample/rect.h
new file mode 100644
index 000000000..e74d8f47a
--- /dev/null
+++ b/tests/libsample/rect.h
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2011 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 RECT_H
+#define RECT_H
+
+#include "libsamplemacros.h"
+
+class LIBSAMPLE_API Rect
+{
+public:
+ Rect()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ Rect(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ ~Rect() {}
+ inline int left() const { return m_left; }
+ inline int top() const { return m_top; }
+ inline int right() const { return m_right; }
+ inline int bottom() const { return m_bottom; }
+private:
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+};
+
+class LIBSAMPLE_API RectF
+{
+public:
+ RectF()
+ {
+ m_left = m_top = 0;
+ m_right = m_bottom = -1;
+ }
+ RectF(int left, int top, int right, int bottom)
+ : m_left(left), m_top(top), m_right(right), m_bottom(bottom) { }
+ RectF(const Rect& other)
+ {
+ m_left = other.left();
+ m_top = other.top();
+ m_right = other.right();
+ m_bottom = other.bottom();
+ }
+ ~RectF() {}
+ inline double left() const { return m_left; }
+ inline double top() const { return m_top; }
+ inline double right() const { return m_right; }
+ inline double bottom() const { return m_bottom; }
+private:
+ double m_left;
+ double m_top;
+ double m_right;
+ double m_bottom;
+};
+
+#endif // RECT_H
+