test(widget): 랭킹 순위 텍스트 정렬 검증을 추가한다
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/pattaya_regular"
|
android:fontFamily="@font/pattaya_regular"
|
||||||
|
android:gravity="center"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:shadowColor="#7A000000"
|
android:shadowColor="#7A000000"
|
||||||
android:shadowRadius="4"
|
android:shadowRadius="4"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/pattaya_regular"
|
android:fontFamily="@font/pattaya_regular"
|
||||||
|
android:gravity="center"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:shadowColor="#7A000000"
|
android:shadowColor="#7A000000"
|
||||||
android:shadowRadius="4"
|
android:shadowRadius="4"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="@font/pattaya_regular"
|
android:fontFamily="@font/pattaya_regular"
|
||||||
|
android:gravity="center"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:shadowColor="#7A000000"
|
android:shadowColor="#7A000000"
|
||||||
android:shadowRadius="4"
|
android:shadowRadius="4"
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package kr.co.vividnext.sodalive.v2.widget.creatorranking
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
|
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
|
||||||
@@ -38,6 +41,65 @@ class CreatorRankingAdapterLayoutTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `large card 순위 숫자는 Figma 고정 박스 안에서 중앙 정렬된다`() {
|
||||||
|
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
|
||||||
|
|
||||||
|
view.setCardSize(CreatorRankingCardSize(widthPx = 374, heightPx = 374))
|
||||||
|
|
||||||
|
assertRankTextBox(
|
||||||
|
view = view.findViewById(R.id.tv_creator_ranking_rank),
|
||||||
|
expectedWidth = 112,
|
||||||
|
expectedHeight = 124,
|
||||||
|
expectedLeft = 0,
|
||||||
|
expectedTop = 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `compact medium card 순위 숫자는 Figma 고정 박스 안에서 중앙 정렬된다`() {
|
||||||
|
val view = inflateView<CreatorRankingCompactCardView>(R.layout.view_creator_ranking_compact_card)
|
||||||
|
|
||||||
|
view.setCardSize(CreatorRankingCardSize(widthPx = 185, heightPx = 185))
|
||||||
|
|
||||||
|
assertRankTextBox(
|
||||||
|
view = view.findViewById(R.id.tv_creator_ranking_rank),
|
||||||
|
expectedWidth = 55,
|
||||||
|
expectedHeight = 75,
|
||||||
|
expectedLeft = 0,
|
||||||
|
expectedTop = 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `compact small card 순위 숫자는 Figma 고정 박스 안에서 중앙 정렬된다`() {
|
||||||
|
val view = inflateView<CreatorRankingCompactCardView>(R.layout.view_creator_ranking_compact_card)
|
||||||
|
|
||||||
|
view.setCardSize(CreatorRankingCardSize(widthPx = 122, heightPx = 122))
|
||||||
|
|
||||||
|
assertRankTextBox(
|
||||||
|
view = view.findViewById(R.id.tv_creator_ranking_rank),
|
||||||
|
expectedWidth = 42,
|
||||||
|
expectedHeight = 56,
|
||||||
|
expectedLeft = 8,
|
||||||
|
expectedTop = 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `horizontal card 순위 그룹은 Figma 고정 박스 위치를 유지한다`() {
|
||||||
|
val view = inflateView<CreatorRankingHorizontalCardView>(R.layout.view_creator_ranking_horizontal_card)
|
||||||
|
|
||||||
|
view.setCardSize(CreatorRankingCardSize(widthPx = 374, heightPx = 100))
|
||||||
|
|
||||||
|
val rankGroup = view.findViewById<View>(R.id.ll_creator_ranking_rank_group)
|
||||||
|
val params = rankGroup.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
|
assertEquals(49, params.width)
|
||||||
|
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, params.height)
|
||||||
|
assertEquals(14, params.leftMargin)
|
||||||
|
assertEquals(14, params.topMargin)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `large card는 순위 변동 숨김이면 delta를 숨긴다`() {
|
fun `large card는 순위 변동 숨김이면 delta를 숨긴다`() {
|
||||||
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
|
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
|
||||||
@@ -92,6 +154,21 @@ class CreatorRankingAdapterLayoutTest {
|
|||||||
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun assertRankTextBox(
|
||||||
|
view: TextView,
|
||||||
|
expectedWidth: Int,
|
||||||
|
expectedHeight: Int,
|
||||||
|
expectedLeft: Int,
|
||||||
|
expectedTop: 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)
|
||||||
|
}
|
||||||
|
|
||||||
private inline fun <reified T : View> inflateView(layoutResId: Int): T {
|
private inline fun <reified T : View> inflateView(layoutResId: Int): T {
|
||||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
return LayoutInflater.from(context).inflate(layoutResId, null, false) as T
|
return LayoutInflater.from(context).inflate(layoutResId, null, false) as T
|
||||||
|
|||||||
Reference in New Issue
Block a user