/ src /
/src/properties.lisp
1 (in-package :qt.tests)
2
3 (5am:in-suite :qt.suite)
4
5 (5am:test property-list
6 "Test properties"
7 (5am:is (= 1 (length (qt:class-properties (find-class 'qt:object)))))
8 (5am:is (= 1 (length (qt:properties (make-instance 'qt:object))))))
9
10 (5am:test (property :depends-on qstring)
11 "Tests get and set property string"
12 (let ((o (make-instance 'qt:object)))
13 (5am:is (eql t (qt:property-p o "objectName")))
14 (5am:is (eql t (qt:property-p o :object-name)))
15
16 (setf (qt:property o :object-name) "fooBar")
17 (5am:is (string= (qt:property o :object-name) "fooBar"))
18 (5am:is (string= (qt:property o "objectName") "fooBar"))
19 (5am:is (string= (cxx:object-name o) "fooBar"))
20
21 (5am:is (eql nil (qt:property-p o 'foo)))
22 (setf (qt:property o 'foo) "bar")
23 (5am:is (= 2 (length (qt:properties o))))
24 (5am:is (member 'foo (qt:properties o)))
25 (5am:is (eq t (qt:property-p o 'foo)))
26 (5am:is (string= (qt:property o 'foo) "bar"))
27
28 (qt:remove-property o 'foo)
29 (5am:is (eq nil (qt:property-p o 'foo)))))
30
31
32 (5am:test property-int
33 "Test get and set property integer"
34 (let ((o (make-instance 'qt:object)))
35 (5am:for-all ((integer (5am:gen-integer)))
36 (setf (qt:property o 'foo-bar) integer)
37 (5am:is (= integer (qt:property o 'foo-bar))))))
38
39 (5am:test attributes
40 "Test C++ attribute access with slot-* functions."
41 (let ((o (make-instance 'qt:object)))
42 (5am:is (slot-boundp o :static-meta-object))
43 (5am:is (slot-boundp (find-class 'qt:object) :static-meta-object))
44 (5am:is (string= "QObject"
45 (cxx:class-name
46 (slot-value o :static-meta-object))))
47 (5am:is (string= "QObject"
48 (cxx:class-name
49 (slot-value (find-class 'qt:object)
50 :static-meta-object))))
51 (5am:signals error
52 (setf (slot-value o :static-meta-object)
53 (cffi:null-pointer))))
54 (let ((data (make-instance 'qt:shared-data)))
55 (5am:is (slot-boundp data :ref))
56 (5am:for-all ((value (5am:gen-integer :min -255 :max 255)))
57 (setf (slot-value data :ref) value)
58 (5am:is (cxx:= (slot-value data :ref) value)))))