feat(content): 랭킹 변동 숨김 처리를 추가한다
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package kr.co.vividnext.sodalive.v2.widget.contentranking
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class ContentRankingCardViewTest {
|
||||
|
||||
@Test
|
||||
fun `large card는 showRankChange가 false이면 rank num을 숨긴다`() {
|
||||
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_content_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `medium grid card는 showRankChange가 false이면 rank num을 숨긴다`() {
|
||||
val view = inflateView<ContentRankingMediumGridCardView>(R.layout.view_content_ranking_medium_grid_card)
|
||||
|
||||
view.bind(sampleItem(rank = 2, showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_content_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `small grid card는 showRankChange가 false이면 rank num을 숨긴다`() {
|
||||
val view = inflateView<ContentRankingSmallGridCardView>(R.layout.view_content_ranking_small_grid_card)
|
||||
|
||||
view.bind(sampleItem(rank = 8, showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_content_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `horizontal card는 showRankChange가 false이면 rank num을 숨긴다`() {
|
||||
val view = inflateView<ContentRankingHorizontalCardView>(R.layout.view_content_ranking_horizontal_card)
|
||||
|
||||
view.bind(sampleItem(rank = 11, showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_content_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `card는 showRankChange가 true이면 rank num을 보여준다`() {
|
||||
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = true))
|
||||
|
||||
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_content_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
private inline fun <reified T : View> inflateView(layoutResId: Int): T {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
return LayoutInflater.from(context).inflate(layoutResId, null, false) as T
|
||||
}
|
||||
|
||||
private fun sampleItem(
|
||||
rank: Int = 1,
|
||||
showRankChange: Boolean = true
|
||||
) = ContentRankingItem(
|
||||
contentId = "content-1",
|
||||
creatorId = "creator-1",
|
||||
rank = rank,
|
||||
previousRank = 5,
|
||||
rankChangeType = Increase,
|
||||
rankChangeAmount = 4,
|
||||
contentName = "콘텐츠 이름",
|
||||
creatorName = "크리에이터 이름",
|
||||
imageUrl = "https://example.com/image.png",
|
||||
isBlocked = false,
|
||||
showRankChange = showRankChange
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user