refactor(creator): 진행 중 라이브 컴포넌트를 공통화한다
This commit is contained in:
+23
-23
@@ -11,7 +11,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.ui.calculateCreatorChannelSer
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.calculateCreatorChannelSeriesCardWidthDp
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.calculateCreatorChannelScheduleTimelineLineCount
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelDebutActivityValue
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelLiveDateTime
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelLiveTime
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleDate
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleDayOfWeek
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.ui.formatCreatorChannelScheduleTime
|
||||
@@ -929,31 +929,22 @@ class CreatorChannelActivitySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `현재 라이브 섹션은 전용 layout과 bind로 렌더링한다`() {
|
||||
fun `현재 라이브 섹션은 공통 View로 렌더링한다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/ui/CreatorChannelHomeSectionAdapter.kt"
|
||||
).readText()
|
||||
val liveLayout = projectFile("app/src/main/res/layout/item_creator_channel_home_live.xml").readText()
|
||||
|
||||
assertTrue(liveLayout.contains("@+id/layout_current_live_card"))
|
||||
assertTrue(liveLayout.contains("@+id/tv_current_live_title"))
|
||||
assertTrue(liveLayout.contains("@+id/tv_current_live_start_time"))
|
||||
assertTrue(liveLayout.contains("@+id/tv_current_live_price"))
|
||||
assertTrue(liveLayout.contains("@+id/tv_current_live_adult"))
|
||||
assertTrue(liveLayout.contains("@drawable/bg_creator_channel_current_live"))
|
||||
assertTrue(liveLayout.contains("@drawable/bg_creator_channel_current_live_price"))
|
||||
assertTrue(liveLayout.contains("@drawable/ic_can"))
|
||||
assertTrue(liveLayout.contains("android:layout_height=\"78dp\""))
|
||||
assertTrue(liveLayout.contains("CreatorChannelCurrentLiveView"))
|
||||
assertFalse(liveLayout.contains("@layout/view_section_title"))
|
||||
assertFalse(liveLayout.contains("@+id/tv_section_title"))
|
||||
assertFalse(liveLayout.contains("@+id/ll_section_items"))
|
||||
assertTrue(adapter.contains("private val currentLiveTitle: TextView?"))
|
||||
assertTrue(adapter.contains("private val currentLiveStartTime: TextView?"))
|
||||
assertTrue(adapter.contains("private val currentLivePrice: TextView?"))
|
||||
assertTrue(adapter.contains("private val currentLiveAdult: TextView?"))
|
||||
assertTrue(adapter.contains("currentLiveTitle?.text = item.live.title"))
|
||||
assertTrue(adapter.contains("currentLivePriceLayout?.isVisible = item.live.price > 0"))
|
||||
assertTrue(adapter.contains("currentLiveAdult?.isVisible = item.live.isAdult"))
|
||||
assertTrue(adapter.contains("private val currentLiveView: CreatorChannelCurrentLiveView?"))
|
||||
assertTrue(adapter.contains("currentLiveView?.bind(item.live, onLiveClick)"))
|
||||
assertFalse(adapter.contains("private val currentLiveTitle: TextView?"))
|
||||
assertFalse(adapter.contains("private val currentLiveStartTime: TextView?"))
|
||||
assertFalse(adapter.contains("private val currentLivePrice: TextView?"))
|
||||
assertFalse(adapter.contains("private val currentLiveAdult: TextView?"))
|
||||
assertFalse(adapter.contains("private fun addHeroCard"))
|
||||
assertFalse(adapter.contains("addHeroCard("))
|
||||
}
|
||||
@@ -1367,11 +1358,21 @@ class CreatorChannelActivitySourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `현재 진행 중인 라이브 시간은 디바이스 timezone 기준 초 단위 날짜 시간으로 표시한다`() {
|
||||
fun `현재 진행 중인 라이브 시간은 디바이스 timezone 기준 시분으로 표시한다`() {
|
||||
val timeZone = TimeZone.getTimeZone("Asia/Seoul")
|
||||
val locale = Locale.KOREA
|
||||
|
||||
assertEquals("2026.06.30 00:00:01", formatCreatorChannelLiveDateTime("2026-06-29T15:00:01Z", timeZone, locale))
|
||||
assertEquals("00:00", formatCreatorChannelLiveTime("2026-06-29T15:00:01Z", timeZone, locale))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `현재 진행 중인 라이브 UTC 시간이 잘못되면 빈 문자열을 표시한다`() {
|
||||
assertEquals("", formatCreatorChannelLiveTime("invalid"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `현재 진행 중인 라이브 UTC 시간 뒤에 추가 문자가 있으면 빈 문자열을 표시한다`() {
|
||||
assertEquals("", formatCreatorChannelLiveTime("2026-06-29T15:00:01Zjunk"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1601,9 +1602,8 @@ class CreatorChannelActivitySourceTest {
|
||||
).readText()
|
||||
|
||||
assertTrue(adapter.contains("private val onLiveClick: (CreatorChannelLiveResponse) -> Unit = {}"))
|
||||
assertTrue(adapter.contains("private val currentLiveCard: View?"))
|
||||
assertTrue(adapter.contains("currentLiveCard?.setOnClickListener"))
|
||||
assertTrue(adapter.contains("onLiveClick(item.live)"))
|
||||
assertTrue(adapter.contains("private val currentLiveView: CreatorChannelCurrentLiveView?"))
|
||||
assertTrue(adapter.contains("currentLiveView?.bind(item.live, onLiveClick)"))
|
||||
assertTrue(fragment.contains("onLiveClick = ::onCurrentLiveClicked"))
|
||||
assertTrue(fragment.contains("private fun onCurrentLiveClicked(live: CreatorChannelLiveResponse)"))
|
||||
assertTrue(fragment.contains("host.onCreatorChannelCurrentLiveClicked(live)"))
|
||||
|
||||
+16
-18
@@ -42,7 +42,6 @@ class CreatorChannelLiveFragmentLayoutTest {
|
||||
assertSame(emptyContainer, emptyMessage.parent)
|
||||
assertSame(root, errorMessage.parent)
|
||||
assertSame(root, retryButton.parent)
|
||||
assertNotNull(currentLiveCard.findViewById<TextView>(R.id.tv_creator_channel_live_current_title))
|
||||
assertEquals(false, replayList.clipToPadding)
|
||||
assertTrue(layout.contains("android:layout_height=\"wrap_content\""))
|
||||
assertTrue(layout.contains("android:id=\"@+id/layout_creator_channel_live_empty\""))
|
||||
@@ -64,6 +63,21 @@ class CreatorChannelLiveFragmentLayoutTest {
|
||||
assertFalse(layout.contains("app:layout_constraintBottom_toTopOf=\"@id/btn_creator_channel_live_retry\""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `라이브 탭 현재 라이브는 공통 View를 사용한다`() {
|
||||
val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_live.xml").readText()
|
||||
val fragment = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/CreatorChannelLiveFragment.kt"
|
||||
).readText()
|
||||
|
||||
assertTrue(layout.contains("CreatorChannelCurrentLiveView"))
|
||||
assertTrue(fragment.contains("layoutCreatorChannelLiveCurrentCard.bind(live"))
|
||||
assertFalse(fragment.contains("tvCreatorChannelLiveCurrentTitle.text"))
|
||||
assertFalse(fragment.contains("tvCreatorChannelLiveCurrentTime.text"))
|
||||
assertFalse(fragment.contains("tvCreatorChannelLiveCurrentPrice.text"))
|
||||
assertFalse(fragment.contains("ivCreatorChannelLiveCurrentPriceCash.isVisible"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `라이브 empty 상태는 추가 스크롤 영역을 만들지 않도록 minimumHeight를 사용하지 않는다`() {
|
||||
val fragment = projectFile(
|
||||
@@ -165,20 +179,14 @@ class CreatorChannelLiveFragmentLayoutTest {
|
||||
|
||||
@Test
|
||||
fun `라이브 layout은 가격 영역을 유연한 너비와 bar cash icon으로 제공한다`() {
|
||||
val fragmentLayout = projectFile("app/src/main/res/layout/fragment_creator_channel_live.xml").readText()
|
||||
val itemLayout = projectFile("app/src/main/res/layout/item_creator_channel_audio_content.xml").readText()
|
||||
val root = inflateView(R.layout.fragment_creator_channel_live)
|
||||
val item = inflateView(R.layout.item_creator_channel_audio_content)
|
||||
val currentPrice = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_live_current_price))
|
||||
val currentPriceCash = requireNotNull(root.findViewById<ImageView>(R.id.iv_creator_channel_live_current_price_cash))
|
||||
val replayAction = requireNotNull(item.findViewById<View>(R.id.layout_creator_channel_audio_content_action))
|
||||
val replayPlay = requireNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_play))
|
||||
val actionText = requireNotNull(item.findViewById<View>(R.id.layout_creator_channel_audio_content_action_text))
|
||||
val adultBadge = requireNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_adult_badge))
|
||||
val adultBadgeParams = adultBadge.layoutParams as ViewGroup.MarginLayoutParams
|
||||
|
||||
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, currentPrice.layoutParams.width)
|
||||
assertNotNull(currentPriceCash)
|
||||
assertEquals(ViewGroup.LayoutParams.WRAP_CONTENT, replayAction.layoutParams.width)
|
||||
assertEquals(dp(28), replayPlay.layoutParams.width)
|
||||
assertEquals(dp(28), replayPlay.layoutParams.height)
|
||||
@@ -186,18 +194,10 @@ class CreatorChannelLiveFragmentLayoutTest {
|
||||
assertEquals(dp(8), (actionText.layoutParams as ViewGroup.MarginLayoutParams).topMargin)
|
||||
assertEquals(dp(6), adultBadgeParams.topMargin)
|
||||
assertEquals(dp(6), adultBadgeParams.marginEnd)
|
||||
assertTrue(fragmentLayout.contains("@drawable/ic_bar_cash"))
|
||||
assertTrue(itemLayout.contains("@drawable/ic_bar_cash"))
|
||||
assertTrue(itemLayout.contains("@drawable/bg_creator_channel_live_replay_play"))
|
||||
assertTrue(itemLayout.contains("android:orientation=\"vertical\""))
|
||||
assertFalse(fragmentLayout.contains("@drawable/ic_can"))
|
||||
assertFalse(itemLayout.contains("@drawable/ic_can"))
|
||||
assertFalse(
|
||||
fragmentLayout.contains(
|
||||
"android:id=\"@+id/layout_creator_channel_live_current_price\"\n" +
|
||||
" android:layout_width=\"60dp\""
|
||||
)
|
||||
)
|
||||
assertFalse(
|
||||
itemLayout.contains(
|
||||
"android:id=\"@+id/layout_creator_channel_audio_content_action\"\n" +
|
||||
@@ -243,9 +243,7 @@ class CreatorChannelLiveFragmentLayoutTest {
|
||||
assertTrue(fragment.contains("viewModel.consumePaginationErrorMessage()"))
|
||||
assertTrue(fragment.contains("bindEmpty() = with(binding)"))
|
||||
assertTrue(fragment.contains("bindError(state: CreatorChannelLiveUiState.Error) = with(binding)"))
|
||||
assertTrue(fragment.contains("formatCreatorChannelLiveDateTime(live.beginDateTimeUtc)"))
|
||||
assertTrue(fragment.contains("ivCreatorChannelLiveCurrentPriceCash.isVisible = live.price > 0"))
|
||||
assertTrue(fragment.contains("R.string.audio_content_tag_free"))
|
||||
assertTrue(fragment.contains("layoutCreatorChannelLiveCurrentCard.bind(live"))
|
||||
assertTrue(fragment.contains("onCreatorChannelCurrentLiveClicked"))
|
||||
assertTrue(fragment.contains("onCreatorChannelLiveContentChanged"))
|
||||
assertFalse(fragment.contains("addOnScrollListener(object : RecyclerView.OnScrollListener()"))
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class CreatorChannelCurrentLiveViewModelTest {
|
||||
|
||||
@Test
|
||||
fun `양수 가격은 포맷된 금액과 가격 아이콘을 표시한다`() {
|
||||
val presentation = createCreatorChannelCurrentLivePresentation(
|
||||
price = 1200,
|
||||
isAdult = false,
|
||||
freeText = "무료",
|
||||
priceFormatter = { "$it CAN" }
|
||||
)
|
||||
|
||||
assertEquals("1200 CAN", presentation.priceText)
|
||||
assertTrue(presentation.showPriceIcon)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `0 이하 가격은 무료 문구를 표시하고 가격 아이콘을 숨긴다`() {
|
||||
listOf(0, -1).forEach { price ->
|
||||
val presentation = createCreatorChannelCurrentLivePresentation(
|
||||
price = price,
|
||||
isAdult = false,
|
||||
freeText = "무료",
|
||||
priceFormatter = Int::toString
|
||||
)
|
||||
|
||||
assertEquals("무료", presentation.priceText)
|
||||
assertFalse(presentation.showPriceIcon)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `성인 여부는 성인 배지 표시 상태에 반영한다`() {
|
||||
val adult = createCreatorChannelCurrentLivePresentation(
|
||||
price = 0,
|
||||
isAdult = true,
|
||||
freeText = "무료",
|
||||
priceFormatter = Int::toString
|
||||
)
|
||||
val allAges = createCreatorChannelCurrentLivePresentation(
|
||||
price = 0,
|
||||
isAdult = false,
|
||||
freeText = "무료",
|
||||
priceFormatter = Int::toString
|
||||
)
|
||||
|
||||
assertTrue(adult.showAdultBadge)
|
||||
assertFalse(allAges.showAdultBadge)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `유료와 무료 재바인딩 상태 전환은 표시 모델을 매번 새로 계산한다`() {
|
||||
val paidAdult = createCreatorChannelCurrentLivePresentation(
|
||||
price = 300,
|
||||
isAdult = true,
|
||||
freeText = "무료",
|
||||
priceFormatter = { "$it CAN" }
|
||||
)
|
||||
val freeAllAges = createCreatorChannelCurrentLivePresentation(
|
||||
price = 0,
|
||||
isAdult = false,
|
||||
freeText = "무료",
|
||||
priceFormatter = { "$it CAN" }
|
||||
)
|
||||
val paidAllAges = createCreatorChannelCurrentLivePresentation(
|
||||
price = 300,
|
||||
isAdult = false,
|
||||
freeText = "무료",
|
||||
priceFormatter = { "$it CAN" }
|
||||
)
|
||||
|
||||
assertEquals("300 CAN", paidAdult.priceText)
|
||||
assertTrue(paidAdult.showPriceIcon)
|
||||
assertTrue(paidAdult.showAdultBadge)
|
||||
assertEquals("무료", freeAllAges.priceText)
|
||||
assertFalse(freeAllAges.showPriceIcon)
|
||||
assertFalse(freeAllAges.showAdultBadge)
|
||||
assertEquals("300 CAN", paidAllAges.priceText)
|
||||
assertTrue(paidAllAges.showPriceIcon)
|
||||
assertFalse(paidAllAges.showAdultBadge)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user