Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

20150811 potatotips 20

1,163 views

Published on

How to test GPS on Emulator. You can use Genymotion which is x86 virtual box image to run android applicadtion faster.

Published in: Software
  • Be the first to comment

20150811 potatotips 20

  1. 1. How to test GPS on Emulator potatotips #20
  2. 2. Problems to solve • Execute test code effectively • Android public emulator does not support GPS sensors
  3. 3. Genymotion • Fast • x86 archirecture, VirtualBox • Simple • Some behavior with Android Public Emulator • Powerfull • Contro some sensor from API
  4. 4. Configuring Gradle Builds repositories { maven{ url "http://api.genymotion.com/repositories/releases/" } } dependencies { androidTestCompile ‘com.genymotion.api:genymotion-api:1.0.2’ }
  5. 5. How to use (GPS Sensors) GenymotionManager genymotion = GenymotionManager.getGenymotionManager(ctx); // Position to reykjavik (257km away)) Log.d(GpsSampleFragment.TAG, "Force position to Reykjavik"); genymotion.getGps() .setLatitude(64.13367829) .setLongitude(-21.8964386); // Then ensure warning is hidden Assert.assertEquals(tvWarning.getVisibility(), View.GONE); // Position near Dalvik Log.d(GpsSampleFragment.TAG, "Force position near Dalvik"); genymotion.getGps() .setLatitude(65.9446) .setLongitude(-18.35744619); // Ensure warning is shown Assert.assertEquals(tvWarning.getVisibility(), View.VISIBLE);
  6. 6. How to use (Battery Status) GenymotionManager genymotion = GenymotionManager.getGenymotionManager(getActivity()); // Change battery level and charging status Log.d(BatterySampleFragment.TAG, "Force full battery + charging"); genymotion.getBattery() .setLevel(100) .setStatus(Battery.Status.CHARGING); // Then ensure warning is hidden Assert.assertEquals(tvWarning.getVisibility(), View.GONE); // Change battery level and charging status Log.d(BatterySampleFragment.TAG, "Force low battery"); genymotion.getBattery() .setLevel(3) .setStatus(Battery.Status.DISCHARGING); // Then ensure warning is visible Assert.assertEquals(tvWarning.getVisibility(), View.VISIBLE); // set battery mode back to HOST genymotion.getBattery().setMode(Battery.Mode.HOST);
  7. 7. Excursus • Need to login • Free • For personal use only • Business • €24.99, per month,per user • Java API • need to emulate sensors
  8. 8. Thank you

×