forked from mozilla-mobile/android-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mozilla-mobile#6907 - Adds test for TabSessionState
- Loading branch information
Showing
3 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...nts/feature/tabs/src/test/java/mozilla/components/feature/tabs/ext/TabSessionStateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.feature.tabs.ext | ||
|
||
|
||
import mozilla.components.browser.state.state.BrowserState | ||
import mozilla.components.browser.state.state.MediaState | ||
import mozilla.components.browser.state.state.createTab | ||
import mozilla.components.browser.state.store.BrowserStore | ||
import mozilla.components.concept.engine.media.Media | ||
import org.junit.Test | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNull | ||
|
||
class TabSessionStateTest { | ||
@Test | ||
fun `mediaState gets set correctly`() { | ||
var browserState = BrowserState( | ||
tabs = listOf( | ||
createTab("https://www.mozilla.org", id = "a"), | ||
createTab("https://getpocket.com", id = "b"), | ||
createTab("https://developer.mozilla.org", id = "c"), | ||
createTab("https://www.firefox.com", id = "d"), | ||
createTab("https://www.google.com", id = "e") | ||
), | ||
selectedTabId = "a", | ||
media = MediaState(MediaState.Aggregate(activeTabId = "a", state = MediaState.State.PLAYING)) | ||
) | ||
|
||
var tabs = browserState.toTabs() | ||
assertEquals(Media.State.PLAYING, tabs.list[0].mediaState) | ||
|
||
browserState = browserState.copy( | ||
media = MediaState(MediaState.Aggregate(activeTabId = "b", state = MediaState.State.PAUSED)) | ||
) | ||
tabs = browserState.toTabs() | ||
assertNull(tabs.list[0].mediaState) | ||
assertEquals(Media.State.PAUSED, tabs.list[1].mediaState) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters