Commit 999f9b1e authored by Tiger Oakes's avatar Tiger Oakes Committed by Sebastian Kaspari
Browse files

Issue #3481 - Support Q in browser components

parent 92862899
package mozilla.components.browser.domains
import android.content.Context
import android.preference.PreferenceManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.Dispatchers
import mozilla.components.browser.domains.autocomplete.BaseDomainAutocompleteProvider
......@@ -9,7 +8,6 @@ import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvide
import mozilla.components.browser.domains.autocomplete.DomainList
import mozilla.components.browser.domains.autocomplete.DomainsLoader
import mozilla.components.support.test.robolectric.testContext
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
......@@ -19,14 +17,6 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BaseDomainAutocompleteProviderTest {
@After
fun tearDown() {
PreferenceManager.getDefaultSharedPreferences(testContext)
.edit()
.clear()
.apply()
}
@Test
fun `empty provider with DEFAULT list returns nothing`() {
val provider = createAndInitProvider(testContext, DomainList.DEFAULT) {
......@@ -135,4 +125,4 @@ private fun assertNoCompletion(provider: DomainAutocompleteProvider, input: Stri
private fun createAndInitProvider(context: Context, list: DomainList, loader: DomainsLoader): DomainAutocompleteProvider =
object : BaseDomainAutocompleteProvider(list, loader) {
override val coroutineContext = super.coroutineContext + Dispatchers.Main
}.apply { initialize(context) }
\ No newline at end of file
}.apply { initialize(context) }
......@@ -6,12 +6,10 @@
package mozilla.components.browser.domains
import android.preference.PreferenceManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.browser.domains.DomainAutoCompleteProvider.AutocompleteSource.CUSTOM_LIST
import mozilla.components.browser.domains.DomainAutoCompleteProvider.AutocompleteSource.DEFAULT_LIST
import mozilla.components.support.test.robolectric.testContext
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
......@@ -24,14 +22,6 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class DomainAutoCompleteProviderTest {
@After
fun tearDown() {
PreferenceManager.getDefaultSharedPreferences(testContext)
.edit()
.clear()
.apply()
}
@Test
fun autocompletionWithShippedDomains() {
val provider = DomainAutoCompleteProvider().also {
......
......@@ -44,7 +44,7 @@ class ParseSearchPluginsTest(private val searchEngineIdentifier: String) {
companion object {
@JvmStatic
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}")
fun searchPlugins(): Collection<Array<Any>> = basePath.list()
fun searchPlugins(): Collection<Array<Any>> = basePath.list().orEmpty()
.mapNotNull { it as Any }
.map { arrayOf(it) }
......
......@@ -6,7 +6,6 @@ package org.mozilla.samples.dataprotect
import android.content.SharedPreferences
import android.os.Bundle
import android.preference.PreferenceManager
import android.util.Base64
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
......@@ -36,7 +35,7 @@ class MainActivity : AppCompatActivity() {
keystore.generateKey()
// setup protected data key/value pairs
val prefs = PreferenceManager.getDefaultSharedPreferences(this).apply {
val prefs = getSharedPreferences(SAMPLE_PREFS_KEY, MODE_PRIVATE).apply {
prepareProtectedData(this)
}
......@@ -78,4 +77,8 @@ class MainActivity : AppCompatActivity() {
val res = if (listAdapter.unlocked) R.string.btn_toggle_lock else R.string.btn_toggle_unlock
toggleBtn.setText(res)
}
companion object {
private const val SAMPLE_PREFS_KEY = "protectedData"
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment