Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
use application context in lost client (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsnow1 committed May 9, 2017
1 parent 836bdbf commit d311a9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Builder {
private ConnectionCallbacks connectionCallbacks;

public Builder(Context context) {
this.context = context;
this.context = context.getApplicationContext();
}

public Builder addConnectionCallbacks(ConnectionCallbacks callbacks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.robolectric.shadows.ShadowLooper;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
Expand Down Expand Up @@ -56,8 +55,8 @@ public class FusedLocationProviderServiceDelegateTest extends BaseRobolectricTes
private LostApiClient otherClient;

@Before public void setUp() throws Exception {
client = new LostApiClient.Builder(mock(Context.class)).build();
otherClient = new LostApiClient.Builder(mock(Context.class)).build();
client = new LostApiClient.Builder(application).build();
otherClient = new LostApiClient.Builder(application).build();
delegate = new FusedLocationProviderServiceDelegate(application);
locationManager = (LocationManager) application.getSystemService(LOCATION_SERVICE);
shadowLocationManager = (LostShadowLocationManager) ShadowExtractor.extract(locationManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mapzen.android.lost.api.LostApiClient;
import com.mapzen.lost.BuildConfig;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
Expand All @@ -32,7 +33,11 @@
public class LostClientManagerTest extends BaseRobolectricTest {

LostClientManager manager = new LostClientManager();
LostApiClient client = new LostApiClient.Builder(application).build();
LostApiClient client;

@Before public void setup() throws Exception {
client = new LostApiClient.Builder(application).build();
}

@Test public void shouldHaveZeroClientCount() {
assertThat(manager.numberOfClients()).isEqualTo(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.mapzen.android.lost.internal;

import com.mapzen.android.lost.api.LostApiClient;
import com.mapzen.lost.BuildConfig;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import static org.fest.assertions.api.Assertions.assertThat;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class LostClientWrapperTest {
private LostClientWrapper wrapper;
private LostApiClient client;
Expand Down

0 comments on commit d311a9e

Please sign in to comment.