Fix unit test for GalleryAdapter

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-04-19 10:45:28 +02:00
parent 997e4c736c
commit fb12a65949
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 25 additions and 1 deletions

View file

@ -59,7 +59,6 @@ class GalleryAdapter(
private var storageManager: FileDataStorageManager private var storageManager: FileDataStorageManager
init { init {
shouldShowFooters(false)
storageManager = transferServiceGetter.storageManager storageManager = transferServiceGetter.storageManager
ocFileListDelegate = OCFileListDelegate( ocFileListDelegate = OCFileListDelegate(
@ -76,6 +75,8 @@ class GalleryAdapter(
) )
} }
override fun showFooters(): Boolean = false
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SectionedViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SectionedViewHolder {
return if (viewType == VIEW_TYPE_HEADER) { return if (viewType == VIEW_TYPE_HEADER) {
GalleryHeaderViewHolder( GalleryHeaderViewHolder(

View file

@ -25,13 +25,19 @@ package com.owncloud.android.ui.adapter
import android.content.Context import android.content.Context
import com.nextcloud.client.account.User import com.nextcloud.client.account.User
import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.GalleryItems import com.owncloud.android.datamodel.GalleryItems
import com.owncloud.android.datamodel.OCFile import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.ui.activity.ComponentsGetter import com.owncloud.android.ui.activity.ComponentsGetter
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
import junit.framework.Assert.assertEquals import junit.framework.Assert.assertEquals
import org.junit.After
import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mockito.Mock import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.whenever
class GalleryAdapterTest { class GalleryAdapterTest {
@Mock @Mock
@ -49,8 +55,25 @@ class GalleryAdapterTest {
@Mock @Mock
lateinit var transferServiceGetter: ComponentsGetter lateinit var transferServiceGetter: ComponentsGetter
@Mock
lateinit var storageManager: FileDataStorageManager
private lateinit var mocks: AutoCloseable
@Before
fun setUp() {
mocks = MockitoAnnotations.openMocks(this)
}
@After
fun tearDown() {
mocks.close()
}
@Test @Test
fun testItemCount() { fun testItemCount() {
whenever(transferServiceGetter.storageManager) doReturn storageManager
val sut = GalleryAdapter( val sut = GalleryAdapter(
context, context,
user, user,