Reputation: 671
Our android application is getting fairly big and we would like to use functional tests for our application to prevent regression. We are looking in to options to achieve this.
We make use of geo locations, so now we test the app by entering lat/long in DDMS. If we want to test this, it should be possible to set these geo locations programmatically.
Is there a framework that we can use to functional test our android app and also send these updates to our emulator?
Upvotes: 6
Views: 2676
Reputation: 19237
If you use monkeyrunner, then you might use this function:
def telnet(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
# connect to remote host
try :
s.connect((host, port))
except :
print 'Unable to connect'
sys.exit()
print 'Connected to remote host'
return s
def geo_fix(port, lat, lng):
print "setting gps to " + str(lat) + "," + str(lng)
socket = telnet("localhost", port)
socket.send("geo fix " + str(lng) + " " + str(lat) + "\n")
socket.send("exit\n")
socket.close()
geo_fix(5554, 32.0878802, 34.797246)
I couldn't find a way to get the emulator's port from the MonkeyDevice, so I manually pass the port, but would be nicer if we could figure it out from the device object
Upvotes: 0
Reputation: 1125
I am facing the same problem. While this solution is not built into robotium, you should be able to make it into a utility that can be used in your unit tests.
Upvotes: 4
Reputation: 11930
If you compile in Eclipse, you can fake the lat/lon in the android emulator:
Upvotes: 6