|
|
@ -80,32 +80,63 @@ class BookmarkFragmentStoreTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `ensure selected items remain selected after a tree change`() = runBlocking {
|
|
|
|
fun `ensure selected items remain selected after a tree change`() = runBlocking {
|
|
|
|
val initialState = BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(item, subfolder)))
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(item, subfolder)),
|
|
|
|
|
|
|
|
isLoading = false,
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.Change(newTree)).join()
|
|
|
|
store.dispatch(BookmarkFragmentAction.Change(newTree)).join()
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(store.state.tree, newTree)
|
|
|
|
assertEquals(
|
|
|
|
assertEquals(store.state.mode, BookmarkFragmentState.Mode.Selecting(setOf(subfolder)))
|
|
|
|
store.state,
|
|
|
|
|
|
|
|
BookmarkFragmentState(
|
|
|
|
|
|
|
|
newTree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(subfolder)),
|
|
|
|
|
|
|
|
guidBackstack = listOf(tree.guid),
|
|
|
|
|
|
|
|
isLoading = false,
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `select and deselect bookmarks changes the mode`() = runBlocking {
|
|
|
|
fun `select and deselect a single bookmark changes the mode and swipe to refresh state`() = runBlocking {
|
|
|
|
val initialState = BookmarkFragmentState(tree)
|
|
|
|
val initialState = BookmarkFragmentState(tree)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.Select(childItem)).join()
|
|
|
|
store.dispatch(BookmarkFragmentAction.Select(childItem)).join()
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(childItem))))
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
store.state,
|
|
|
|
|
|
|
|
BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(childItem)),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.Deselect(childItem)).join()
|
|
|
|
store.dispatch(BookmarkFragmentAction.Deselect(childItem)).join()
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(store.state, BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Normal()))
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
store.state,
|
|
|
|
|
|
|
|
BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Normal(),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `selecting the same item twice does nothing`() = runBlocking {
|
|
|
|
fun `selecting the same item twice does nothing`() = runBlocking {
|
|
|
|
val initialState = BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(item, subfolder)))
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(item, subfolder)),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.Select(item)).join()
|
|
|
|
store.dispatch(BookmarkFragmentAction.Select(item)).join()
|
|
|
@ -115,7 +146,11 @@ class BookmarkFragmentStoreTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `deselecting an unselected bookmark does nothing`() = runBlocking {
|
|
|
|
fun `deselecting an unselected bookmark does nothing`() = runBlocking {
|
|
|
|
val initialState = BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(childItem)))
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(childItem)),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.Deselect(item)).join()
|
|
|
|
store.dispatch(BookmarkFragmentAction.Deselect(item)).join()
|
|
|
@ -134,14 +169,25 @@ class BookmarkFragmentStoreTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `deselect all bookmarks changes the mode`() = runBlocking {
|
|
|
|
fun `deselect all bookmarks changes the mode and updates swipe to refresh state`() =
|
|
|
|
val initialState = BookmarkFragmentState(tree, BookmarkFragmentState.Mode.Selecting(setOf(item, childItem)))
|
|
|
|
runBlocking {
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
store.dispatch(BookmarkFragmentAction.DeselectAll).join()
|
|
|
|
BookmarkFragmentState.Mode.Selecting(setOf(item, childItem)),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
assertEquals(store.state, initialState.copy(mode = BookmarkFragmentState.Mode.Normal()))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.DeselectAll).join()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
|
|
|
store.state,
|
|
|
|
|
|
|
|
initialState.copy(
|
|
|
|
|
|
|
|
mode = BookmarkFragmentState.Mode.Normal(),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `deselect all bookmarks when none are selected`() = runBlocking {
|
|
|
|
fun `deselect all bookmarks when none are selected`() = runBlocking {
|
|
|
@ -214,6 +260,45 @@ class BookmarkFragmentStoreTest {
|
|
|
|
assertEquals(BookmarkFragmentState.Mode.Syncing, store.state.mode)
|
|
|
|
assertEquals(BookmarkFragmentState.Mode.Syncing, store.state.mode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun `enabling swipe to refresh in Normal mode works`() = runBlocking {
|
|
|
|
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Normal(),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.SwipeRefreshAvailabilityChanged(true)).join()
|
|
|
|
|
|
|
|
assertEquals(true, store.state.isSwipeToRefreshEnabled)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun `enabling swipe to refresh in Syncing mode works`() = runBlocking {
|
|
|
|
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Syncing,
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.SwipeRefreshAvailabilityChanged(true)).join()
|
|
|
|
|
|
|
|
assertEquals(true, store.state.isSwipeToRefreshEnabled)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
fun `enabling swipe to refresh in Selecting mode does not work`() = runBlocking {
|
|
|
|
|
|
|
|
val initialState = BookmarkFragmentState(
|
|
|
|
|
|
|
|
tree,
|
|
|
|
|
|
|
|
BookmarkFragmentState.Mode.Selecting(emptySet()),
|
|
|
|
|
|
|
|
isSwipeToRefreshEnabled = false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
val store = BookmarkFragmentStore(initialState)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
store.dispatch(BookmarkFragmentAction.SwipeRefreshAvailabilityChanged(true)).join()
|
|
|
|
|
|
|
|
assertEquals(false, store.state.isSwipeToRefreshEnabled)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private val item = BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null)
|
|
|
|
private val item = BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null)
|
|
|
|
private val separator = BookmarkNode(BookmarkNodeType.SEPARATOR, "789", "123", 1, null, null, null)
|
|
|
|
private val separator = BookmarkNode(BookmarkNodeType.SEPARATOR, "789", "123", 1, null, null, null)
|
|
|
|
private val subfolder = BookmarkNode(BookmarkNodeType.FOLDER, "987", "123", 0, "Subfolder", null, listOf())
|
|
|
|
private val subfolder = BookmarkNode(BookmarkNodeType.FOLDER, "987", "123", 0, "Subfolder", null, listOf())
|
|
|
|