Testing

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Testing

m1k3ry4n
Hi,
I'd like to help get the following patch committed by doing testing on it. Can someone direct me to documentation on how to do this testing? I've found old info from trac.osgeo and info for OL3 on github. But I'm not sure what I'm supposed to do for OL 2.1x.
Thanks,
Mike

https://github.com/openlayers/openlayers/pull/174#ref-issue-6562621
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

Andreas Hocevar-2
Hi,

thanks for willing to help out! That pull request needs unit tests. To get started, look at the contents of the tests/ folder in the repository. The html files in there contain test cases. It should be rather self-explanatory how to write tests with TestAnotherWay (the test framework used), if you are familiar with the concept of unit tests.

Andreas.


On Fri, May 17, 2013 at 11:24 PM, Michael Ryan <[hidden email]> wrote:
Hi,
I'd like to help get the following patch committed by doing testing on it. Can someone direct me to documentation on how to do this testing? I've found old info from trac.osgeo and info for OL3 on github. But I'm not sure what I'm supposed to do for OL 2.1x.
Thanks,
Mike

https://github.com/openlayers/openlayers/pull/174#ref-issue-6562621

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
OK, I'm understanding TestAnotherWay and I'm coming up with tests. 

I was going to use a version of the feature-click example with four overlapping circles and then click all the possibilities (none, all four, just two, etc.). 

So, how do I simulate a button click in a specific location? I was looking at the test for buttonclick.html, but that  doesn't seem to be what I want. And I assume it isn't practical to use TestAnotherWay's record feature?

I'm continuing to work on this. If anyone can help me out, it would be appreciated. 

-m


On May 19, 2013, at 7:20 AM, Andreas Hocevar <[hidden email]> wrote:

Hi,

thanks for willing to help out! That pull request needs unit tests. To get started, look at the contents of the tests/ folder in the repository. The html files in there contain test cases. It should be rather self-explanatory how to write tests with TestAnotherWay (the test framework used), if you are familiar with the concept of unit tests.

Andreas.


On Fri, May 17, 2013 at 11:24 PM, Michael Ryan <[hidden email]> wrote:
Hi,
I'd like to help get the following patch committed by doing testing on it. Can someone direct me to documentation on how to do this testing? I've found old info from trac.osgeo and info for OL3 on github. But I'm not sure what I'm supposed to do for OL 2.1x.
Thanks,
Mike

https://github.com/openlayers/openlayers/pull/174#ref-issue-6562621

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
In reply to this post by Andreas Hocevar-2
I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
Thank you Andreas for clearing up that I should assign events like so:

events = map.events

The other part of this is that you have specify that the event you are triggering is a left-click.

By tracing the code you see that you need to set the "which" attribute to 1 in the object passed to triggerEvent(), otherwise onClick in featureclick.js ignores the event. 

So, this is what my code should have looked like:

events = map.events;
events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);
events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);

I'm assuming I can get tests written today. Although, I'm not exactly clear how to submit them. If anyone wants to clue me in to that procedure I'd appreciate it.

-Mike

On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:

While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html



_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

Andreas Hocevar-2
Hey Michael,

you should find all information on how to submit code here: http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to create a pull request, as explained here: http://trac.osgeo.org/openlayers/wiki/CreatingPatches.

I hope this helps.

Andreas.


On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
Thank you Andreas for clearing up that I should assign events like so:

events = map.events

The other part of this is that you have specify that the event you are triggering is a left-click.

By tracing the code you see that you need to set the "which" attribute to 1 in the object passed to triggerEvent(), otherwise onClick in featureclick.js ignores the event. 

So, this is what my code should have looked like:

events = map.events;
events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);
events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);

I'm assuming I can get tests written today. Although, I'm not exactly clear how to submit them. If anyone wants to clue me in to that procedure I'd appreciate it.

-Mike

On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:

While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html



_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
Thanks for all the help, Andreas.

I'm pretty sure I can figure the contrib stuff out. 

At the moment, I'm hitting a wall with why a very simple test works if I just run the featureclick.html page, but not when I run the test function:


When I run the html page the logevt array has length 2. In the test, it's length 0. Yet I'm running the exact same code.

I know this is taking a while and I may be missing the 2.13 deadline, but I'll keep plugging away at this til I get it right. 

-Mike

On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]> wrote:

Hey Michael,

you should find all information on how to submit code here: http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to create a pull request, as explained here: http://trac.osgeo.org/openlayers/wiki/CreatingPatches.

I hope this helps.

Andreas.


On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
Thank you Andreas for clearing up that I should assign events like so:

events = map.events

The other part of this is that you have specify that the event you are triggering is a left-click.

By tracing the code you see that you need to set the "which" attribute to 1 in the object passed to triggerEvent(), otherwise onClick in featureclick.js ignores the event. 

So, this is what my code should have looked like:

events = map.events;
events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);
events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);

I'm assuming I can get tests written today. Although, I'm not exactly clear how to submit them. If anyone wants to clue me in to that procedure I'd appreciate it.

-Mike

On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:

While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html



_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

Andreas Hocevar-2
I think the problem is that your init() function won't be called when the page is loaded by the test runner. So you'll have to call init() from the test function (test_onClick12 in the current code).

Andreas.


On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
Thanks for all the help, Andreas.

I'm pretty sure I can figure the contrib stuff out. 

At the moment, I'm hitting a wall with why a very simple test works if I just run the featureclick.html page, but not when I run the test function:


When I run the html page the logevt array has length 2. In the test, it's length 0. Yet I'm running the exact same code.

I know this is taking a while and I may be missing the 2.13 deadline, but I'll keep plugging away at this til I get it right. 

-Mike

On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]> wrote:

Hey Michael,

you should find all information on how to submit code here: http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to create a pull request, as explained here: http://trac.osgeo.org/openlayers/wiki/CreatingPatches.

I hope this helps.

Andreas.


On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
Thank you Andreas for clearing up that I should assign events like so:

events = map.events

The other part of this is that you have specify that the event you are triggering is a left-click.

By tracing the code you see that you need to set the "which" attribute to 1 in the object passed to triggerEvent(), otherwise onClick in featureclick.js ignores the event. 

So, this is what my code should have looked like:

events = map.events;
events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);
events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);

I'm assuming I can get tests written today. Although, I'm not exactly clear how to submit them. If anyone wants to clue me in to that procedure I'd appreciate it.

-Mike

On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:

While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html



_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
I checked that out, but that didn't seem to be it. I noticed in buttonclick.html that it just uses onload=init() in the body tag and doesn't call init() in any of the test functions.

However, it seems ilke I have to add the featureclick event and assign it a function with parantheses, whereas running it in the html requires no parentheses. 

So the test function now looks like this:

function test_onClick23(t) {
t.plan(1);
logevt = [];
map.events.on({featureclick: logEvent()});
events = map.events;
lonlat = new OpenLayers.LonLat(0,0);
pixel = map.getPixelFromLonLat(lonlat);
trigger('mousedown', pixel);
trigger('mouseup', pixel);
t.eq(logevt.length, 2, "testing log length");
t.wait_result( 3 );
}

and the logEvent function is:

function logEvent(e) {

//alert("Does this happen?");
logevt.push(e);
}


The problem is that no matter how many features I add, the logevt array is length 1.

I tried using the t.wait_result() function, taking a wild stab that since a featureclick event gets fired for each feature that maybe there's some timing issue that gets taken care of when you view featureclick.html but needs to be accounted for in testing. Unfortunately, t.wait_result() didn't change anything.

-Mike

On May 23, 2013, at 3:26 PM, Andreas Hocevar <[hidden email]> wrote:

I think the problem is that your init() function won't be called when the page is loaded by the test runner. So you'll have to call init() from the test function (test_onClick12 in the current code).

Andreas.


On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
Thanks for all the help, Andreas.

I'm pretty sure I can figure the contrib stuff out. 

At the moment, I'm hitting a wall with why a very simple test works if I just run the featureclick.html page, but not when I run the test function:


When I run the html page the logevt array has length 2. In the test, it's length 0. Yet I'm running the exact same code.

I know this is taking a while and I may be missing the 2.13 deadline, but I'll keep plugging away at this til I get it right. 

-Mike

On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]> wrote:

Hey Michael,

you should find all information on how to submit code here: http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to create a pull request, as explained here: http://trac.osgeo.org/openlayers/wiki/CreatingPatches.

I hope this helps.

Andreas.


On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
Thank you Andreas for clearing up that I should assign events like so:

events = map.events

The other part of this is that you have specify that the event you are triggering is a left-click.

By tracing the code you see that you need to set the "which" attribute to 1 in the object passed to triggerEvent(), otherwise onClick in featureclick.js ignores the event. 

So, this is what my code should have looked like:

events = map.events;
events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);
events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1}, map);

I'm assuming I can get tests written today. Although, I'm not exactly clear how to submit them. If anyone wants to clue me in to that procedure I'd appreciate it.

-Mike

On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:

While I've understood I need to use trigger() somehow, I have been unsuccessful in implementing it. 


I would have assumed that within the context of the featurclick example

I could have used something like 

events = OpenLayers.Events(map, document.getElementById("map"));
events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)}, map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)}, map);

But, apparently, that's wrong. 

Am I trying to do something that isn't possible? I'm assuming I'm just implementing it wrong. Any thoughts?

-Mike

On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:

I'll answer my question about triggering a buttonclick by saying, it looks like you use trigger() which takes coordinates as an argument as in this test:  https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html



_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev




--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

Andreas Hocevar-2
Right now you are calling logEvent() once, and you're doing so when
you define the listener:

    map.events.on({featureclick: logEvent()});

Instead, this should read

    map.events.on({featureclick: logEvent});

Andreas.

On Thu, May 23, 2013 at 4:30 PM, Michael Ryan <[hidden email]> wrote:

> I checked that out, but that didn't seem to be it. I noticed in
> buttonclick.html that it just uses onload=init() in the body tag and doesn't
> call init() in any of the test functions.
>
> However, it seems ilke I have to add the featureclick event and assign it a
> function with parantheses, whereas running it in the html requires no
> parentheses.
>
> So the test function now looks like this:
>
> function test_onClick23(t) {
> t.plan(1);
> logevt = [];
> map.events.on({featureclick: logEvent()});
> events = map.events;
> lonlat = new OpenLayers.LonLat(0,0);
> pixel = map.getPixelFromLonLat(lonlat);
> trigger('mousedown', pixel);
> trigger('mouseup', pixel);
> t.eq(logevt.length, 2, "testing log length");
> t.wait_result( 3 );
> }
>
> and the logEvent function is:
>
> function logEvent(e) {
>
> //alert("Does this happen?");
> logevt.push(e);
> }
>
> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>
> The problem is that no matter how many features I add, the logevt array is
> length 1.
>
> I tried using the t.wait_result() function, taking a wild stab that since a
> featureclick event gets fired for each feature that maybe there's some
> timing issue that gets taken care of when you view featureclick.html but
> needs to be accounted for in testing. Unfortunately, t.wait_result() didn't
> change anything.
>
> -Mike
>
> On May 23, 2013, at 3:26 PM, Andreas Hocevar <[hidden email]> wrote:
>
> I think the problem is that your init() function won't be called when the
> page is loaded by the test runner. So you'll have to call init() from the
> test function (test_onClick12 in the current code).
>
> Andreas.
>
>
> On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
>>
>> Thanks for all the help, Andreas.
>>
>> I'm pretty sure I can figure the contrib stuff out.
>>
>> At the moment, I'm hitting a wall with why a very simple test works if I
>> just run the featureclick.html page, but not when I run the test function:
>>
>>
>> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>>
>> When I run the html page the logevt array has length 2. In the test, it's
>> length 0. Yet I'm running the exact same code.
>>
>> I know this is taking a while and I may be missing the 2.13 deadline, but
>> I'll keep plugging away at this til I get it right.
>>
>> -Mike
>>
>> On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]>
>> wrote:
>>
>> Hey Michael,
>>
>> you should find all information on how to submit code here:
>> http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to
>> create a pull request, as explained here:
>> http://trac.osgeo.org/openlayers/wiki/CreatingPatches.
>>
>> I hope this helps.
>>
>> Andreas.
>>
>>
>> On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
>>>
>>> Thank you Andreas for clearing up that I should assign events like so:
>>>
>>> events = map.events
>>>
>>> The other part of this is that you have specify that the event you are
>>> triggering is a left-click.
>>>
>>> By tracing the code you see that you need to set the "which" attribute to
>>> 1 in the object passed to triggerEvent(), otherwise onClick in
>>> featureclick.js ignores the event.
>>>
>>> So, this is what my code should have looked like:
>>>
>>> events = map.events;
>>> events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which:
>>> 1}, map);
>>> events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1},
>>> map);
>>>
>>> I'm assuming I can get tests written today. Although, I'm not exactly
>>> clear how to submit them. If anyone wants to clue me in to that procedure
>>> I'd appreciate it.
>>>
>>> -Mike
>>>
>>> On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> While I've understood I need to use trigger() somehow, I have been
>>> unsuccessful in implementing it.
>>>
>>> I was using test for buttonclick as a reference:
>>> https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html
>>>
>>> I would have assumed that within the context of the featurclick example
>>> https://github.com/openlayers/openlayers/pull/174/files
>>>
>>> I could have used something like
>>>
>>> events = OpenLayers.Events(map, document.getElementById("map"));
>>> events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)},
>>> map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)},
>>> map);
>>>
>>> But, apparently, that's wrong.
>>>
>>> Am I trying to do something that isn't possible? I'm assuming I'm just
>>> implementing it wrong. Any thoughts?
>>>
>>> -Mike
>>>
>>> On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> I'll answer my question about triggering a buttonclick by saying, it
>>> looks like you use trigger() which takes coordinates as an argument as in
>>> this test:
>>> https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>>
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

Andreas Hocevar-2
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.

Andreas.


On Thu, May 23, 2013 at 5:20 PM, Andreas Hocevar <[hidden email]> wrote:
Right now you are calling logEvent() once, and you're doing so when
you define the listener:

    map.events.on({featureclick: logEvent()});

Instead, this should read

    map.events.on({featureclick: logEvent});

Andreas.

On Thu, May 23, 2013 at 4:30 PM, Michael Ryan <[hidden email]> wrote:
> I checked that out, but that didn't seem to be it. I noticed in
> buttonclick.html that it just uses onload=init() in the body tag and doesn't
> call init() in any of the test functions.
>
> However, it seems ilke I have to add the featureclick event and assign it a
> function with parantheses, whereas running it in the html requires no
> parentheses.
>
> So the test function now looks like this:
>
> function test_onClick23(t) {
> t.plan(1);
> logevt = [];
> map.events.on({featureclick: logEvent()});
> events = map.events;
> lonlat = new OpenLayers.LonLat(0,0);
> pixel = map.getPixelFromLonLat(lonlat);
> trigger('mousedown', pixel);
> trigger('mouseup', pixel);
> t.eq(logevt.length, 2, "testing log length");
> t.wait_result( 3 );
> }
>
> and the logEvent function is:
>
> function logEvent(e) {
>
> //alert("Does this happen?");
> logevt.push(e);
> }
>
> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>
> The problem is that no matter how many features I add, the logevt array is
> length 1.
>
> I tried using the t.wait_result() function, taking a wild stab that since a
> featureclick event gets fired for each feature that maybe there's some
> timing issue that gets taken care of when you view featureclick.html but
> needs to be accounted for in testing. Unfortunately, t.wait_result() didn't
> change anything.
>
> -Mike
>
> On May 23, 2013, at 3:26 PM, Andreas Hocevar <[hidden email]> wrote:
>
> I think the problem is that your init() function won't be called when the
> page is loaded by the test runner. So you'll have to call init() from the
> test function (test_onClick12 in the current code).
>
> Andreas.
>
>
> On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
>>
>> Thanks for all the help, Andreas.
>>
>> I'm pretty sure I can figure the contrib stuff out.
>>
>> At the moment, I'm hitting a wall with why a very simple test works if I
>> just run the featureclick.html page, but not when I run the test function:
>>
>>
>> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>>
>> When I run the html page the logevt array has length 2. In the test, it's
>> length 0. Yet I'm running the exact same code.
>>
>> I know this is taking a while and I may be missing the 2.13 deadline, but
>> I'll keep plugging away at this til I get it right.
>>
>> -Mike
>>
>> On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]>
>> wrote:
>>
>> Hey Michael,
>>
>> you should find all information on how to submit code here:
>> http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to
>> create a pull request, as explained here:
>> http://trac.osgeo.org/openlayers/wiki/CreatingPatches.
>>
>> I hope this helps.
>>
>> Andreas.
>>
>>
>> On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
>>>
>>> Thank you Andreas for clearing up that I should assign events like so:
>>>
>>> events = map.events
>>>
>>> The other part of this is that you have specify that the event you are
>>> triggering is a left-click.
>>>
>>> By tracing the code you see that you need to set the "which" attribute to
>>> 1 in the object passed to triggerEvent(), otherwise onClick in
>>> featureclick.js ignores the event.
>>>
>>> So, this is what my code should have looked like:
>>>
>>> events = map.events;
>>> events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which:
>>> 1}, map);
>>> events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1},
>>> map);
>>>
>>> I'm assuming I can get tests written today. Although, I'm not exactly
>>> clear how to submit them. If anyone wants to clue me in to that procedure
>>> I'd appreciate it.
>>>
>>> -Mike
>>>
>>> On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> While I've understood I need to use trigger() somehow, I have been
>>> unsuccessful in implementing it.
>>>
>>> I was using test for buttonclick as a reference:
>>> https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html
>>>
>>> I would have assumed that within the context of the featurclick example
>>> https://github.com/openlayers/openlayers/pull/174/files
>>>
>>> I could have used something like
>>>
>>> events = OpenLayers.Events(map, document.getElementById("map"));
>>> events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)},
>>> map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)},
>>> map);
>>>
>>> But, apparently, that's wrong.
>>>
>>> Am I trying to do something that isn't possible? I'm assuming I'm just
>>> implementing it wrong. Any thoughts?
>>>
>>> -Mike
>>>
>>> On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> I'll answer my question about triggering a buttonclick by saying, it
>>> looks like you use trigger() which takes coordinates as an argument as in
>>> this test:
>>> https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>>
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
Added pagePosition and set featureclick to logEvent in the test and get the same result where it works in the html page but not in the testing function:


-Mike

On May 23, 2013, at 6:31 PM, Andreas Hocevar <[hidden email]> wrote:

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.

Andreas.


On Thu, May 23, 2013 at 5:20 PM, Andreas Hocevar <[hidden email]> wrote:
Right now you are calling logEvent() once, and you're doing so when
you define the listener:

    map.events.on({featureclick: logEvent()});

Instead, this should read

    map.events.on({featureclick: logEvent});

Andreas.

On Thu, May 23, 2013 at 4:30 PM, Michael Ryan <[hidden email]> wrote:
> I checked that out, but that didn't seem to be it. I noticed in
> buttonclick.html that it just uses onload=init() in the body tag and doesn't
> call init() in any of the test functions.
>
> However, it seems ilke I have to add the featureclick event and assign it a
> function with parantheses, whereas running it in the html requires no
> parentheses.
>
> So the test function now looks like this:
>
> function test_onClick23(t) {
> t.plan(1);
> logevt = [];
> map.events.on({featureclick: logEvent()});
> events = map.events;
> lonlat = new OpenLayers.LonLat(0,0);
> pixel = map.getPixelFromLonLat(lonlat);
> trigger('mousedown', pixel);
> trigger('mouseup', pixel);
> t.eq(logevt.length, 2, "testing log length");
> t.wait_result( 3 );
> }
>
> and the logEvent function is:
>
> function logEvent(e) {
>
> //alert("Does this happen?");
> logevt.push(e);
> }
>
> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>
> The problem is that no matter how many features I add, the logevt array is
> length 1.
>
> I tried using the t.wait_result() function, taking a wild stab that since a
> featureclick event gets fired for each feature that maybe there's some
> timing issue that gets taken care of when you view featureclick.html but
> needs to be accounted for in testing. Unfortunately, t.wait_result() didn't
> change anything.
>
> -Mike
>
> On May 23, 2013, at 3:26 PM, Andreas Hocevar <[hidden email]> wrote:
>
> I think the problem is that your init() function won't be called when the
> page is loaded by the test runner. So you'll have to call init() from the
> test function (test_onClick12 in the current code).
>
> Andreas.
>
>
> On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
>>
>> Thanks for all the help, Andreas.
>>
>> I'm pretty sure I can figure the contrib stuff out.
>>
>> At the moment, I'm hitting a wall with why a very simple test works if I
>> just run the featureclick.html page, but not when I run the test function:
>>
>>
>> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>>
>> When I run the html page the logevt array has length 2. In the test, it's
>> length 0. Yet I'm running the exact same code.
>>
>> I know this is taking a while and I may be missing the 2.13 deadline, but
>> I'll keep plugging away at this til I get it right.
>>
>> -Mike
>>
>> On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]>
>> wrote:
>>
>> Hey Michael,
>>
>> you should find all information on how to submit code here:
>> http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to
>> create a pull request, as explained here:
>> http://trac.osgeo.org/openlayers/wiki/CreatingPatches.
>>
>> I hope this helps.
>>
>> Andreas.
>>
>>
>> On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
>>>
>>> Thank you Andreas for clearing up that I should assign events like so:
>>>
>>> events = map.events
>>>
>>> The other part of this is that you have specify that the event you are
>>> triggering is a left-click.
>>>
>>> By tracing the code you see that you need to set the "which" attribute to
>>> 1 in the object passed to triggerEvent(), otherwise onClick in
>>> featureclick.js ignores the event.
>>>
>>> So, this is what my code should have looked like:
>>>
>>> events = map.events;
>>> events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which:
>>> 1}, map);
>>> events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1},
>>> map);
>>>
>>> I'm assuming I can get tests written today. Although, I'm not exactly
>>> clear how to submit them. If anyone wants to clue me in to that procedure
>>> I'd appreciate it.
>>>
>>> -Mike
>>>
>>> On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> While I've understood I need to use trigger() somehow, I have been
>>> unsuccessful in implementing it.
>>>
>>> I was using test for buttonclick as a reference:
>>> https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html
>>>
>>> I would have assumed that within the context of the featurclick example
>>> https://github.com/openlayers/openlayers/pull/174/files
>>>
>>> I could have used something like
>>>
>>> events = OpenLayers.Events(map, document.getElementById("map"));
>>> events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)},
>>> map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)},
>>> map);
>>>
>>> But, apparently, that's wrong.
>>>
>>> Am I trying to do something that isn't possible? I'm assuming I'm just
>>> implementing it wrong. Any thoughts?
>>>
>>> -Mike
>>>
>>> On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> I'll answer my question about triggering a buttonclick by saying, it
>>> looks like you use trigger() which takes coordinates as an argument as in
>>> this test:
>>> https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>>
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Testing

m1k3ry4n
In reply to this post by Andreas Hocevar-2
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. 

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. 

Again, everything works if I just run featureclick.html, but not when I run the test. 

https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html

-Mike

On May 23, 2013, at 6:31 PM, Andreas Hocevar <[hidden email]> wrote:

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.

Andreas.


On Thu, May 23, 2013 at 5:20 PM, Andreas Hocevar <[hidden email]> wrote:
Right now you are calling logEvent() once, and you're doing so when
you define the listener:

    map.events.on({featureclick: logEvent()});

Instead, this should read

    map.events.on({featureclick: logEvent});

Andreas.

On Thu, May 23, 2013 at 4:30 PM, Michael Ryan <[hidden email]> wrote:
> I checked that out, but that didn't seem to be it. I noticed in
> buttonclick.html that it just uses onload=init() in the body tag and doesn't
> call init() in any of the test functions.
>
> However, it seems ilke I have to add the featureclick event and assign it a
> function with parantheses, whereas running it in the html requires no
> parentheses.
>
> So the test function now looks like this:
>
> function test_onClick23(t) {
> t.plan(1);
> logevt = [];
> map.events.on({featureclick: logEvent()});
> events = map.events;
> lonlat = new OpenLayers.LonLat(0,0);
> pixel = map.getPixelFromLonLat(lonlat);
> trigger('mousedown', pixel);
> trigger('mouseup', pixel);
> t.eq(logevt.length, 2, "testing log length");
> t.wait_result( 3 );
> }
>
> and the logEvent function is:
>
> function logEvent(e) {
>
> //alert("Does this happen?");
> logevt.push(e);
> }
>
> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>
> The problem is that no matter how many features I add, the logevt array is
> length 1.
>
> I tried using the t.wait_result() function, taking a wild stab that since a
> featureclick event gets fired for each feature that maybe there's some
> timing issue that gets taken care of when you view featureclick.html but
> needs to be accounted for in testing. Unfortunately, t.wait_result() didn't
> change anything.
>
> -Mike
>
> On May 23, 2013, at 3:26 PM, Andreas Hocevar <[hidden email]> wrote:
>
> I think the problem is that your init() function won't be called when the
> page is loaded by the test runner. So you'll have to call init() from the
> test function (test_onClick12 in the current code).
>
> Andreas.
>
>
> On Thu, May 23, 2013 at 12:33 PM, Michael Ryan <[hidden email]> wrote:
>>
>> Thanks for all the help, Andreas.
>>
>> I'm pretty sure I can figure the contrib stuff out.
>>
>> At the moment, I'm hitting a wall with why a very simple test works if I
>> just run the featureclick.html page, but not when I run the test function:
>>
>>
>> https://github.com/m1k3ry4n/openlayers/blob/master/tests/Events/featureclick.html
>>
>> When I run the html page the logevt array has length 2. In the test, it's
>> length 0. Yet I'm running the exact same code.
>>
>> I know this is taking a while and I may be missing the 2.13 deadline, but
>> I'll keep plugging away at this til I get it right.
>>
>> -Mike
>>
>> On May 22, 2013, at 10:02 PM, Andreas Hocevar <[hidden email]>
>> wrote:
>>
>> Hey Michael,
>>
>> you should find all information on how to submit code here:
>> http://trac.osgeo.org/openlayers/wiki/HowToContribute. You will want to
>> create a pull request, as explained here:
>> http://trac.osgeo.org/openlayers/wiki/CreatingPatches.
>>
>> I hope this helps.
>>
>> Andreas.
>>
>>
>> On Wed, May 22, 2013 at 9:34 AM, Michael Ryan <[hidden email]> wrote:
>>>
>>> Thank you Andreas for clearing up that I should assign events like so:
>>>
>>> events = map.events
>>>
>>> The other part of this is that you have specify that the event you are
>>> triggering is a left-click.
>>>
>>> By tracing the code you see that you need to set the "which" attribute to
>>> 1 in the object passed to triggerEvent(), otherwise onClick in
>>> featureclick.js ignores the event.
>>>
>>> So, this is what my code should have looked like:
>>>
>>> events = map.events;
>>> events.triggerEvent( 'mousedown', {xy: new OpenLayers.Pixel(0,0), which:
>>> 1}, map);
>>> events.triggerEvent('mouseup', {xy: new OpenLayers.Pixel(0,0), which: 1},
>>> map);
>>>
>>> I'm assuming I can get tests written today. Although, I'm not exactly
>>> clear how to submit them. If anyone wants to clue me in to that procedure
>>> I'd appreciate it.
>>>
>>> -Mike
>>>
>>> On May 21, 2013, at 5:21 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> While I've understood I need to use trigger() somehow, I have been
>>> unsuccessful in implementing it.
>>>
>>> I was using test for buttonclick as a reference:
>>> https://github.com/openlayers/openlayers/blob/master/tests/Events/buttonclick.html
>>>
>>> I would have assumed that within the context of the featurclick example
>>> https://github.com/openlayers/openlayers/pull/174/files
>>>
>>> I could have used something like
>>>
>>> events = OpenLayers.Events(map, document.getElementById("map"));
>>> events.triggerEvent({type: 'mousedown', xy: new OpenLayers.Pixel(0,0)},
>>> map); events.triggerEvent({type: 'mouseup', xy: new OpenLayers.Pixel(0,0)},
>>> map);
>>>
>>> But, apparently, that's wrong.
>>>
>>> Am I trying to do something that isn't possible? I'm assuming I'm just
>>> implementing it wrong. Any thoughts?
>>>
>>> -Mike
>>>
>>> On May 20, 2013, at 5:04 PM, Michael Ryan <[hidden email]> wrote:
>>>
>>> I'll answer my question about triggering a buttonclick by saying, it
>>> looks like you use trigger() which takes coordinates as an argument as in
>>> this test:
>>> https://github.com/drewwells/openlayers/blob/master/tests/Control/Measure.html
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>>
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev