feat(widget): 랭킹 카드 순위 변동 숨김을 적용한다
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
package kr.co.vividnext.sodalive.v2.widget.creatorranking
|
||||
|
||||
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 CreatorRankingAdapterLayoutTest {
|
||||
|
||||
@Test
|
||||
@@ -25,4 +37,77 @@ class CreatorRankingAdapterLayoutTest {
|
||||
assertEquals(6, spanLookup.getSpanSize(position))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `large card는 순위 변동 숨김이면 delta를 숨긴다`() {
|
||||
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `large card는 순위 변동 표시이면 delta를 보여준다`() {
|
||||
val view = inflateView<CreatorRankingLargeCardView>(R.layout.view_creator_ranking_large_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = true))
|
||||
|
||||
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compact card는 순위 변동 숨김이면 delta를 숨긴다`() {
|
||||
val view = inflateView<CreatorRankingCompactCardView>(R.layout.view_creator_ranking_compact_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compact card는 순위 변동 표시이면 delta를 보여준다`() {
|
||||
val view = inflateView<CreatorRankingCompactCardView>(R.layout.view_creator_ranking_compact_card)
|
||||
|
||||
view.bind(sampleItem(showRankChange = true))
|
||||
|
||||
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `horizontal card는 순위 변동 숨김이면 delta를 숨긴다`() {
|
||||
val view = inflateView<CreatorRankingHorizontalCardView>(R.layout.view_creator_ranking_horizontal_card)
|
||||
|
||||
view.bind(sampleItem(rank = 11, showRankChange = false))
|
||||
|
||||
assertEquals(View.GONE, view.findViewById<View>(R.id.ll_creator_ranking_delta).visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `horizontal card는 순위 변동 표시이면 delta를 보여준다`() {
|
||||
val view = inflateView<CreatorRankingHorizontalCardView>(R.layout.view_creator_ranking_horizontal_card)
|
||||
|
||||
view.bind(sampleItem(rank = 11, showRankChange = true))
|
||||
|
||||
assertEquals(View.VISIBLE, view.findViewById<View>(R.id.ll_creator_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
|
||||
) = CreatorRankingItem(
|
||||
creatorId = 1L,
|
||||
rank = rank,
|
||||
rankChangeType = Increase,
|
||||
rankChangeAmount = 4,
|
||||
creatorName = "크리에이터 이름",
|
||||
imageUrl = "https://example.com/image.png",
|
||||
isBlocked = false,
|
||||
showRankChange = showRankChange
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user