Skip to content

Commit

Permalink
No bug - Update uses of SuggestionQuery in Firefox Suggest.
Browse files Browse the repository at this point in the history
This commit fixes the breaking change introduced in
mozilla/application-services#5867.
  • Loading branch information
linabutler committed Oct 14, 2023
1 parent 6e9f56f commit 9e0e214
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Expand Up @@ -6,6 +6,7 @@ package mozilla.components.feature.fxsuggest

import android.content.res.Resources
import mozilla.appservices.suggest.Suggestion
import mozilla.appservices.suggest.SuggestionProvider
import mozilla.appservices.suggest.SuggestionQuery
import mozilla.components.concept.awesomebar.AwesomeBar
import mozilla.components.feature.session.SessionUseCases
Expand Down Expand Up @@ -36,11 +37,18 @@ class FxSuggestSuggestionProvider(
if (text.isEmpty()) {
emptyList()
} else {
val providers = buildList() {
if (includeSponsoredSuggestions) {
add(SuggestionProvider.AMP)
}
if (includeNonSponsoredSuggestions) {
add(SuggestionProvider.WIKIPEDIA)
}
}
GlobalFxSuggestDependencyProvider.requireStorage().query(
SuggestionQuery(
keyword = text,
includeSponsored = includeSponsoredSuggestions,
includeNonSponsored = includeNonSponsoredSuggestions,
providers = providers,
),
).into()
}
Expand Down
Expand Up @@ -7,6 +7,7 @@ package mozilla.components.feature.fxsuggest
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.test.runTest
import mozilla.appservices.suggest.Suggestion
import mozilla.appservices.suggest.SuggestionProvider
import mozilla.appservices.suggest.SuggestionQuery
import mozilla.components.support.test.any
import mozilla.components.support.test.eq
Expand Down Expand Up @@ -112,8 +113,7 @@ class FxSuggestSuggestionProviderTest {
eq(
SuggestionQuery(
keyword = "la",
includeSponsored = true,
includeNonSponsored = true,
providers = listOf(SuggestionProvider.AMP, SuggestionProvider.WIKIPEDIA),
),
),
)
Expand Down Expand Up @@ -168,8 +168,7 @@ class FxSuggestSuggestionProviderTest {
eq(
SuggestionQuery(
keyword = "la",
includeSponsored = false,
includeNonSponsored = true,
providers = listOf(SuggestionProvider.WIKIPEDIA),
),
),
)
Expand Down Expand Up @@ -212,8 +211,7 @@ class FxSuggestSuggestionProviderTest {
eq(
SuggestionQuery(
keyword = "la",
includeSponsored = true,
includeNonSponsored = false,
providers = listOf(SuggestionProvider.AMP),
),
),
)
Expand Down

0 comments on commit 9e0e214

Please sign in to comment.