summaryrefslogtreecommitdiffstats
path: root/qtsharp/src/tests/lookuptest.cs
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtsharp/src/tests/lookuptest.cs
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtsharp/src/tests/lookuptest.cs')
-rw-r--r--qtsharp/src/tests/lookuptest.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/qtsharp/src/tests/lookuptest.cs b/qtsharp/src/tests/lookuptest.cs
new file mode 100644
index 00000000..9882678f
--- /dev/null
+++ b/qtsharp/src/tests/lookuptest.cs
@@ -0,0 +1,50 @@
+// Demonstrates that auto-boxing of foreign C++ objects works.
+// Set QTCSHARP_DEBUG to true in your environment to see this work.
+//
+// TODO
+// o Turn this into an nunit test.
+// o Mono won't let this test call LookupObject because
+// it is marked 'internal', even though they're both
+// in the same namespace. Mono bug?
+
+namespace Qt {
+
+ using Qt;
+ using System;
+
+ public class LookupTest : QVBox, IDisposable {
+
+ public LookupTest() : base (null)
+ {
+ QPushButton button = new QPushButton ("Quit", this);
+ QPushButton button2 = (QPushButton)QtSupport.LookupObject (button.Ptr); // Lookup a child object that exists in C#
+
+ if (button.GetHashCode () != button2.GetHashCode ())
+ Console.WriteLine ("ERROR: Hash codes differ for button and button2!");
+
+ QSize size = button2.SizeHint (); // Wrap a non-C# object. Lookup is called from the C# sizeHint method.
+ QSize size2 = (QSize)QtSupport.LookupObject (size.Ptr);
+
+ if (size.GetHashCode () != size2.GetHashCode ())
+ Console.WriteLine ("ERROR: Hash codes differ for size and size2!");
+
+ Connect (button, SIGNAL ("clicked()"), QObject.qApp, SLOT ("Quit()"));
+ }
+
+ public static void Main (string[] args)
+ {
+ QApplication a = new QApplication (args);
+ LookupTest lt = new LookupTest ();
+ a.SetMainWidget (lt);
+ lt.Show ();
+
+ LookupTest lt2 = (LookupTest)QtSupport.LookupObject (lt.Ptr); // Lookup a root object that exists in C#
+
+ if (lt.GetHashCode () != lt2.GetHashCode ())
+ Console.WriteLine ("ERROR: Hash codes differ for lt and lt2!");
+
+ a.Exec ();
+ lt.Dispose ();
+ }
+ }
+}