| | 167 | |
|---|
| | 168 | function test_Control_DragFeature_up(t) { |
|---|
| | 169 | t.plan(7); |
|---|
| | 170 | var map = new OpenLayers.Map("map"); |
|---|
| | 171 | var layer = new OpenLayers.Layer.Vector(); |
|---|
| | 172 | map.addLayer(layer); |
|---|
| | 173 | var control = new OpenLayers.Control.DragFeature(layer); |
|---|
| | 174 | map.addControl(control); |
|---|
| | 175 | |
|---|
| | 176 | control.activate(); |
|---|
| | 177 | |
|---|
| | 178 | // simulate a mouseover on a feature |
|---|
| | 179 | layer.getFeatureFromEvent = function(evt) { |
|---|
| | 180 | return "foo"; |
|---|
| | 181 | } |
|---|
| | 182 | map.events.triggerEvent("mousemove", {type: "mousemove"}); |
|---|
| | 183 | t.eq(control.over, true, |
|---|
| | 184 | "mouseover on a feature sets the over property to true"); |
|---|
| | 185 | t.eq(control.map.div.style.cursor, "move", |
|---|
| | 186 | "mouseover on a feature sets the cursor to move"); |
|---|
| | 187 | t.eq(control.handlers.drag.active, true, |
|---|
| | 188 | "mouseover on a feature activates drag handler"); |
|---|
| | 189 | |
|---|
| | 190 | // simulate a mouse-up on the map, with the mouse still |
|---|
| | 191 | // over the dragged feature |
|---|
| | 192 | control.handlers.drag.started = true; |
|---|
| | 193 | map.events.triggerEvent("mouseup", {type: "mouseup"}); |
|---|
| | 194 | t.eq(control.map.div.style.cursor, "move", |
|---|
| | 195 | "mouseup while still over dragged feature does not reset cursor to default"); |
|---|
| | 196 | t.eq(control.handlers.drag.active, true, |
|---|
| | 197 | "mouseup while still over dragged feature does not deactivate drag handler"); |
|---|
| | 198 | |
|---|
| | 199 | // simulate a mouse-up on the map, with the mouse out of |
|---|
| | 200 | // the dragged feature |
|---|
| | 201 | control.handlers.drag.started = true; |
|---|
| | 202 | control.over = false; |
|---|
| | 203 | map.events.triggerEvent("mouseup", {type: "mouseup"}); |
|---|
| | 204 | t.eq(control.map.div.style.cursor, "default", |
|---|
| | 205 | "mouseup resets cursor to default"); |
|---|
| | 206 | t.eq(control.handlers.drag.active, false, |
|---|
| | 207 | "mouseup deactivates drag handler"); |
|---|
| | 208 | |
|---|
| | 209 | control.deactivate(); |
|---|
| | 210 | } |
|---|