From aded72af4199b7b5eb92d3379ea0e6358027d376 Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Tue, 17 Aug 2021 23:39:45 -0400 Subject: [PATCH] [fenix] Issue https://github.com/mozilla-mobile/fenix/issues/20864: Speculative fix for HomeFragmentTest failures --- .../java/org/mozilla/fenix/home/HomeFragmentTest.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/test/java/org/mozilla/fenix/home/HomeFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/home/HomeFragmentTest.kt index fbcbc6070a..8175422855 100644 --- a/app/src/test/java/org/mozilla/fenix/home/HomeFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/HomeFragmentTest.kt @@ -14,6 +14,9 @@ import mozilla.components.browser.menu.view.MenuButton import org.junit.Assert import org.junit.Before import org.junit.Test +import org.mozilla.fenix.FenixApplication +import org.mozilla.fenix.ext.application +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.utils.Settings @@ -26,13 +29,16 @@ class HomeFragmentTest { @Before fun setup() { - context = mockk(relaxed = true) settings = mockk(relaxed = true) + context = mockk(relaxed = true) + + val fenixApplication: FenixApplication = mockk(relaxed = true) homeFragment = spyk(HomeFragment()) + every { context.application } returns fenixApplication every { homeFragment.context } answers { context } - every { context.settings() } answers { settings } + every { context.components.settings } answers { settings } } @Test @@ -47,7 +53,7 @@ class HomeFragmentTest { @Test fun `GIVEN showTopFrecentSites is true WHEN getTopSitesConfig is called THEN it returns TopSitesConfig with non-null frecencyConfig`() { - every { context.settings().showTopFrecentSites } returns true + every { settings.showTopFrecentSites } returns true every { settings.topSitesMaxLimit } returns 10 val topSitesConfig = homeFragment.getTopSitesConfig()