(in-package :qt.tests) (5am:in-suite :qt.suite) (defclass click-test-widget (qt:push-button) () (:metaclass cxx:class)) (5am:test (click-test :depends-on with-app) "Test clicking a button." (qt:with-app () (let ((widget (make-instance 'click-test-widget)) (click-count 0)) (qt:connect (qt:get-signal widget "clicked()") #'(lambda () (5am:is (eq widget (qt:sender))) (incf click-count))) (cxx:set-text widget "Hello World") (5am:is (string= "Hello World" (cxx:text widget))) (5am:is (= 0 click-count)) (qt:test.mouse-click widget qt:+left-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 1 click-count)) (qt:test.mouse-click widget qt:+right-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 1 click-count))))) (5am:test (click-test-bool :depends-on click-test) "Test clicking a button (bool argument)." (qt:with-app () (let ((widget (make-instance 'click-test-widget)) (click-count 0)) (qt:connect (qt:get-signal widget "clicked(bool)") #'(lambda (checked) (5am:is (eql nil checked)) (incf click-count))) (5am:is (= 0 click-count)) (qt:test.mouse-click widget qt:+left-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 1 click-count)) (qt:test.mouse-click widget qt:+left-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 2 click-count))))) (5am:test (click-test-bool-this :depends-on click-test) "Test clicking a button (bool argument) for a function with this argument." (qt:with-app () (let ((widget (make-instance 'click-test-widget)) (click-count 0)) (qt:connect (qt:get-signal widget "clicked(bool)") (qt:get-slot widget #'(lambda (object checked) (5am:is (eq nil checked)) (5am:is (eq widget object)) (incf click-count)))) (5am:is (= 0 click-count)) (qt:test.mouse-click widget qt:+left-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 1 click-count)) (qt:test.mouse-click widget qt:+left-button+ 0 (make-instance 'qt:point) -1) (5am:is (= 2 click-count)))))