This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* inject client manager * clear client manager location data to always report initial loc when service started * add reported changes tests
- Loading branch information
1 parent
338575f
commit 8efddea
Showing
8 changed files
with
124 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
lost/src/test/java/com/mapzen/android/lost/internal/ReportedChangesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.mapzen.android.lost.internal; | ||
|
||
import com.mapzen.android.lost.api.LocationRequest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import android.location.Location; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.fest.assertions.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class ReportedChangesTest { | ||
|
||
Map<LocationRequest, Long> timeChanges = new HashMap<>(); | ||
Map<LocationRequest, Location> locationChanges = new HashMap<>(); | ||
ReportedChanges changes; | ||
|
||
@Before public void setup() { | ||
changes = new ReportedChanges(timeChanges, locationChanges); | ||
} | ||
|
||
@Test public void putAll_shouldUpdateTimeChanges() { | ||
Map<LocationRequest, Long> otherTimeChanges = new HashMap<>(); | ||
LocationRequest locRequest = LocationRequest.create(new TestPidReader()); | ||
otherTimeChanges.put(locRequest, 1234L); | ||
Map<LocationRequest, Location> otherLocationChanges = new HashMap<>(); | ||
ReportedChanges otherChanges = new ReportedChanges(otherTimeChanges, otherLocationChanges); | ||
changes.putAll(otherChanges); | ||
assertThat(changes.timeChanges().get(locRequest)).isEqualTo(1234L); | ||
} | ||
|
||
@Test public void putAll_shouldUpdateLocationChanges() { | ||
Map<LocationRequest, Long> otherTimeChanges = new HashMap<>(); | ||
Map<LocationRequest, Location> otherLocationChanges = new HashMap<>(); | ||
LocationRequest locRequest = LocationRequest.create(new TestPidReader()); | ||
Location loc = mock(Location.class); | ||
otherLocationChanges.put(locRequest, loc); | ||
ReportedChanges otherChanges = new ReportedChanges(otherTimeChanges, otherLocationChanges); | ||
changes.putAll(otherChanges); | ||
assertThat(changes.locationChanges().get(locRequest)).isEqualTo(loc); | ||
} | ||
|
||
@Test public void clearAll_shouldClearTimeChanges() { | ||
Map<LocationRequest, Long> otherTimeChanges = new HashMap<>(); | ||
LocationRequest locRequest = LocationRequest.create(new TestPidReader()); | ||
otherTimeChanges.put(locRequest, 1234L); | ||
Map<LocationRequest, Location> otherLocationChanges = new HashMap<>(); | ||
Location loc = mock(Location.class); | ||
otherLocationChanges.put(locRequest, loc); | ||
ReportedChanges otherChanges = new ReportedChanges(otherTimeChanges, otherLocationChanges); | ||
changes.putAll(otherChanges); | ||
changes.clearAll(); | ||
assertThat(changes.timeChanges()).isEmpty(); | ||
} | ||
|
||
@Test public void clearAll_shouldClearLocationChanges() { | ||
Map<LocationRequest, Long> otherTimeChanges = new HashMap<>(); | ||
LocationRequest locRequest = LocationRequest.create(new TestPidReader()); | ||
otherTimeChanges.put(locRequest, 1234L); | ||
Map<LocationRequest, Location> otherLocationChanges = new HashMap<>(); | ||
Location loc = mock(Location.class); | ||
otherLocationChanges.put(locRequest, loc); | ||
ReportedChanges otherChanges = new ReportedChanges(otherTimeChanges, otherLocationChanges); | ||
changes.putAll(otherChanges); | ||
changes.clearAll(); | ||
assertThat(changes.locationChanges()).isEmpty(); | ||
} | ||
|
||
} |