diff options
Diffstat (limited to 'app/src/test/kotlin')
3 files changed, 54 insertions, 3 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbFullImageTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbFullImageTest.kt new file mode 100644 index 00000000..98dc7dda --- /dev/null +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbFullImageTest.kt @@ -0,0 +1,32 @@ +package com.pitchedapps.frost.facebook + +import com.pitchedapps.frost.facebook.requests.getFullSizedImage +import com.pitchedapps.frost.facebook.requests.getFullSizedImageUrl +import com.pitchedapps.frost.internal.COOKIE +import com.pitchedapps.frost.internal.authDependent +import org.junit.BeforeClass +import org.junit.Test +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + +/** + * Created by Allan Wang on 12/04/18. + */ +class FbFullImageTest { + + companion object { + @BeforeClass + @JvmStatic + fun before() { + authDependent() + } + } + + @Test + fun getFullImage() { + val url = "https://touch.facebook.com/photo/view_full_size/?fbid=107368839645039" + val result = COOKIE.getFullSizedImageUrl(url).blockingGet() + assertNotNull(result) + println(result) + } +}
\ No newline at end of file diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt index 0e45d2f2..beda26ef 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt @@ -1,6 +1,7 @@ package com.pitchedapps.frost.facebook import com.pitchedapps.frost.utils.isImageUrl +import com.pitchedapps.frost.utils.isIndirectImageUrl import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -48,6 +49,13 @@ class FbUrlTest { } @Test + fun ampersand() { + val url = "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/123.jpg?_nc_cat=0&efg=asdf" + val formattedUrl = "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/123.jpg?_nc_cat=0&efg=asdf" + assertFbFormat(formattedUrl, url) + } + + @Test fun doubleDash() { assertFbFormat("${FB_URL_BASE}relative", "$FB_URL_BASE/relative") } @@ -73,6 +81,15 @@ class FbUrlTest { } @Test + fun indirectImage() { + arrayOf( + "#!/photo/view_full_size/?fbid=107368839645039" + ).forEach { + assertTrue(it.isIndirectImageUrl, "Failed to match indirect image for $it") + } + } + + @Test fun antiImageRegex() { arrayOf( "http...fbcdn.net...mp4", diff --git a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt index 2af98eda..e3beabd2 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt @@ -24,11 +24,13 @@ import kotlin.test.fail private const val FILE = "priv.properties" +private val propPaths = arrayOf(FILE, "../$FILE") + val PROPS: Properties by lazy { val props = Properties() - val file = File(FILE) - if (!file.exists()) { - println("$FILE not found") + val file = propPaths.map(::File).firstOrNull { it.isFile } + if (file == null) { + println("$FILE not found at ${File(".").absolutePath}") return@lazy props } println("Found properties at ${file.absolutePath}") |