initial import
tests
Thu Jul 2 19:34:07 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* initial import
diff -rN -u old-commonqt/tests/test.lisp new-commonqt/tests/test.lisp
--- old-commonqt/tests/test.lisp 1970-01-01 01:00:00.000000000 +0100
+++ new-commonqt/tests/test.lisp 2014-10-30 07:09:43.000000000 +0100
@@ -0,0 +1,92 @@
+(eval-when (:compile-toplevel :load-toplevel)
+ (mb:load :FiveAM))
+
+(in-package :cl-smoke.commonqt)
+
+(5am:def-suite :cl-smoke.commonqt-suite)
+(5am:in-suite :cl-smoke.commonqt-suite)
+
+(5am:test static-call
+ (5am:is (string= (cl-smoke.qt:q-version)
+ (#_qVersion "GlobalSpace"))))
+
+(5am:test enum
+ (5am:is (enum= cl-smoke.qt:+blue+
+ (#_blue "Qt"))))
+
+(5am:test new
+ (5am:is (cxx:= (make-instance 'cl-smoke.qt:byte-array :args '("foobar"))
+ (#_new QByteArray "foobar"))))
+
+(5am:test call
+ (let ((byte-array (make-instance 'cl-smoke.qt:byte-array :args '("foobar"))))
+ (5am:is (string= (cxx:data byte-array)
+ (#_data byte-array)))))
+
+(defclass button ()
+ ((called :accessor button-meta-object-called :initform nil))
+ (:metaclass qt-class)
+ (:qt-superclass "QPushButton")
+ (:override ("metaObject" meta-object)))
+
+(defmethod initialize-instance :after ((instance button) &rest initargs)
+ (declare (ignore initargs))
+ (new instance "foobar"))
+
+(defmethod meta-object ((this button))
+ (setf (button-meta-object-called this) t)
+ (call-next-qmethod))
+
+(5am:test subclassing
+ (cl-smoke.qt:with-app ()
+ (let ((button (make-instance 'button)))
+ (5am:is (string= ""
+ (#_objectName button)))
+ (5am:is (string= "foobar"
+ (#_text button))))))
+
+(5am:test overriding
+ (cl-smoke.qt:with-app ()
+ (let ((button (make-instance 'button)))
+ (5am:is (eql nil (button-meta-object-called button)))
+ (#_metaObject button)
+ (5am:is (eql t (button-meta-object-called button))))))
+
+(defclass mumble ()
+ ((called :accessor mumble-called :initform nil))
+ (:metaclass qt-class)
+ (:qt-superclass "QObject")
+ (:slots ("listen(int)" (lambda (this &optional value)
+ (5am:is (= 37 value))
+ (setf (mumble-called this) t))))
+ (:signals ("say(int)")))
+
+(defmethod initialize-instance :after ((instance mumble) &rest initargs)
+ (declare (ignore initargs))
+ (new instance))
+
+(5am:test signal-slot
+ (let ((mumble (make-instance 'mumble)))
+ (5am:is (eql t
+ (#_connect "QObject"
+ mumble (qt:qsignal "say(int)")
+ mumble (qt:qslot "listen(int)"))))
+ (5am:is (eql nil (mumble-called mumble)))
+ (emit-signal mumble "say(int)" 37)
+ (5am:is (eql t (mumble-called mumble)))
+
+ (5am:is (string= "QObject"
+ (#_className (#_superClass (#_metaObject mumble)))))))
+
+(5am:test make-qapplication
+ (let ((application (make-qapplication)))
+ (5am:is (eql (#_instance "QCoreApplication")
+ application))
+ (5am:is (eql t (typep application 'cl-smoke.qt:application)))
+ (smoke:delete-object application)))
+
+(eval-when (:load-toplevel)
+ (let ((results (5am:run :cl-smoke.commonqt-suite)))
+ (5am:explain! results)
+ (unless (5am:results-status results)
+ (error "Testsuite :qt.suite failed."))))