Add test case for (de)select when in single file fragment

Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com>
This commit is contained in:
ZetaTom 2023-07-26 11:39:46 +02:00 committed by Andy Scherzinger
parent 0e13fe2c4d
commit f39170bc0d
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -269,6 +269,52 @@ class FileMenuFilterIT : AbstractIT() {
}
}
@Test
fun filter_select_all() {
configureCapability(OCCapability())
launchActivity<TestActivity>().use {
it.onActivity { activity ->
val filterFactory = FileMenuFilter.Factory(mockStorageManager, activity, editorUtils)
val files = listOf<OCFile>(OCFile("/foo.bin"), OCFile("/bar.bin"), OCFile("/baz.bin"))
// single file
var sut = filterFactory.newInstance(files.first(), mockComponentsGetter, true, user)
var toHide = sut.getToHide(true)
assertTrue(toHide.contains(R.id.action_select_all_action_menu))
assertTrue(toHide.contains(R.id.action_deselect_all_action_menu))
toHide = sut.getToHide(false)
assertTrue(toHide.contains(R.id.action_select_all_action_menu))
assertTrue(toHide.contains(R.id.action_deselect_all_action_menu))
// multiple files, all selected
sut = filterFactory.newInstance(files.size, files, mockComponentsGetter, false, user)
toHide = sut.getToHide(true)
assertTrue(toHide.contains(R.id.action_select_all_action_menu))
assertTrue(toHide.contains(R.id.action_deselect_all_action_menu))
toHide = sut.getToHide(false)
assertTrue(toHide.contains(R.id.action_select_all_action_menu))
assertFalse(toHide.contains(R.id.action_deselect_all_action_menu))
// multiple files, all but one selected
sut = filterFactory.newInstance(files.size + 1, files, mockComponentsGetter, false, user)
toHide = sut.getToHide(true)
assertTrue(toHide.contains(R.id.action_select_all_action_menu))
assertTrue(toHide.contains(R.id.action_deselect_all_action_menu))
toHide = sut.getToHide(false)
assertFalse(toHide.contains(R.id.action_select_all_action_menu))
assertFalse(toHide.contains(R.id.action_deselect_all_action_menu))
}
}
}
private data class ExpectedLockVisibilities(
val lockFile: Boolean,
val unlockFile: Boolean