1
0
Fork 0

Update Android Components and fix breaking tests

master
Jonathan Almeida 2020-08-06 13:51:48 -04:00 committed by Jonathan Almeida
parent bee2ae6c83
commit 9568bdaed8
3 changed files with 24 additions and 6 deletions

View File

@ -126,7 +126,14 @@ class ToolbarView(
/* Only set the search terms if pasted text is null so that the search term doesn't
overwrite pastedText when view enters `editMode` */
if (searchState.pastedText.isNullOrEmpty()) {
view.setSearchTerms(searchState.searchTerms)
// If we're in edit mode, setting the search term will update the toolbar,
// so we make sure we have the correct term/query to show.
val termOrQuery = if (searchState.searchTerms.isNotEmpty()) {
searchState.searchTerms
} else {
searchState.query
}
view.setSearchTerms(termOrQuery)
}
// We must trigger an onTextChanged so when search terms are set when transitioning to `editMode`

View File

@ -106,15 +106,26 @@ class ToolbarViewTest {
view.update(defaultState)
view.update(defaultState)
verify(exactly = 1) { toolbar.url = any() }
verify(exactly = 1) { toolbar.setSearchTerms(any()) }
verify(exactly = 1) { interactor.onTextChanged(any()) }
// editMode gets called when the view is initialized. So it is called twice in this test
verify(exactly = 2) { toolbar.editMode() }
assertTrue(view.isInitialized)
}
@Test
fun `search term updates the url`() {
val view = buildToolbarView(false)
view.update(defaultState)
view.update(defaultState)
view.update(defaultState)
// editMode gets called when the view is initialized.
verify(exactly = 2) { toolbar.editMode() }
// search term changes update the url and invoke the interactor.
verify(exactly = 2) { toolbar.url = any() }
verify(exactly = 2) { interactor.onTextChanged(any()) }
}
@Test
fun `URL gets set to the states query`() {
val toolbarView = buildToolbarView(false)

View File

@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object AndroidComponents {
const val VERSION = "54.0.20200806130142"
const val VERSION = "54.0.20200807130552"
}