feat(banner): 배너 wrap content 높이를 지원한다
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -120,6 +120,36 @@ class BannerViewTest {
|
||||
assertEquals(362.dpToPx(), holder.itemView.layoutParams.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `배너 view는 wrap content 높이면 402dp 폭 기준 362dp 높이로 측정된다`() {
|
||||
val view = inflateBannerView()
|
||||
|
||||
view.setItems(listOf(sampleItem("1"), sampleItem("2")))
|
||||
view.measure(exactly(402.dpToPx()), atMost(1_000.dpToPx()))
|
||||
|
||||
assertEquals(362.dpToPx(), view.measuredHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `배너 view는 wrap content 높이면 360dp 폭 기준 320dp 높이로 측정된다`() {
|
||||
val view = inflateBannerView()
|
||||
|
||||
view.setItems(listOf(sampleItem("1"), sampleItem("2")))
|
||||
view.measure(exactly(360.dpToPx()), atMost(1_000.dpToPx()))
|
||||
|
||||
assertEquals(320.dpToPx(), view.measuredHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `배너 view는 명시 높이면 부모 측정 높이를 유지한다`() {
|
||||
val view = inflateBannerView()
|
||||
|
||||
view.setItems(listOf(sampleItem("1"), sampleItem("2")))
|
||||
view.measure(exactly(402.dpToPx()), exactly(500.dpToPx()))
|
||||
|
||||
assertEquals(500.dpToPx(), view.measuredHeight)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `배너 view는 단일 item이면 item 간격을 적용하지 않는다`() {
|
||||
val view = inflateBannerView()
|
||||
@@ -303,6 +333,8 @@ class BannerViewTest {
|
||||
|
||||
private fun exactly(size: Int): Int = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY)
|
||||
|
||||
private fun atMost(size: Int): Int = MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST)
|
||||
|
||||
private fun Int.dpToPx(): Int {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
return (this * context.resources.displayMetrics.density).toInt()
|
||||
|
||||
Reference in New Issue
Block a user