[android] - expose setAccesToken on Mapbox.java
This commit is contained in:
@@ -68,7 +68,7 @@ public final class Mapbox {
|
||||
}
|
||||
|
||||
/**
|
||||
* Access token for this application.
|
||||
* Get the current active access token for this application.
|
||||
*
|
||||
* @return Mapbox access token
|
||||
*/
|
||||
@@ -78,6 +78,15 @@ public final class Mapbox {
|
||||
return INSTANCE.accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active accessToken.
|
||||
*/
|
||||
public static void setAccessToken(String accessToken) {
|
||||
validateMapbox();
|
||||
INSTANCE.accessToken = accessToken;
|
||||
FileSource.getInstance(getApplicationContext()).setAccessToken(accessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Application context
|
||||
*
|
||||
|
||||
@@ -6,10 +6,14 @@ import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertSame;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
public class MapboxTest extends BaseActivityTest {
|
||||
|
||||
private static final String ACCESS_TOKEN = "pk.0000000001";
|
||||
private static final String ACCESS_TOKEN_2 = "pk.0000000002";
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
@@ -30,4 +34,15 @@ public class MapboxTest extends BaseActivityTest {
|
||||
Mapbox.setConnected(null);
|
||||
assertTrue(Mapbox.isConnected());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAccessToken() {
|
||||
validateTestSetup();
|
||||
String realToken = Mapbox.getAccessToken();
|
||||
Mapbox.setAccessToken(ACCESS_TOKEN);
|
||||
assertSame(ACCESS_TOKEN, Mapbox.getAccessToken());
|
||||
Mapbox.setAccessToken(ACCESS_TOKEN_2);
|
||||
assertSame(ACCESS_TOKEN_2, Mapbox.getAccessToken());
|
||||
Mapbox.setAccessToken(realToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user