Android functional test; send geographic location to emulator

Our Android application is getting quite large, and we would like to use functional tests for our application to prevent regression. We are looking for opportunities for this.

We use geolocation, so now we are testing the application by entering lat / long in DDMS. If we want to test it, it will be possible to establish these geo positions programmatically.

Is there any framework that we can use for functional testing of our Android application, and also send these updates to our emulator?

+6
source share
3 answers

I ran into the same problem. Although this solution is not built into robotics, you should be able to make it a utility that can be used in your unit tests.

Site Location Service

+4
source

If you compile in Eclipse, you can fake lat / lon in the Android emulator:

  • Windows> Open Perspective> Other.
  • Choose DDMS
  • Search emulator control tab
  • Use the location control to send latitude and longitude whenever you want.
+6
source

If you are using monkeyrunner, you can 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 could not find a way to get the emulator port from MonkeyDevice, so I manually pass the port, but it would be better if we could understand this from the device object

0
source

Source: https://habr.com/ru/post/904139/


All Articles