@ -10,7 +10,8 @@ import io.mockk.mockk
import io.mockk.verify
import io.mockk.verify
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.top.sites.TopSite
import mozilla.components.feature.top.sites.TopSite
import mozilla.components.service.pocket.PocketRecommendedStory
import mozilla.components.service.pocket.PocketStory
import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertFalse
@ -67,24 +68,24 @@ class SessionControlViewTest {
@Test
@Test
fun `GIVEN pocketArticles WHEN calling shouldShowHomeOnboardingDialog THEN show the dialog ` ( ) {
fun `GIVEN pocketArticles WHEN calling shouldShowHomeOnboardingDialog THEN show the dialog ` ( ) {
val pocket Articl es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 0 , 0 ) )
val pocket Stori es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 0 , 0 ) )
val settings : Settings = mockk ( )
val settings : Settings = mockk ( )
every { settings . hasShownHomeOnboardingDialog } returns false
every { settings . hasShownHomeOnboardingDialog } returns false
val state = AppState ( pocketStories = pocket Articl es)
val state = AppState ( pocketStories = pocket Stori es)
assertTrue ( state . shouldShowHomeOnboardingDialog ( settings ) )
assertTrue ( state . shouldShowHomeOnboardingDialog ( settings ) )
}
}
@Test
@Test
fun `GIVEN the home onboading dialog has been shown before WHEN calling shouldShowHomeOnboardingDialog THEN DO NOT showthe dialog ` ( ) {
fun `GIVEN the home onboading dialog has been shown before WHEN calling shouldShowHomeOnboardingDialog THEN DO NOT showthe dialog ` ( ) {
val pocket Articl es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 0 , 0 ) )
val pocket Stori es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 0 , 0 ) )
val settings : Settings = mockk ( )
val settings : Settings = mockk ( )
every { settings . hasShownHomeOnboardingDialog } returns true
every { settings . hasShownHomeOnboardingDialog } returns true
val state = AppState ( pocketStories = pocket Articl es)
val state = AppState ( pocketStories = pocket Stori es)
assertFalse ( state . shouldShowHomeOnboardingDialog ( settings ) )
assertFalse ( state . shouldShowHomeOnboardingDialog ( settings ) )
}
}
@ -139,7 +140,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf ( RecentBookmark ( ) )
val recentBookmarks = listOf ( RecentBookmark ( ) )
val recentTabs = emptyList < RecentTab . Tab > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val pocket Articl es = emptyList < Pocket Recommended Story> ( )
val pocket Stori es = emptyList < Pocket Story> ( )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -157,7 +158,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
@ -175,7 +176,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf ( RecentBookmark ( ) )
val recentBookmarks = listOf ( RecentBookmark ( ) )
val recentTabs = emptyList < RecentTab . Tab > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val pocket Articl es = emptyList < Pocket Recommended Story> ( )
val pocket Stori es = emptyList < Pocket Story> ( )
val nimbusMessageCard : Message = mockk ( )
val nimbusMessageCard : Message = mockk ( )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
@ -194,7 +195,7 @@ class SessionControlViewTest {
nimbusMessageCard ,
nimbusMessageCard ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results . contains ( AdapterItem . NimbusMessageCard ( nimbusMessageCard ) ) )
assertTrue ( results . contains ( AdapterItem . NimbusMessageCard ( nimbusMessageCard ) ) )
@ -209,7 +210,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf < RecentBookmark > ( )
val recentBookmarks = listOf < RecentBookmark > ( )
val recentTabs = listOf < RecentTab . Tab > ( mockk ( ) )
val recentTabs = listOf < RecentTab . Tab > ( mockk ( ) )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val pocket Articl es = emptyList < Pocket Recommended Story> ( )
val pocket Stori es = emptyList < Pocket Story> ( )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -227,7 +228,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
@ -245,7 +246,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf < RecentBookmark > ( )
val recentBookmarks = listOf < RecentBookmark > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val historyMetadata = listOf ( RecentHistoryGroup ( " title " , emptyList ( ) ) )
val historyMetadata = listOf ( RecentHistoryGroup ( " title " , emptyList ( ) ) )
val pocket Articl es = emptyList < Pocket Recommended Story> ( )
val pocket Stori es = emptyList < Pocket Story> ( )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -263,7 +264,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
@ -281,7 +282,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf < RecentBookmark > ( )
val recentBookmarks = listOf < RecentBookmark > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val pocket Articl es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 1 , 1 ) )
val pocket Stori es = listOf ( PocketRecommendedStory ( " " , " " , " " , " " , " " , 1 , 1 ) )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -299,7 +300,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
@ -318,7 +319,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf < RecentBookmark > ( )
val recentBookmarks = listOf < RecentBookmark > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val recentTabs = emptyList < RecentTab . Tab > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val historyMetadata = emptyList < RecentHistoryGroup > ( )
val pocket Articl es = emptyList < Pocket Recommended Story> ( )
val pocket Stori es = emptyList < Pocket Story> ( )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -336,7 +337,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertEquals ( results . size , 2 )
assertEquals ( results . size , 2 )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
@ -354,7 +355,7 @@ class SessionControlViewTest {
val recentBookmarks = listOf < RecentBookmark > ( mockk ( ) )
val recentBookmarks = listOf < RecentBookmark > ( mockk ( ) )
val recentTabs = listOf < RecentTab . Tab > ( mockk ( ) )
val recentTabs = listOf < RecentTab . Tab > ( mockk ( ) )
val historyMetadata = listOf < RecentHistoryGroup > ( mockk ( ) )
val historyMetadata = listOf < RecentHistoryGroup > ( mockk ( ) )
val pocket Articl es = listOf < Pocket Recommended Story> ( mockk ( ) )
val pocket Stori es = listOf < Pocket Story> ( mockk ( ) )
every { settings . showTopSitesFeature } returns true
every { settings . showTopSitesFeature } returns true
every { settings . showRecentTabsFeature } returns true
every { settings . showRecentTabsFeature } returns true
@ -372,7 +373,7 @@ class SessionControlViewTest {
null ,
null ,
recentTabs ,
recentTabs ,
historyMetadata ,
historyMetadata ,
pocket Articl es
pocket Stori es
)
)
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )
assertTrue ( results [ 0 ] is AdapterItem . TopPlaceholderItem )