Skip to content

Commit

Permalink
Close mozilla-mobile#15168: Remove intermittent failing test in Toolb…
Browse files Browse the repository at this point in the history
…arViewTest

This test seems to be hacking at the binding between Fenix and the
BrowserToolbar to simulate toolbar events passing to the Fenix
interactor.

This is rather clumsy test that relies on the magic working of mockk
instead of following a general unit testing strategy that would commonly
require the class to be re-written to allow for better testing instead.

It is far safer to remove this test since we are not guaranteeing
anything in it and instead we see intermittent failures that make us
lose more time.

So therefore.. 🔥
  • Loading branch information
jonalmeida committed Aug 12, 2021
1 parent ecab4f2 commit 36184f3
Showing 1 changed file with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import io.mockk.verify
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.browser.toolbar.edit.EditToolbar
import mozilla.components.concept.engine.Engine
import mozilla.components.concept.toolbar.Toolbar
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -68,30 +66,6 @@ class ToolbarViewTest {
toolbar = spyk(BrowserToolbar(context))
}

@Test
fun `sets up interactor listeners`() {
lateinit var urlCommitListener: ((String) -> Boolean)
var editListener: Toolbar.OnEditListener? = null
every { toolbar.setOnUrlCommitListener(any()) } answers {
urlCommitListener = firstArg()
}
every { toolbar.setOnEditListener(any()) } answers {
editListener = firstArg()
}

buildToolbarView(isPrivate = false)

assertFalse(urlCommitListener("test"))
verify { interactor.onUrlCommitted("test") }

assertNotNull(editListener)
assertFalse(editListener!!.onCancelEditing())
verify { interactor.onEditingCanceled() }

editListener!!.onTextChanged("https://example.com")
verify { interactor.onTextChanged("https://example.com") }
}

@Test
fun `sets toolbar to normal mode`() {
buildToolbarView(isPrivate = false)
Expand Down

0 comments on commit 36184f3

Please sign in to comment.