This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - add resource usage to HttpRequest, add offline query para…
…meter flag to http request
- Loading branch information
Showing
7 changed files
with
114 additions
and
19 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
29 changes: 24 additions & 5 deletions
29
platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxInjector.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
67 changes: 67 additions & 0 deletions
67
...d/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUrlTest.kt
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,67 @@ | ||
package com.mapbox.mapboxsdk.module.http | ||
|
||
import com.mapbox.mapboxsdk.MapboxInjector | ||
import com.mapbox.mapboxsdk.http.HttpRequestUrl | ||
import io.mockk.mockk | ||
import junit.framework.Assert.assertEquals | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class HttpRequestUrlTest { | ||
|
||
@Before | ||
fun setUp() { | ||
MapboxInjector.inject(mockk(relaxed = true), "pk.foobar", "foobar") | ||
} | ||
|
||
@Test | ||
fun testOfflineFlagMapboxCom() { | ||
val expected = "http://mapbox.com/path/of/no/return.pbf?sku=foobar&offline=true" | ||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, true) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun testOfflineFlagMapboxCn() { | ||
val expected = "http://mapbox.cn/path/of/no/return.pbf?sku=foobar&offline=true" | ||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, true) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun testOfflineFlagInvalidHost() { | ||
val expected = "http://foobar.com/path/of/no/return.pbf" | ||
val actual = HttpRequestUrl.buildResourceUrl("foobar.com", "http://foobar.com/path/of/no/return.pbf", 0, true) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun testOnlineMapboxCom() { | ||
val expected = "http://mapbox.com/path/of/no/return.pbf?sku=foobar" | ||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, false) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun testOnlineMapboxCn() { | ||
val expected = "http://mapbox.cn/path/of/no/return.pbf?sku=foobar" | ||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, false) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@Test | ||
fun testOnlineInvalidHost() { | ||
val expected = "http://foobar.com/path/of/no/return.pbf" | ||
val actual = HttpRequestUrl.buildResourceUrl("foobar.com", "http://foobar.com/path/of/no/return.pbf", 0, false) | ||
assertEquals(expected, actual) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
MapboxInjector.clear() | ||
} | ||
} |
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