<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The best I've come up with is to verify that a nofeatureclick event occurs in the test event, which would indicate something is off with the pixel I'm sending. <div><br></div><div>However, I've used pagePosition to compensate for clicking in the correct location on the map. But it's only a difference of 8 pixels in either direction. And the circles have a radius of 30 pixels, so I don't think that would matter anyway. </div><div><br></div><div>Again, everything works if I just run featureclick.html, but not when I run the test. <br><div><br></div><div><a href="https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html">https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html</a><br><div><br></div><div>-Mike</div><div><br><div><div>On May 23, 2013, at 6:31 PM, Andreas Hocevar <<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">But the real problem is that the clientX and clientY in your mock events is relative to the map viewport, but should be relative to the browser viewport. You'll need to use OpenLayers.Util.pagePosition to get the position of the map's viewportDiv and add that to the  pixel coordinate you are currently using.<div>
<br></div><div style="">Andreas.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 5:20 PM, Andreas Hocevar <span dir="ltr"><<a href="mailto:ahocevar@opengeo.org" target="_blank">ahocevar@opengeo.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Right now you are calling logEvent() once, and you're doing so when<br>
you define the listener:<br>
<br>
    map.events.on({featureclick: logEvent()});<br>
<br>
Instead, this should read<br>
<br>
    map.events.on({featureclick: logEvent});<br>
<br>
Andreas.<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, May 23, 2013 at 4:30 PM, Michael Ryan <<a href="mailto:mr@mry4n.net">mr@mry4n.net</a>> wrote:<br>
> I checked that out, but that didn't seem to be it. I noticed in<br>
> buttonclick.html that it just uses onload=init() in the body tag and doesn't<br>
> call init() in any of the test functions.<br>
><br>
> However, it seems ilke I have to add the featureclick event and assign it a<br>
> function with parantheses, whereas running it in the html requires no<br>
> parentheses.<br>
><br>
> So the test function now looks like this:<br>
><br>
> function test_onClick23(t) {<br>
> t.plan(1);<br>
> logevt = [];<br>
> map.events.on({featureclick: logEvent()});<br>
> events = map.events;<br>
> lonlat = new OpenLayers.LonLat(0,0);<br>
> pixel = map.getPixelFromLonLat(lonlat);<br>
> trigger('mousedown', pixel);<br>
> trigger('mouseup', pixel);<br>
> t.eq(logevt.length, 2, "testing log length");<br>
> t.wait_result( 3 );<br>
> }<br>
><br>
> and the logEvent function is:<br>
><br>
> function logEvent(e) {<br>
><br>
> //alert("Does this happen?");<br>
> logevt.push(e);<br>
> }<br>
><br>
> <a href="https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html" target="_blank">https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html</a><br>
><br>
> The problem is that no matter how many features I add, the logevt array is<br>
> length 1.<br>
><br>
> I tried using the t.wait_result() function, taking a wild stab that since a<br>
> featureclick event gets fired for each feature that maybe there's some<br>
> timing issue that gets taken care of when you view featureclick.html but<br>
> needs to be accounted for in testing. Unfortunately, t.wait_result() didn't<br>
> change anything.<br>
><br>
> -Mike<br>
><br>
> On May 23, 2013, at 3:26 PM, Andreas Hocevar <<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>> wrote:<br>
><br>
> I think the problem is that your init() function won't be called when the<br>
> page is loaded by the test runner. So you'll have to call init() from the<br>
> test function (test_onClick12 in the current code).<br>
><br>
> Andreas.<br>
><br>
><br>
> On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <<a href="mailto:mr@mry4n.net">mr@mry4n.net</a>> wrote:<br>
>><br>
>> Thanks for all the help, Andreas.<br>
>><br>
>> I'm pretty sure I can figure the contrib stuff out.<br>
>><br>
>> At the moment, I'm hitting a wall with why a very simple test works if I<br>
>> just run the featureclick.html page, but not when I run the test function:<br>
>><br>
>><br>
>> <a href="https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html" target="_blank">https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html</a><br>
>><br>
>> When I run the html page the logevt array has length 2. In the test, it's<br>
>> length 0. Yet I'm running the exact same code.<br>
>><br>
>> I know this is taking a while and I may be missing the 2.13 deadline, but<br>
>> I'll keep plugging away at this til I get it right.<br>
>><br>
>> -Mike<br>
>><br>
>> On May 22, 2013, at 10:02 PM, Andreas Hocevar <<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>><br>
>> wrote:<br>
>><br>
>> Hey Michael,<br>
>><br>
>> you should find all information on how to submit code here:<br>
>> <a href="http://trac.osgeo.org/openlayers/wiki/HowToContribute" target="_blank">http://trac.osgeo.org/openlayers/wiki/HowToContribute</a>. You will want to<br>
>> create a pull request, as explained here:<br>
>> <a href="http://trac.osgeo.org/openlayers/wiki/CreatingPatches" target="_blank">http://trac.osgeo.org/openlayers/wiki/CreatingPatches</a>.<br>
>><br>
>> I hope this helps.<br>
>><br>
>> Andreas.<br>
>><br>
>><br>
>> On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <<a href="mailto:mr@mry4n.net">mr@mry4n.net</a>> wrote:<br>
>>><br>
>>> Thank you Andreas for clearing up that I should assign events like so:<br>
>>><br>
>>> events = map.events<br>
>>><br>
>>> The other part of this is that you have specify that the event you are<br>
>>> triggering is a left-click.<br>
>>><br>
>>> By tracing the code you see that you need to set the "which" attribute to<br>
>>> 1 in the object passed to triggerEvent(), otherwise onClick in<br>
>>> featureclick.js ignores the event.<br>
>>><br>
>>> So, this is what my code should have looked like:<br>
>>><br>
>>> events = map.events;<br>
>>> events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which:<br>
>>> 1}, map);<br>
>>> events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1},<br>
>>> map);<br>
>>><br>
>>> I'm assuming I can get tests written today. Although, I'm not exactly<br>
>>> clear how to submit them. If anyone wants to clue me in to that procedure<br>
>>> I'd appreciate it.<br>
>>><br>
>>> -Mike<br>
>>><br>
>>> On May 21, 2013, at 5:21 PM, Michael Ryan <<a href="mailto:mr@mry4n.net">mr@mry4n.net</a>> wrote:<br>
>>><br>
>>> While I've understood I need to use trigger() somehow, I have been<br>
>>> unsuccessful in implementing it.<br>
>>><br>
>>> I was using test for buttonclick as a reference:<br>
>>> <a href="https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html" target="_blank">https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html</a><br>
>>><br>
>>> I would have assumed that within the context of the featurclick example<br>
>>> <a href="https://github.com/openlayers/openlayers/pull/174/files" target="_blank">https://github.com/openlayers/openlayers/pull/174/files</a><br>
>>><br>
>>> I could have used something like<br>
>>><br>
>>> events = OpenLayers.Events(map, document.getElementById("map"));<br>
>>> events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)},<br>
>>> map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)},<br>
>>> map);<br>
>>><br>
>>> But, apparently, that's wrong.<br>
>>><br>
>>> Am I trying to do something that isn't possible? I'm assuming I'm just<br>
>>> implementing it wrong. Any thoughts?<br>
>>><br>
>>> -Mike<br>
>>><br>
>>> On May 20, 2013, at 5:04 PM, Michael Ryan <<a href="mailto:mr@mry4n.net">mr@mry4n.net</a>> wrote:<br>
>>><br>
>>> I'll answer my question about triggering a buttonclick by saying, it<br>
>>> looks like you use trigger() which takes coordinates as an argument as in<br>
>>> this test:<br>
>>> <a href="https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html" target="_blank">https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html</a><br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Dev mailing list<br>
>>> <a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
>>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
>>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Andreas Hocevar<br>
>> OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
>> Expert service straight from the developers.<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Dev mailing list<br>
>> <a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Andreas Hocevar<br>
> OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
> Expert service straight from the developers.<br>
><br>
><br>
<br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Andreas Hocevar<br>OpenGeo - <a href="http://opengeo.org/">http://opengeo.org/</a><br>Expert service straight from the developers.<br>
</div>
</blockquote></div><br></div></div></div></body></html>