[graphic-forms-cvs] r394 - trunk/src/tests/uitoolkit

junrue at common-lisp.net junrue at common-lisp.net
Mon Nov 13 23:23:40 UTC 2006


Author: junrue
Date: Mon Nov 13 18:23:39 2006
New Revision: 394

Modified:
   trunk/src/tests/uitoolkit/border-layout-unit-tests.lisp
   trunk/src/tests/uitoolkit/flow-layout-unit-tests.lisp
   trunk/src/tests/uitoolkit/test-utils.lisp
Log:
implemented define-layout-test convenience macro

Modified: trunk/src/tests/uitoolkit/border-layout-unit-tests.lisp
==============================================================================
--- trunk/src/tests/uitoolkit/border-layout-unit-tests.lisp	(original)
+++ trunk/src/tests/uitoolkit/border-layout-unit-tests.lisp	Mon Nov 13 18:23:39 2006
@@ -39,43 +39,26 @@
                                 (make-instance 'mock-widget :min-size *child-size-2*)
                                 (make-instance 'mock-widget :min-size *child-size-3*)))
 
-(define-test border-layout-test1
-  ;; regions: all
-  ;; spacing: 0
-  ;; margins: 0
-  ;;
-  (let* ((layout (make-border-layout *all-border-kids*))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 45 80 5) (60 5 20 40) (0 5 20 40) (0 0 80 5) (20 5 40 40))))
-    (assert-equal 80 (gfs:size-width size))
-    (assert-equal 50 (gfs:size-height size))
-    (validate-rects data expected-rects)))
+(defvar *outer-border-kids* (list (make-instance 'mock-widget :min-size *child-size-1*)
+                                  (make-instance 'mock-widget :min-size *child-size-2*)
+                                  (make-instance 'mock-widget :min-size *child-size-1*)
+                                  (make-instance 'mock-widget :min-size *child-size-2*)
+                                  nil))
 
-(define-test border-layout-test2
-  ;; regions: all but center
-  ;; spacing: 0
-  ;; margins: 0
-  ;;
-  (let* ((kids (append (butlast *all-border-kids*) '(nil)))
-         (layout (make-border-layout kids))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 15 40 5) (20 5 20 10) (0 5 20 10) (0 0 40 5))))
-    (assert-equal 40 (gfs:size-width size))
-    (assert-equal 20 (gfs:size-height size))
-    (validate-rects data expected-rects)))
+(defvar *center-border-kid* (list nil nil nil nil
+                                  (make-instance 'mock-widget :min-size *child-size-3*)))
 
-(define-test border-layout-test3
-  ;; regions: center only
-  ;; spacing: 0
-  ;; margins: 0
-  ;;
-  (let* ((kids (append '(nil nil nil nil) (last *all-border-kids*)))
-         (layout (make-border-layout kids))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 40 40))))
-    (assert-equal 40 (gfs:size-width size))
-    (assert-equal 40 (gfs:size-height size))
-    (validate-rects data expected-rects)))
+(define-layout-test border-layout-test1
+                    -1 -1 80 50
+                    '((0 45 80 5) (60 5 20 40) (0 5 20 40) (0 0 80 5) (20 5 40 40))
+                    #'make-border-layout *all-border-kids*)
+
+(define-layout-test border-layout-test2
+                    -1 -1 40 20
+                    '((0 15 40 5) (20 5 20 10) (0 5 20 10) (0 0 40 5))
+                    #'make-border-layout *outer-border-kids*)
+
+(define-layout-test border-layout-test3
+                    -1 -1 40 40
+                    '((0 0 40 40))
+                    #'make-border-layout *center-border-kid*)

Modified: trunk/src/tests/uitoolkit/flow-layout-unit-tests.lisp
==============================================================================
--- trunk/src/tests/uitoolkit/flow-layout-unit-tests.lisp	(original)
+++ trunk/src/tests/uitoolkit/flow-layout-unit-tests.lisp	Mon Nov 13 18:23:39 2006
@@ -40,222 +40,72 @@
                                 (make-instance 'mock-widget :min-size *child-size-1*)
                                 (make-instance 'mock-widget :min-size *child-size-2*)))
 
-(define-test flow-layout-test1
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal)))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 20 10) (20 0 20 10) (40 0 20 10))))
-    (assert-equal 60 (gfs:size-width size))
-    (assert-equal 10 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test2
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical)))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 20 10) (0 10 20 10) (0 20 20 10))))
-    (assert-equal 20 (gfs:size-width size))
-    (assert-equal 30 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test3
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: restricted width, unrestricted height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal :wrap)))
-         (data (gfw::compute-layout layout *mock-container* 45 -1))
-         (expected-rects '((0 0 20 10) (20 0 20 10) (0 10 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test4
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width, restricted height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical :wrap)))
-         (data (gfw::compute-layout layout *mock-container* -1 25))
-         (expected-rects '((0 0 20 10) (0 10 20 10) (20 0 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test5
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: restricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal :wrap)))
-         (data (gfw::compute-layout layout *mock-container* 45 18))
-         (expected-rects '((0 0 20 10) (20 0 20 10) (0 10 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test6
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: restricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical :wrap)))
-         (data (gfw::compute-layout layout *mock-container* 30 25))
-         (expected-rects '((0 0 20 10) (0 10 20 10) (20 0 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test7
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 4
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal) 4))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 20 10) (24 0 20 10) (48 0 20 10))))
-    (assert-equal 68 (gfs:size-width size))
-    (assert-equal 10 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test8
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 4
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical) 4))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 20 10) (0 14 20 10) (0 28 20 10))))
-    (assert-equal 20 (gfs:size-width size))
-    (assert-equal 38 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test9
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 4
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: restricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal :wrap) 4))
-         (data (gfw::compute-layout layout *mock-container* 45 18))
-         (expected-rects '((0 0 20 10) (24 0 20 10) (0 14 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test10
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: enabled
-  ;; spacing: 4
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: restricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical :wrap) 4))
-         (data (gfw::compute-layout layout *mock-container* 30 25))
-         (expected-rects '((0 0 20 10) (0 14 20 10) (24 0 20 10))))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test11
-  ;; orient: horizontal
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 3, top-margin: 3, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:horizontal) 0 3 3))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((3 3 20 10) (23 3 20 10) (43 3 20 10))))
-    (assert-equal 63 (gfs:size-width size))
-    (assert-equal 13 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test12
-  ;; orient: vertical
-  ;; normalize: disabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 3, bottom-margin: 3
-  ;; container: unrestricted width and height
-  ;; kids: uniform
-  ;;
-  (let* ((layout (make-flow-layout *flow-uniform-kids* '(:vertical) 0 0 0 3 3))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 20 10) (0 10 20 10) (0 20 20 10))))
-    (assert-equal 23 (gfs:size-width size))
-    (assert-equal 33 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test13
-  ;; orient: horizontal
-  ;; normalize: enabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: mixed
-  ;;
-  (let* ((layout (make-flow-layout *flow-mixed-kids* '(:horizontal :normalize)))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 25 10) (25 0 25 10) (50 0 25 10))))
-    (assert-equal 75 (gfs:size-width size))
-    (assert-equal 10 (gfs:size-height size))
-    (validate-rects data expected-rects)))
-
-(define-test flow-layout-test14
-  ;; orient: vertical
-  ;; normalize: enabled
-  ;; wrap: disabled
-  ;; spacing: 0
-  ;; left-margin: 0, top-margin: 0, right-margin: 0, bottom-margin: 0
-  ;; container: unrestricted width and height
-  ;; kids: mixed
-  ;;
-  (let* ((layout (make-flow-layout *flow-mixed-kids* '(:vertical :normalize)))
-         (size (gfw::compute-size layout *mock-container* -1 -1))
-         (data (gfw::compute-layout layout *mock-container* -1 -1))
-         (expected-rects '((0 0 25 10) (0 10 25 10) (0 20 25 10))))
-    (assert-equal 25 (gfs:size-width size))
-    (assert-equal 30 (gfs:size-height size))
-    (validate-rects data expected-rects)))
+(define-layout-test flow-layout-test1
+                    -1 -1 60 10
+                    '((0 0 20 10) (20 0 20 10) (40 0 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal))
+
+(define-layout-test flow-layout-test2
+                    -1 -1 20 30
+                    '((0 0 20 10) (0 10 20 10) (0 20 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical))
+
+(define-layout-test flow-layout-test3
+                    45 -1 40 20
+                    '((0 0 20 10) (20 0 20 10) (0 10 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal :wrap))
+
+(define-layout-test flow-layout-test4
+                    -1 25 20 20
+                    '((0 0 20 10) (0 10 20 10) (20 0 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical :wrap))
+
+(define-layout-test flow-layout-test5
+                    45 18 40 20
+                    '((0 0 20 10) (20 0 20 10) (0 10 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal :wrap))
+
+(define-layout-test flow-layout-test6
+                    30 25 40 20
+                    '((0 0 20 10) (0 10 20 10) (20 0 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical :wrap))
+
+(define-layout-test flow-layout-test7
+                    -1 -1 68 10
+                    '((0 0 20 10) (24 0 20 10) (48 0 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal) 4)
+
+(define-layout-test flow-layout-test8
+                    -1 -1 20 38
+                    '((0 0 20 10) (0 14 20 10) (0 28 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical) 4)
+
+(define-layout-test flow-layout-test9
+                    45 18 0 0
+                    '((0 0 20 10) (24 0 20 10) (0 14 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal :wrap) 4)
+
+(define-layout-test flow-layout-test10
+                    30 25 0 0
+                    '((0 0 20 10) (0 14 20 10) (24 0 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical :wrap) 4)
+
+(define-layout-test flow-layout-test11
+                    -1 -1 63 13
+                    '((3 3 20 10) (23 3 20 10) (43 3 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:horizontal) 0 3 3)
+
+(define-layout-test flow-layout-test12
+                    -1 -1 23 33
+                    '((0 0 20 10) (0 10 20 10) (0 20 20 10))
+                    #'make-flow-layout *flow-uniform-kids* '(:vertical) 0 0 0 3 3)
+
+(define-layout-test flow-layout-test13
+                    -1 -1 75 10
+                    '((0 0 25 10) (25 0 25 10) (50 0 25 10))
+                    #'make-flow-layout *flow-mixed-kids* '(:horizontal :normalize))
+
+(define-layout-test flow-layout-test14
+                    -1 -1 25 30
+                    '((0 0 25 10) (0 10 25 10) (0 20 25 10))
+                    #'make-flow-layout *flow-mixed-kids* '(:vertical :normalize))

Modified: trunk/src/tests/uitoolkit/test-utils.lisp
==============================================================================
--- trunk/src/tests/uitoolkit/test-utils.lisp	(original)
+++ trunk/src/tests/uitoolkit/test-utils.lisp	Mon Nov 13 18:23:39 2006
@@ -95,3 +95,17 @@
                 (assert-equal (fourth expected) (gfs:size-height sz-a))))
           expected-rects
           actual-rects)))
+
+(defmacro define-layout-test (name width-hint height-hint
+                              expected-width expected-height expected-rects
+                              factory &rest factory-args)
+  (let ((layout (gensym))
+        (size (gensym))
+        (data (gensym)))
+   `(define-test ,name
+      (let* ((,layout (apply ,factory (list , at factory-args)))
+             (,size (gfw::compute-size ,layout *mock-container* ,width-hint ,height-hint))
+             (,data (gfw::compute-layout ,layout *mock-container* ,width-hint ,height-hint)))
+        (assert-equal ,expected-width (gfs::size-width ,size))
+        (assert-equal ,expected-height (gfs::size-height ,size))
+        (validate-rects ,data ,expected-rects)))))



More information about the Graphic-forms-cvs mailing list