Revert 36b8664f
parent
de96980a11
commit
4de11cb073
@ -1,20 +0,0 @@ |
|||||||
package com.keylesspalace.tusky.util |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import android.content.Intent |
|
||||||
import android.net.Uri |
|
||||||
import com.keylesspalace.tusky.R |
|
||||||
|
|
||||||
fun shouldRickRoll(context: Context, domain: String) = |
|
||||||
context.resources.getStringArray(R.array.rick_roll_domains).any { candidate -> |
|
||||||
domain.equals(candidate, true) || domain.endsWith(".$candidate", true) |
|
||||||
} |
|
||||||
|
|
||||||
fun rickRoll(context: Context) { |
|
||||||
val uri = Uri.parse(context.getString(R.string.rick_roll_url)) |
|
||||||
val intent = Intent(Intent.ACTION_VIEW, uri).apply { |
|
||||||
addCategory(Intent.CATEGORY_BROWSABLE) |
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
|
||||||
} |
|
||||||
context.startActivity(intent) |
|
||||||
} |
|
@ -1,34 +0,0 @@ |
|||||||
package com.keylesspalace.tusky.util |
|
||||||
|
|
||||||
import android.app.Activity |
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4 |
|
||||||
import com.keylesspalace.tusky.FakeTuskyApplication |
|
||||||
import org.junit.Assert.assertFalse |
|
||||||
import org.junit.Assert.assertTrue |
|
||||||
import org.junit.Before |
|
||||||
import org.junit.Test |
|
||||||
import org.junit.runner.RunWith |
|
||||||
import org.robolectric.Robolectric |
|
||||||
import org.robolectric.annotation.Config |
|
||||||
|
|
||||||
@Config(application = FakeTuskyApplication::class, sdk = [28]) |
|
||||||
@RunWith(AndroidJUnit4::class) |
|
||||||
class RickRollTest { |
|
||||||
private lateinit var activity: Activity |
|
||||||
@Before |
|
||||||
fun setupActivity() { |
|
||||||
val controller = Robolectric.buildActivity(Activity::class.java) |
|
||||||
activity = controller.get() |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
fun testShouldRickRoll() { |
|
||||||
listOf("gab.Com", "social.gab.ai", "whatever.GAB.com").forEach { |
|
||||||
rollableDomain -> assertTrue(shouldRickRoll(activity, rollableDomain)) |
|
||||||
} |
|
||||||
|
|
||||||
listOf("chaos.social", "notgab.com").forEach { |
|
||||||
notRollableDomain -> assertFalse(shouldRickRoll(activity, notRollableDomain)) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue