can you write an app to play your app?

Hi

I’m refactoring my app and doing some testing. I wrote a test function that simulates playing the app partly just for fun and partly to help me research this memory leak I may have by playing the app multiple times for me to save me the trouble.

Anyway just wondering, can you write an app that will ‘play’ another app but that is a completely separate app? My test function ‘plays’ the app but it’s also part of the app.

Also in the same vein, suppose you want to test a touch event listener on its own. Is there a way to call a touch event listener function without really touching the screen? How would you send it the ‘event’?

thanks,

David

One option is to use AutoHotKey or similar to simulate mouse movements to “play” Corona simulator. I have not tried anything like that.

To fire off touch listener function you can make a call like this for example

[lua]myTouchListenerFunction({phase = “ended”, target = myTargetObject})[/lua]

I would recommend using corona’s dispatch event method to do the touching vs firing the function directly:

myObject:dispatchEvent( { name = "touch", phase = "began" } )

The beauty of corona’s dispatch event method, is that you can also dispatch events to objects in different files via runtime events, which in turn can dispatch local events.

It’s a very powerful concept, and something well worth learning and experimenting with.

Hi

thanks - I’m running into a problem in that my touch objects are all local to their functions, so that if I call a touch listener function from inside a different function I have no access to the touch objects.

For example, the touch listener I’m trying to call assigns a value to a variable like this:

 myData.questionChoice = event.target.type

The target.type in this case is just a string, e.g. “Musical terms”

Is there a way to call the listener and send it “Musical terms”? I tried to do

displayMainMenuListener({phase = "ended", target.type = "Musical terms" })

but it doesn’t work. I need to send it a real object I think.

thanks.

I created an object within my test function as used that.

questionType\_everything\_test = display.newText("",100,100,FONT\_NAME, SCORES\_FONT\_SIZE) questionType\_everything\_test.type = "Musical terms" displayMainMenuListener({phase = "ended", target = questionType\_everything\_test })

This works well enough.

Seriously, use dispatch event. It’s the cleanest way of doing this.

https://docs.coronalabs.com/api/type/EventListener/dispatchEvent.html

OK I’ve implemented that. Thanks.

One option is to use AutoHotKey or similar to simulate mouse movements to “play” Corona simulator. I have not tried anything like that.

To fire off touch listener function you can make a call like this for example

[lua]myTouchListenerFunction({phase = “ended”, target = myTargetObject})[/lua]

I would recommend using corona’s dispatch event method to do the touching vs firing the function directly:

myObject:dispatchEvent( { name = "touch", phase = "began" } )

The beauty of corona’s dispatch event method, is that you can also dispatch events to objects in different files via runtime events, which in turn can dispatch local events.

It’s a very powerful concept, and something well worth learning and experimenting with.

Hi

thanks - I’m running into a problem in that my touch objects are all local to their functions, so that if I call a touch listener function from inside a different function I have no access to the touch objects.

For example, the touch listener I’m trying to call assigns a value to a variable like this:

 myData.questionChoice = event.target.type

The target.type in this case is just a string, e.g. “Musical terms”

Is there a way to call the listener and send it “Musical terms”? I tried to do

displayMainMenuListener({phase = "ended", target.type = "Musical terms" })

but it doesn’t work. I need to send it a real object I think.

thanks.

I created an object within my test function as used that.

questionType\_everything\_test = display.newText("",100,100,FONT\_NAME, SCORES\_FONT\_SIZE) questionType\_everything\_test.type = "Musical terms" displayMainMenuListener({phase = "ended", target = questionType\_everything\_test })

This works well enough.

Seriously, use dispatch event. It’s the cleanest way of doing this.

https://docs.coronalabs.com/api/type/EventListener/dispatchEvent.html

OK I’ve implemented that. Thanks.