fix(content): 콘텐츠 랭킹 rank 간격을 보정한다

This commit is contained in:
2026-06-25 15:57:53 +09:00
parent 2e86e21cb7
commit 11853761cf
7 changed files with 103 additions and 0 deletions

View File

@@ -2,8 +2,11 @@ package kr.co.vividnext.sodalive.v2.widget.contentranking
import android.app.Application
import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.test.core.app.ApplicationProvider
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
@@ -17,6 +20,77 @@ import org.robolectric.annotation.Config
@Config(sdk = [28], application = Application::class)
class ContentRankingCardViewTest {
@Test
fun `large card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 268))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 91,
expectedHeight = 114,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 10
)
}
@Test
fun `medium grid card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingMediumGridCardView>(R.layout.view_content_ranking_medium_grid_card)
view.setCardSize(ContentRankingCardSize(widthPx = 185, heightPx = 185))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 55,
expectedHeight = 75,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 6
)
}
@Test
fun `small grid card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingSmallGridCardView>(R.layout.view_content_ranking_small_grid_card)
view.setCardSize(ContentRankingCardSize(widthPx = 122, heightPx = 122))
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 42,
expectedHeight = 56,
expectedLeft = 8,
expectedTop = 0,
expectedBottomPadding = 5
)
}
@Test
fun `horizontal card 순위 숫자는 폰트 padding 없이 하단 보정 padding을 가진다`() {
val view = inflateView<ContentRankingHorizontalCardView>(R.layout.view_content_ranking_horizontal_card)
view.setCardSize(ContentRankingCardSize(widthPx = 374, heightPx = 100))
val rankGroup = view.findViewById<View>(R.id.ll_content_ranking_rank_group)
val rankGroupParams = rankGroup.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(49, rankGroupParams.width)
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, rankGroupParams.height)
assertEquals(14, rankGroupParams.leftMargin)
assertEquals(14, rankGroupParams.topMargin)
assertRankTextBox(
view = view.findViewById(R.id.tv_content_ranking_rank),
expectedWidth = 48,
expectedHeight = 52,
expectedLeft = 0,
expectedTop = 0,
expectedBottomPadding = 4
)
}
@Test
fun `large card는 showRankChange가 false이면 rank num을 숨긴다`() {
val view = inflateView<ContentRankingLargeCardView>(R.layout.view_content_ranking_large_card)
@@ -67,6 +141,24 @@ class ContentRankingCardViewTest {
return LayoutInflater.from(context).inflate(layoutResId, null, false) as T
}
private fun assertRankTextBox(
view: TextView,
expectedWidth: Int,
expectedHeight: Int,
expectedLeft: Int,
expectedTop: Int,
expectedBottomPadding: Int
) {
val params = view.layoutParams as ViewGroup.MarginLayoutParams
assertEquals(expectedWidth, params.width)
assertEquals(expectedHeight, params.height)
assertEquals(expectedLeft, params.leftMargin)
assertEquals(expectedTop, params.topMargin)
assertEquals(Gravity.CENTER, view.gravity)
assertEquals(false, view.includeFontPadding)
assertEquals(expectedBottomPadding, view.paddingBottom)
}
private fun sampleItem(
rank: Int = 1,
showRankChange: Boolean = true