Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi identify #1338

Merged
merged 2 commits into from
Dec 12, 2016
Merged

Multi identify #1338

merged 2 commits into from
Dec 12, 2016

Conversation

manisandro
Copy link
Contributor

Adds a multiSelection property to the Identify component which allows multiple identify requests to be captured without purging the results if the ctrl modifier is pressed when clicking.

Note: I've been unsuccessful in finding any way to simulate a click in openlayers to implement the 'click' test below... Any ideas how this can be done? The way ol upstream does it[1] in the test suite relies on many private methods...

+    it('check if the handler for "click" event is called', (done) => {
+        const testHandlers = {
+            handler: () => {}
+        };
+        var spy = expect.spyOn(testHandlers, 'handler');
+
+        const map = ReactDOM.render(
+            <OpenlayersMap
+                center={{y: 43.9, x: 10.3}}
+                zoom={11}
+                onClick={testHandlers.handler}
+            />
+        , document.getElementById("map"));
+
+        const olMap = map.map;
+        const mapDiv = olMap.getViewport();
+
+        let downEvent = document.createEvent('MouseEvents');
+        downEvent.initEvent ("mousedown", true, true);
+        mapDiv.dispatchEvent(downEvent);
+        let upEvent = document.createEvent('MouseEvents');
+        upEvent.initEvent ("mouseup", true, true);
+        mapDiv.dispatchEvent(upEvent);
+        let clickEvent = document.createEvent('MouseEvents');
+        clickEvent.initEvent ("click", true, true);
+        mapDiv.dispatchEvent(clickEvent);
+
+//         mapDiv.click();
+        setTimeout(() => {
+          try {
+            expect(spy.calls.length).toEqual(1);
+            expect(spy.calls[0].arguments.length).toEqual(1);
+            expect(spy.calls[0].arguments[0].pixel).toExist();
+            expect(spy.calls[0].arguments[0].latlng).toExist();
+            expect(spy.calls[0].arguments[0].modifiers).toExist();
+            expect(spy.calls[0].arguments[0].modifiers.altKey).toEqual(false);
+            expect(spy.calls[0].arguments[0].modifiers.ctrlKey).toEqual(false);
+            expect(spy.calls[0].arguments[0].modifiers.shiftKey).toEqual(false);
+          } catch(e) {
+            return done(e);
+          }
+            done();
+        }, 600);
+    });

[1] https://github.com/openlayers/ol3/blob/master/test/spec/ol/interaction/modify.test.js#L80

@simboss simboss added the ready label Dec 7, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 80.281% when pulling 7c3a0c3 on sourcepole:multi_identify into bdeb615 on geosolutions-it:master.

@mbarto mbarto merged commit 2f0b144 into geosolutions-it:master Dec 12, 2016
@mbarto mbarto removed the ready label Dec 12, 2016
@manisandro manisandro deleted the multi_identify branch December 12, 2016 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants