Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (39 sloc) 1.699 kB
eec6d81 @daveray starting to work on mouse stuff. So far, just moving ideas over from …
authored
1 ; Copyright (c) Dave Ray, 2012. 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)
9623de6 @daveray Whitespace
authored
5 ; which can be found in the file epl-v10.html at the root of this
eec6d81 @daveray starting to work on mouse stuff. So far, just moving ideas over from …
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.mouse
12 (:require [seesaw.mouse :as mouse])
13 (:use [lazytest.describe :only (describe it testing)]
14 [lazytest.expect :only (expect)]))
15
16 (defn- fake-event [[x y] modex btn]
9623de6 @daveray Whitespace
authored
17 (java.awt.event.MouseEvent.
18 (javax.swing.JLabel.) ,
19 0, 0 , modex,
20 x, y, 1, false,
eec6d81 @daveray starting to work on mouse stuff. So far, just moving ideas over from …
authored
21 btn))
22
23 (describe mouse/location
24 (testing "with no arguments"
25 (it "returns the [x y] mouse location on the whole screen"
26 (let [[x y] (mouse/location)
27 p (.getLocation (java.awt.MouseInfo/getPointerInfo))]
28 (expect (= (.x p) x))
29 (expect (= (.y p) y)))))
30 (testing "with a MouseEvent argument"
31 (it "returns the [x y] of the event"
32 (let [e (fake-event [123 456] 0 0)]
33 (expect (= [123 456] (mouse/location e)))))))
34
35 (describe mouse/button-down?
36 (testing "with a MouseEvent"
37 (it "returns true if the button is down"
38 (let [e (fake-event [0 0] java.awt.event.InputEvent/BUTTON2_DOWN_MASK 0)]
39 (expect (mouse/button-down? e :center))))))
40
41 (describe mouse/button
42 (testing "with a MouseEvent"
43 (it "returns the button whose state changed"
44 (let [e (fake-event [0 0] 0 java.awt.event.MouseEvent/BUTTON3)]
45 (expect (= :right (mouse/button e)))))))
Something went wrong with that request. Please try again.