Update Android Components and fix breaking tests
parent
bee2ae6c83
commit
9568bdaed8
|
@ -126,7 +126,14 @@ class ToolbarView(
|
||||||
/* Only set the search terms if pasted text is null so that the search term doesn't
|
/* Only set the search terms if pasted text is null so that the search term doesn't
|
||||||
overwrite pastedText when view enters `editMode` */
|
overwrite pastedText when view enters `editMode` */
|
||||||
if (searchState.pastedText.isNullOrEmpty()) {
|
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`
|
// We must trigger an onTextChanged so when search terms are set when transitioning to `editMode`
|
||||||
|
|
|
@ -106,15 +106,26 @@ class ToolbarViewTest {
|
||||||
view.update(defaultState)
|
view.update(defaultState)
|
||||||
view.update(defaultState)
|
view.update(defaultState)
|
||||||
|
|
||||||
verify(exactly = 1) { toolbar.url = any() }
|
|
||||||
verify(exactly = 1) { toolbar.setSearchTerms(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)
|
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
|
@Test
|
||||||
fun `URL gets set to the states query`() {
|
fun `URL gets set to the states query`() {
|
||||||
val toolbarView = buildToolbarView(false)
|
val toolbarView = buildToolbarView(false)
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
object AndroidComponents {
|
object AndroidComponents {
|
||||||
const val VERSION = "54.0.20200806130142"
|
const val VERSION = "54.0.20200807130552"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue