Skip to content
Newer
Older
100644 33 lines (27 sloc) 1.26 KB
3400137 @daveray Implemented timer and a somewhat crappy analog clock example.
authored
1 ; Copyright (c) Dave Ray, 2011. All rights reserved.
2
3 ; The use and distribution terms for this software are covered by the
4 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
a1d2559 @daveray whitespace
authored
5 ; which can be found in the file epl-v10.html at the root of this
3400137 @daveray Implemented timer and a somewhat crappy analog clock example.
authored
6 ; distribution.
7 ; By using this software in any fashion, you are agreeing to be bound by
8 ; the terms of this license.
9 ; You must not remove this notice, or any other, from this software.
10
11 (ns seesaw.test.timer
12 (:use seesaw.timer)
13 (:use [lazytest.describe :only (describe it testing)]
14 [lazytest.expect :only (expect)])
15 (:import [javax.swing Action]))
16
17 (describe timer
18 (it "Creates a timer for a handler function and calls it"
19 (let [called (atom nil)
20 t (timer #(inc (reset! called %)) :start? false :initial-value 99)]
21 (.actionPerformed (first (.getActionListeners t)) nil)
22 (expect (= 99 @called))
23 (.actionPerformed (first (.getActionListeners t)) nil)
24 (expect (= 100 @called))))
25
26 (it "Sets timer properties"
27 (let [t (timer identity :start? false :initial-delay 123 :delay 456 :repeats? false)]
28 (expect (= 123 (.getInitialDelay t)))
29 (expect (= 456 (.getDelay t)))
30 (expect (not (.isRunning t)))
31 (expect (not (.isRepeats t))))))
32
Something went wrong with that request. Please try again.