Skip to content
Browse files

Added tests for wait for fix dialog behaviour

  • Loading branch information...
1 parent 482abe5 commit 2e7ffb034f2a815258a273edca969edd6fee5cfc Stefano Dacchille committed Mar 27, 2012
View
2 ...hub/ignition/location/utils/lastlocationfinders/IgnitedGingerbreadLastLocationFinder.java
@@ -38,7 +38,7 @@
* (where one exists) and setup a oneshot location update to find the current location.
*/
public class IgnitedGingerbreadLastLocationFinder extends IgnitedAbstractLastLocationFinder {
- private static String SINGLE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.SINGLE_LOCATION_UPDATE_ACTION";
+ public static String SINGLE_LOCATION_UPDATE_ACTION = "com.github.ignition.location.SINGLE_LOCATION_UPDATE_ACTION";
private PendingIntent singleUpatePI;
View
9 .../src/test/java/com/github/ignition/location/tests/AbstractIgnitedLocationManagerTest.java
@@ -98,6 +98,15 @@ protected void sendBatteryLevelChangedBroadcast(int level) {
}
@Test
+ public void shouldShowWaitForFixDialogIfNoLocationAvailable() {
+ shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, null);
+ resume();
+
+ assertThat("Wait for fix dialog should be shown", Robolectric.shadowOf(activity)
+ .getLastShownDialogId(), equalTo(R.id.ign_loc_dialog_wait_for_fix));
+ }
+
+ @Test
public void ignitedLocationIsCurrentLocation() {
resume();
View
20 ...c/test/java/com/github/ignition/location/tests/IgnitedLocationManagerGingerbreadTest.java
@@ -1,6 +1,7 @@
package com.github.ignition.location.tests;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsEqual.equalTo;
import java.util.Map;
@@ -12,7 +13,11 @@
import android.location.Criteria;
import android.location.LocationManager;
+import com.github.ignition.location.utils.lastlocationfinders.IgnitedGingerbreadLastLocationFinder;
+import com.github.ignition.samples.R;
import com.github.ignition.support.IgnitedDiagnostics;
+import com.xtremelabs.robolectric.Robolectric;
+import com.xtremelabs.robolectric.shadows.ShadowActivity;
@RunWith(IgnitedLocationSampleActivityRobolectricTestRunner.class)
public class IgnitedLocationManagerGingerbreadTest extends AbstractIgnitedLocationManagerTest {
@@ -44,4 +49,19 @@ public void shouldRequestUpdatesFromGpsIfBatteryOkay() {
+ " provider should be requested when battery power is okay!",
locationPendingIntents.containsValue(criteria));
}
+
+ @Test
+ public void shouldDismissWaitForFixDialogWhenLocationIsAvailable() {
+ shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, null);
+ resume();
+
+ sendMockLocationBroadcast(LocationManager.GPS_PROVIDER,
+ IgnitedGingerbreadLastLocationFinder.SINGLE_LOCATION_UPDATE_ACTION);
+
+ // boolean showing = Robolectric.shadowOf(ShadowDialog.getLatestDialog()).isShowing();
+ // assertThat("Wait for fix dialog should be dismissed", showing, equalTo(false));
+ ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
+ assertThat("Wait for fix dialog should be dismissed",
+ shadowActivity.getDialogById(R.id.ign_loc_dialog_wait_for_fix), equalTo(null));
+ }
}
View
7 ...ts/src/test/java/com/github/ignition/location/tests/IgnitedLocationManagerLegacyTest.java
@@ -43,4 +43,11 @@ public void shouldRequestUpdatesFromGpsIfBatteryOkay() {
+ " provider should be requested when battery power is okay!",
locationPendingIntents.containsValue(LocationManager.GPS_PROVIDER));
}
+
+ // TODO don't see an easy way to test it, maybe this requires patching robolectric
+ // @Test
+ // public void shouldDismissWaitForFixDialogWhenLocationIsAvailable() {
+ // shadowLocationManager.setLastKnownLocation(LocationManager.GPS_PROVIDER, null);
+ // resume();
+ // }
}

0 comments on commit 2e7ffb0

Please sign in to comment.
Something went wrong with that request. Please try again.