1
0
Fork 0

For #12025: Set Search Shortcuts Off By Default

master
Kate Glazko 2020-06-26 15:53:51 -07:00 committed by kglazko
parent a18c1befd1
commit 2ac8496315
5 changed files with 34 additions and 2 deletions

View File

@ -50,6 +50,12 @@ class SearchTest {
@Test
fun shortcutButtonTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSearchSubMenu {
enableShowSearchShortcuts()
}.goBack {
}.goBack {
}.openSearch {
verifySearchWithText()
clickSearchEngineButton("DuckDuckGo")
@ -63,6 +69,12 @@ class SearchTest {
@Test
fun shortcutSearchEngineSettingsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSearchSubMenu {
enableShowSearchShortcuts()
}.goBack {
}.goBack {
}.openSearch {
scrollToSearchEngineSettings()
clickSearchEngineSettings()

View File

@ -36,6 +36,7 @@ class SettingsSubMenuSearchRobot {
selectDefaultSearchEngine(searchEngineName)
fun disableShowSearchSuggestions() = toggleShowSearchSuggestions()
fun enableShowSearchShortcuts() = toggleShowSearchShortcuts()
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@ -142,5 +143,16 @@ private fun toggleShowSearchSuggestions() {
.perform(click())
}
private fun toggleShowSearchShortcuts() {
onView(withId(androidx.preference.R.id.recycler_view)).perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText("Show search shortcuts"))
)
)
onView(withText("Show search shortcuts"))
.perform(click())
}
private fun goBackButton() =
onView(CoreMatchers.allOf(withContentDescription("Navigate up")))

View File

@ -309,7 +309,7 @@ class Settings private constructor(
val shouldShowSearchShortcuts by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_show_search_shortcuts),
default = true
default = false
)
val shouldUseDarkTheme by booleanPreference(

View File

@ -150,6 +150,10 @@ class DefaultSearchControllerTest {
@Test
fun `show search shortcuts when setting enabled AND query empty`() {
val text = ""
testContext.settings().preferences
.edit()
.putBoolean(testContext.getString(R.string.pref_key_show_search_shortcuts), true)
.apply()
controller.handleTextChanged(text)
@ -160,6 +164,10 @@ class DefaultSearchControllerTest {
fun `show search shortcuts when setting enabled AND query equals url`() {
val text = "mozilla.org"
every { session?.url } returns "mozilla.org"
testContext.settings().preferences
.edit()
.putBoolean(testContext.getString(R.string.pref_key_show_search_shortcuts), true)
.apply()
assertEquals(text, session?.url)

View File

@ -254,7 +254,7 @@ class SettingsTest {
fun shouldShowSearchShortcuts() {
// When just created
// Then
assertTrue(settings.shouldShowSearchShortcuts)
assertFalse(settings.shouldShowSearchShortcuts)
}
@Test