(in-package :qt.tests) (5am:in-suite :qt.suite) (5am:test property-list "Test properties" (5am:is (= 1 (length (qt:class-properties (find-class 'qt:object))))) (5am:is (= 1 (length (qt:properties (make-instance 'qt:object)))))) (5am:test (property :depends-on qstring) "Tests get and set property string" (let ((o (make-instance 'qt:object))) (5am:is (eql t (qt:property-p o "objectName"))) (5am:is (eql t (qt:property-p o :object-name))) (setf (qt:property o :object-name) "fooBar") (5am:is (string= (qt:property o :object-name) "fooBar")) (5am:is (string= (qt:property o "objectName") "fooBar")) (5am:is (string= (cxx:object-name o) "fooBar")) (5am:is (eql nil (qt:property-p o 'foo))) (setf (qt:property o 'foo) "bar") (5am:is (= 2 (length (qt:properties o)))) (5am:is (member 'foo (qt:properties o))) (5am:is (eq t (qt:property-p o 'foo))) (5am:is (string= (qt:property o 'foo) "bar")) (qt:remove-property o 'foo) (5am:is (eq nil (qt:property-p o 'foo))))) (5am:test property-int "Test get and set property integer" (let ((o (make-instance 'qt:object))) (5am:for-all ((integer (5am:gen-integer))) (setf (qt:property o 'foo-bar) integer) (5am:is (= integer (qt:property o 'foo-bar)))))) (5am:test attributes "Test C++ attribute access with slot-* functions." (let ((o (make-instance 'qt:object))) (5am:is (slot-boundp o :static-meta-object)) (5am:is (slot-boundp (find-class 'qt:object) :static-meta-object)) (5am:is (string= "QObject" (cxx:class-name (slot-value o :static-meta-object)))) (5am:is (string= "QObject" (cxx:class-name (slot-value (find-class 'qt:object) :static-meta-object)))) (5am:signals error (setf (slot-value o :static-meta-object) (cffi:null-pointer)))) (let ((data (make-instance 'qt:shared-data))) (5am:is (slot-boundp data :ref)) (5am:for-all ((value (5am:gen-integer :min -255 :max 255))) (setf (slot-value data :ref) value) (5am:is (cxx:= (slot-value data :ref) value)))))